This commit is contained in:
111
node_modules/dnd-core/dist/cjs/actions/dragDrop/beginDrag.js
generated
vendored
Normal file
111
node_modules/dnd-core/dist/cjs/actions/dragDrop/beginDrag.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createBeginDrag = createBeginDrag;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _setClientOffset = require("./local/setClientOffset");
|
||||
|
||||
var _js_utils = require("../../utils/js_utils");
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
var ResetCoordinatesAction = {
|
||||
type: _types.INIT_COORDS,
|
||||
payload: {
|
||||
clientOffset: null,
|
||||
sourceClientOffset: null
|
||||
}
|
||||
};
|
||||
|
||||
function createBeginDrag(manager) {
|
||||
return function beginDrag() {
|
||||
var sourceIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
publishSource: true
|
||||
};
|
||||
var _options$publishSourc = options.publishSource,
|
||||
publishSource = _options$publishSourc === void 0 ? true : _options$publishSourc,
|
||||
clientOffset = options.clientOffset,
|
||||
getSourceClientOffset = options.getSourceClientOffset;
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry(); // Initialize the coordinates using the client offset
|
||||
|
||||
manager.dispatch((0, _setClientOffset.setClientOffset)(clientOffset));
|
||||
verifyInvariants(sourceIds, monitor, registry); // Get the draggable source
|
||||
|
||||
var sourceId = getDraggableSource(sourceIds, monitor);
|
||||
|
||||
if (sourceId === null) {
|
||||
manager.dispatch(ResetCoordinatesAction);
|
||||
return;
|
||||
} // Get the source client offset
|
||||
|
||||
|
||||
var sourceClientOffset = null;
|
||||
|
||||
if (clientOffset) {
|
||||
if (!getSourceClientOffset) {
|
||||
throw new Error('getSourceClientOffset must be defined');
|
||||
}
|
||||
|
||||
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
|
||||
sourceClientOffset = getSourceClientOffset(sourceId);
|
||||
} // Initialize the full coordinates
|
||||
|
||||
|
||||
manager.dispatch((0, _setClientOffset.setClientOffset)(clientOffset, sourceClientOffset));
|
||||
var source = registry.getSource(sourceId);
|
||||
var item = source.beginDrag(monitor, sourceId); // If source.beginDrag returns null, this is an indicator to cancel the drag
|
||||
|
||||
if (item == null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
verifyItemIsObject(item);
|
||||
registry.pinSource(sourceId);
|
||||
var itemType = registry.getSourceType(sourceId);
|
||||
return {
|
||||
type: _types.BEGIN_DRAG,
|
||||
payload: {
|
||||
itemType: itemType,
|
||||
item: item,
|
||||
sourceId: sourceId,
|
||||
clientOffset: clientOffset || null,
|
||||
sourceClientOffset: sourceClientOffset || null,
|
||||
isSourcePublic: !!publishSource
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyInvariants(sourceIds, monitor, registry) {
|
||||
(0, _invariant.invariant)(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
|
||||
sourceIds.forEach(function (sourceId) {
|
||||
(0, _invariant.invariant)(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
|
||||
});
|
||||
}
|
||||
|
||||
function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
|
||||
(0, _invariant.invariant)(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
|
||||
}
|
||||
|
||||
function verifyItemIsObject(item) {
|
||||
(0, _invariant.invariant)((0, _js_utils.isObject)(item), 'Item must be an object.');
|
||||
}
|
||||
|
||||
function getDraggableSource(sourceIds, monitor) {
|
||||
var sourceId = null;
|
||||
|
||||
for (var i = sourceIds.length - 1; i >= 0; i--) {
|
||||
if (monitor.canDragSource(sourceIds[i])) {
|
||||
sourceId = sourceIds[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sourceId;
|
||||
}
|
||||
66
node_modules/dnd-core/dist/cjs/actions/dragDrop/drop.js
generated
vendored
Normal file
66
node_modules/dnd-core/dist/cjs/actions/dragDrop/drop.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createDrop = createDrop;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
var _js_utils = require("../../utils/js_utils");
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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; }
|
||||
|
||||
function createDrop(manager) {
|
||||
return function drop() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
verifyInvariants(monitor);
|
||||
var targetIds = getDroppableTargets(monitor); // Multiple actions are dispatched here, which is why this doesn't return an action
|
||||
|
||||
targetIds.forEach(function (targetId, index) {
|
||||
var dropResult = determineDropResult(targetId, index, registry, monitor);
|
||||
var action = {
|
||||
type: _types.DROP,
|
||||
payload: {
|
||||
dropResult: _objectSpread(_objectSpread({}, options), dropResult)
|
||||
}
|
||||
};
|
||||
manager.dispatch(action);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function verifyInvariants(monitor) {
|
||||
(0, _invariant.invariant)(monitor.isDragging(), 'Cannot call drop while not dragging.');
|
||||
(0, _invariant.invariant)(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
|
||||
}
|
||||
|
||||
function determineDropResult(targetId, index, registry, monitor) {
|
||||
var target = registry.getTarget(targetId);
|
||||
var dropResult = target ? target.drop(monitor, targetId) : undefined;
|
||||
verifyDropResultType(dropResult);
|
||||
|
||||
if (typeof dropResult === 'undefined') {
|
||||
dropResult = index === 0 ? {} : monitor.getDropResult();
|
||||
}
|
||||
|
||||
return dropResult;
|
||||
}
|
||||
|
||||
function verifyDropResultType(dropResult) {
|
||||
(0, _invariant.invariant)(typeof dropResult === 'undefined' || (0, _js_utils.isObject)(dropResult), 'Drop result must either be an object or undefined.');
|
||||
}
|
||||
|
||||
function getDroppableTargets(monitor) {
|
||||
var targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
|
||||
targetIds.reverse();
|
||||
return targetIds;
|
||||
}
|
||||
33
node_modules/dnd-core/dist/cjs/actions/dragDrop/endDrag.js
generated
vendored
Normal file
33
node_modules/dnd-core/dist/cjs/actions/dragDrop/endDrag.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createEndDrag = createEndDrag;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
function createEndDrag(manager) {
|
||||
return function endDrag() {
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
verifyIsDragging(monitor);
|
||||
var sourceId = monitor.getSourceId();
|
||||
|
||||
if (sourceId != null) {
|
||||
var source = registry.getSource(sourceId, true);
|
||||
source.endDrag(monitor, sourceId);
|
||||
registry.unpinSource();
|
||||
}
|
||||
|
||||
return {
|
||||
type: _types.END_DRAG
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyIsDragging(monitor) {
|
||||
(0, _invariant.invariant)(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
|
||||
}
|
||||
73
node_modules/dnd-core/dist/cjs/actions/dragDrop/hover.js
generated
vendored
Normal file
73
node_modules/dnd-core/dist/cjs/actions/dragDrop/hover.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createHover = createHover;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _matchesType = require("../../utils/matchesType");
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
function createHover(manager) {
|
||||
return function hover(targetIdsArg) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
clientOffset = _ref.clientOffset;
|
||||
|
||||
verifyTargetIdsIsArray(targetIdsArg);
|
||||
var targetIds = targetIdsArg.slice(0);
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
checkInvariants(targetIds, monitor, registry);
|
||||
var draggedItemType = monitor.getItemType();
|
||||
removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
|
||||
hoverAllTargets(targetIds, monitor, registry);
|
||||
return {
|
||||
type: _types.HOVER,
|
||||
payload: {
|
||||
targetIds: targetIds,
|
||||
clientOffset: clientOffset || null
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyTargetIdsIsArray(targetIdsArg) {
|
||||
(0, _invariant.invariant)(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
|
||||
}
|
||||
|
||||
function checkInvariants(targetIds, monitor, registry) {
|
||||
(0, _invariant.invariant)(monitor.isDragging(), 'Cannot call hover while not dragging.');
|
||||
(0, _invariant.invariant)(!monitor.didDrop(), 'Cannot call hover after drop.');
|
||||
|
||||
for (var i = 0; i < targetIds.length; i++) {
|
||||
var targetId = targetIds[i];
|
||||
(0, _invariant.invariant)(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
|
||||
var target = registry.getTarget(targetId);
|
||||
(0, _invariant.invariant)(target, 'Expected targetIds to be registered.');
|
||||
}
|
||||
}
|
||||
|
||||
function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
|
||||
// Remove those targetIds that don't match the targetType. This
|
||||
// fixes shallow isOver which would only be non-shallow because of
|
||||
// non-matching targets.
|
||||
for (var i = targetIds.length - 1; i >= 0; i--) {
|
||||
var targetId = targetIds[i];
|
||||
var targetType = registry.getTargetType(targetId);
|
||||
|
||||
if (!(0, _matchesType.matchesType)(targetType, draggedItemType)) {
|
||||
targetIds.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hoverAllTargets(targetIds, monitor, registry) {
|
||||
// Finally call hover on all matching targets.
|
||||
targetIds.forEach(function (targetId) {
|
||||
var target = registry.getTarget(targetId);
|
||||
target.hover(monitor, targetId);
|
||||
});
|
||||
}
|
||||
43
node_modules/dnd-core/dist/cjs/actions/dragDrop/index.js
generated
vendored
Normal file
43
node_modules/dnd-core/dist/cjs/actions/dragDrop/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _exportNames = {
|
||||
createDragDropActions: true
|
||||
};
|
||||
exports.createDragDropActions = createDragDropActions;
|
||||
|
||||
var _beginDrag = require("./beginDrag");
|
||||
|
||||
var _publishDragSource = require("./publishDragSource");
|
||||
|
||||
var _hover = require("./hover");
|
||||
|
||||
var _drop = require("./drop");
|
||||
|
||||
var _endDrag = require("./endDrag");
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
Object.keys(_types).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
||||
if (key in exports && exports[key] === _types[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _types[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function createDragDropActions(manager) {
|
||||
return {
|
||||
beginDrag: (0, _beginDrag.createBeginDrag)(manager),
|
||||
publishDragSource: (0, _publishDragSource.createPublishDragSource)(manager),
|
||||
hover: (0, _hover.createHover)(manager),
|
||||
drop: (0, _drop.createDrop)(manager),
|
||||
endDrag: (0, _endDrag.createEndDrag)(manager)
|
||||
};
|
||||
}
|
||||
18
node_modules/dnd-core/dist/cjs/actions/dragDrop/local/setClientOffset.js
generated
vendored
Normal file
18
node_modules/dnd-core/dist/cjs/actions/dragDrop/local/setClientOffset.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.setClientOffset = setClientOffset;
|
||||
|
||||
var _types = require("../types");
|
||||
|
||||
function setClientOffset(clientOffset, sourceClientOffset) {
|
||||
return {
|
||||
type: _types.INIT_COORDS,
|
||||
payload: {
|
||||
sourceClientOffset: sourceClientOffset || null,
|
||||
clientOffset: clientOffset || null
|
||||
}
|
||||
};
|
||||
}
|
||||
20
node_modules/dnd-core/dist/cjs/actions/dragDrop/publishDragSource.js
generated
vendored
Normal file
20
node_modules/dnd-core/dist/cjs/actions/dragDrop/publishDragSource.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createPublishDragSource = createPublishDragSource;
|
||||
|
||||
var _types = require("./types");
|
||||
|
||||
function createPublishDragSource(manager) {
|
||||
return function publishDragSource() {
|
||||
var monitor = manager.getMonitor();
|
||||
|
||||
if (monitor.isDragging()) {
|
||||
return {
|
||||
type: _types.PUBLISH_DRAG_SOURCE
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
18
node_modules/dnd-core/dist/cjs/actions/dragDrop/types.js
generated
vendored
Normal file
18
node_modules/dnd-core/dist/cjs/actions/dragDrop/types.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.END_DRAG = exports.DROP = exports.HOVER = exports.PUBLISH_DRAG_SOURCE = exports.BEGIN_DRAG = exports.INIT_COORDS = void 0;
|
||||
var INIT_COORDS = 'dnd-core/INIT_COORDS';
|
||||
exports.INIT_COORDS = INIT_COORDS;
|
||||
var BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
|
||||
exports.BEGIN_DRAG = BEGIN_DRAG;
|
||||
var PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
|
||||
exports.PUBLISH_DRAG_SOURCE = PUBLISH_DRAG_SOURCE;
|
||||
var HOVER = 'dnd-core/HOVER';
|
||||
exports.HOVER = HOVER;
|
||||
var DROP = 'dnd-core/DROP';
|
||||
exports.DROP = DROP;
|
||||
var END_DRAG = 'dnd-core/END_DRAG';
|
||||
exports.END_DRAG = END_DRAG;
|
||||
54
node_modules/dnd-core/dist/cjs/actions/registry.js
generated
vendored
Normal file
54
node_modules/dnd-core/dist/cjs/actions/registry.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.addSource = addSource;
|
||||
exports.addTarget = addTarget;
|
||||
exports.removeSource = removeSource;
|
||||
exports.removeTarget = removeTarget;
|
||||
exports.REMOVE_TARGET = exports.REMOVE_SOURCE = exports.ADD_TARGET = exports.ADD_SOURCE = void 0;
|
||||
var ADD_SOURCE = 'dnd-core/ADD_SOURCE';
|
||||
exports.ADD_SOURCE = ADD_SOURCE;
|
||||
var ADD_TARGET = 'dnd-core/ADD_TARGET';
|
||||
exports.ADD_TARGET = ADD_TARGET;
|
||||
var REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE';
|
||||
exports.REMOVE_SOURCE = REMOVE_SOURCE;
|
||||
var REMOVE_TARGET = 'dnd-core/REMOVE_TARGET';
|
||||
exports.REMOVE_TARGET = REMOVE_TARGET;
|
||||
|
||||
function addSource(sourceId) {
|
||||
return {
|
||||
type: ADD_SOURCE,
|
||||
payload: {
|
||||
sourceId: sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function addTarget(targetId) {
|
||||
return {
|
||||
type: ADD_TARGET,
|
||||
payload: {
|
||||
targetId: targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function removeSource(sourceId) {
|
||||
return {
|
||||
type: REMOVE_SOURCE,
|
||||
payload: {
|
||||
sourceId: sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function removeTarget(targetId) {
|
||||
return {
|
||||
type: REMOVE_TARGET,
|
||||
payload: {
|
||||
targetId: targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
111
node_modules/dnd-core/dist/cjs/classes/DragDropManagerImpl.js
generated
vendored
Normal file
111
node_modules/dnd-core/dist/cjs/classes/DragDropManagerImpl.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DragDropManagerImpl = void 0;
|
||||
|
||||
var _dragDrop = require("../actions/dragDrop");
|
||||
|
||||
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; }
|
||||
|
||||
var DragDropManagerImpl = /*#__PURE__*/function () {
|
||||
function DragDropManagerImpl(store, monitor) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, DragDropManagerImpl);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
_defineProperty(this, "monitor", void 0);
|
||||
|
||||
_defineProperty(this, "backend", void 0);
|
||||
|
||||
_defineProperty(this, "isSetUp", false);
|
||||
|
||||
_defineProperty(this, "handleRefCountChange", function () {
|
||||
var shouldSetUp = _this.store.getState().refCount > 0;
|
||||
|
||||
if (_this.backend) {
|
||||
if (shouldSetUp && !_this.isSetUp) {
|
||||
_this.backend.setup();
|
||||
|
||||
_this.isSetUp = true;
|
||||
} else if (!shouldSetUp && _this.isSetUp) {
|
||||
_this.backend.teardown();
|
||||
|
||||
_this.isSetUp = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.store = store;
|
||||
this.monitor = monitor;
|
||||
store.subscribe(this.handleRefCountChange);
|
||||
}
|
||||
|
||||
_createClass(DragDropManagerImpl, [{
|
||||
key: "receiveBackend",
|
||||
value: function receiveBackend(backend) {
|
||||
this.backend = backend;
|
||||
}
|
||||
}, {
|
||||
key: "getMonitor",
|
||||
value: function getMonitor() {
|
||||
return this.monitor;
|
||||
}
|
||||
}, {
|
||||
key: "getBackend",
|
||||
value: function getBackend() {
|
||||
return this.backend;
|
||||
}
|
||||
}, {
|
||||
key: "getRegistry",
|
||||
value: function getRegistry() {
|
||||
return this.monitor.registry;
|
||||
}
|
||||
}, {
|
||||
key: "getActions",
|
||||
value: function getActions() {
|
||||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
||||
var manager = this;
|
||||
var dispatch = this.store.dispatch;
|
||||
|
||||
function bindActionCreator(actionCreator) {
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var action = actionCreator.apply(manager, args);
|
||||
|
||||
if (typeof action !== 'undefined') {
|
||||
dispatch(action);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var actions = (0, _dragDrop.createDragDropActions)(this);
|
||||
return Object.keys(actions).reduce(function (boundActions, key) {
|
||||
var action = actions[key];
|
||||
boundActions[key] = bindActionCreator(action);
|
||||
return boundActions;
|
||||
}, {});
|
||||
}
|
||||
}, {
|
||||
key: "dispatch",
|
||||
value: function dispatch(action) {
|
||||
this.store.dispatch(action);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DragDropManagerImpl;
|
||||
}();
|
||||
|
||||
exports.DragDropManagerImpl = DragDropManagerImpl;
|
||||
256
node_modules/dnd-core/dist/cjs/classes/DragDropMonitorImpl.js
generated
vendored
Normal file
256
node_modules/dnd-core/dist/cjs/classes/DragDropMonitorImpl.js
generated
vendored
Normal file
@@ -0,0 +1,256 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.DragDropMonitorImpl = void 0;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _matchesType = require("../utils/matchesType");
|
||||
|
||||
var _coords = require("../utils/coords");
|
||||
|
||||
var _dirtiness = require("../utils/dirtiness");
|
||||
|
||||
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; }
|
||||
|
||||
var DragDropMonitorImpl = /*#__PURE__*/function () {
|
||||
function DragDropMonitorImpl(store, registry) {
|
||||
_classCallCheck(this, DragDropMonitorImpl);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
_defineProperty(this, "registry", void 0);
|
||||
|
||||
this.store = store;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
_createClass(DragDropMonitorImpl, [{
|
||||
key: "subscribeToStateChange",
|
||||
value: function subscribeToStateChange(listener) {
|
||||
var _this = this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
handlerIds: undefined
|
||||
};
|
||||
var handlerIds = options.handlerIds;
|
||||
(0, _invariant.invariant)(typeof listener === 'function', 'listener must be a function.');
|
||||
(0, _invariant.invariant)(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
|
||||
var prevStateId = this.store.getState().stateId;
|
||||
|
||||
var handleChange = function handleChange() {
|
||||
var state = _this.store.getState();
|
||||
|
||||
var currentStateId = state.stateId;
|
||||
|
||||
try {
|
||||
var canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !(0, _dirtiness.areDirty)(state.dirtyHandlerIds, handlerIds);
|
||||
|
||||
if (!canSkipListener) {
|
||||
listener();
|
||||
}
|
||||
} finally {
|
||||
prevStateId = currentStateId;
|
||||
}
|
||||
};
|
||||
|
||||
return this.store.subscribe(handleChange);
|
||||
}
|
||||
}, {
|
||||
key: "subscribeToOffsetChange",
|
||||
value: function subscribeToOffsetChange(listener) {
|
||||
var _this2 = this;
|
||||
|
||||
(0, _invariant.invariant)(typeof listener === 'function', 'listener must be a function.');
|
||||
var previousState = this.store.getState().dragOffset;
|
||||
|
||||
var handleChange = function handleChange() {
|
||||
var nextState = _this2.store.getState().dragOffset;
|
||||
|
||||
if (nextState === previousState) {
|
||||
return;
|
||||
}
|
||||
|
||||
previousState = nextState;
|
||||
listener();
|
||||
};
|
||||
|
||||
return this.store.subscribe(handleChange);
|
||||
}
|
||||
}, {
|
||||
key: "canDragSource",
|
||||
value: function canDragSource(sourceId) {
|
||||
if (!sourceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var source = this.registry.getSource(sourceId);
|
||||
(0, _invariant.invariant)(source, "Expected to find a valid source. sourceId=".concat(sourceId));
|
||||
|
||||
if (this.isDragging()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return source.canDrag(this, sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "canDropOnTarget",
|
||||
value: function canDropOnTarget(targetId) {
|
||||
// undefined on initial render
|
||||
if (!targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = this.registry.getTarget(targetId);
|
||||
(0, _invariant.invariant)(target, "Expected to find a valid target. targetId=".concat(targetId));
|
||||
|
||||
if (!this.isDragging() || this.didDrop()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetType = this.registry.getTargetType(targetId);
|
||||
var draggedItemType = this.getItemType();
|
||||
return (0, _matchesType.matchesType)(targetType, draggedItemType) && target.canDrop(this, targetId);
|
||||
}
|
||||
}, {
|
||||
key: "isDragging",
|
||||
value: function isDragging() {
|
||||
return Boolean(this.getItemType());
|
||||
}
|
||||
}, {
|
||||
key: "isDraggingSource",
|
||||
value: function isDraggingSource(sourceId) {
|
||||
// undefined on initial render
|
||||
if (!sourceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var source = this.registry.getSource(sourceId, true);
|
||||
(0, _invariant.invariant)(source, "Expected to find a valid source. sourceId=".concat(sourceId));
|
||||
|
||||
if (!this.isDragging() || !this.isSourcePublic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var sourceType = this.registry.getSourceType(sourceId);
|
||||
var draggedItemType = this.getItemType();
|
||||
|
||||
if (sourceType !== draggedItemType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return source.isDragging(this, sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "isOverTarget",
|
||||
value: function isOverTarget(targetId) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
shallow: false
|
||||
};
|
||||
|
||||
// undefined on initial render
|
||||
if (!targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var shallow = options.shallow;
|
||||
|
||||
if (!this.isDragging()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetType = this.registry.getTargetType(targetId);
|
||||
var draggedItemType = this.getItemType();
|
||||
|
||||
if (draggedItemType && !(0, _matchesType.matchesType)(targetType, draggedItemType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetIds = this.getTargetIds();
|
||||
|
||||
if (!targetIds.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var index = targetIds.indexOf(targetId);
|
||||
|
||||
if (shallow) {
|
||||
return index === targetIds.length - 1;
|
||||
} else {
|
||||
return index > -1;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getItemType",
|
||||
value: function getItemType() {
|
||||
return this.store.getState().dragOperation.itemType;
|
||||
}
|
||||
}, {
|
||||
key: "getItem",
|
||||
value: function getItem() {
|
||||
return this.store.getState().dragOperation.item;
|
||||
}
|
||||
}, {
|
||||
key: "getSourceId",
|
||||
value: function getSourceId() {
|
||||
return this.store.getState().dragOperation.sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "getTargetIds",
|
||||
value: function getTargetIds() {
|
||||
return this.store.getState().dragOperation.targetIds;
|
||||
}
|
||||
}, {
|
||||
key: "getDropResult",
|
||||
value: function getDropResult() {
|
||||
return this.store.getState().dragOperation.dropResult;
|
||||
}
|
||||
}, {
|
||||
key: "didDrop",
|
||||
value: function didDrop() {
|
||||
return this.store.getState().dragOperation.didDrop;
|
||||
}
|
||||
}, {
|
||||
key: "isSourcePublic",
|
||||
value: function isSourcePublic() {
|
||||
return Boolean(this.store.getState().dragOperation.isSourcePublic);
|
||||
}
|
||||
}, {
|
||||
key: "getInitialClientOffset",
|
||||
value: function getInitialClientOffset() {
|
||||
return this.store.getState().dragOffset.initialClientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getInitialSourceClientOffset",
|
||||
value: function getInitialSourceClientOffset() {
|
||||
return this.store.getState().dragOffset.initialSourceClientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getClientOffset",
|
||||
value: function getClientOffset() {
|
||||
return this.store.getState().dragOffset.clientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getSourceClientOffset",
|
||||
value: function getSourceClientOffset() {
|
||||
return (0, _coords.getSourceClientOffset)(this.store.getState().dragOffset);
|
||||
}
|
||||
}, {
|
||||
key: "getDifferenceFromInitialOffset",
|
||||
value: function getDifferenceFromInitialOffset() {
|
||||
return (0, _coords.getDifferenceFromInitialOffset)(this.store.getState().dragOffset);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DragDropMonitorImpl;
|
||||
}();
|
||||
|
||||
exports.DragDropMonitorImpl = DragDropMonitorImpl;
|
||||
224
node_modules/dnd-core/dist/cjs/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
224
node_modules/dnd-core/dist/cjs/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.HandlerRegistryImpl = void 0;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
var _registry = require("../actions/registry");
|
||||
|
||||
var _getNextUniqueId = require("../utils/getNextUniqueId");
|
||||
|
||||
var _interfaces = require("../interfaces");
|
||||
|
||||
var _contracts = require("../contracts");
|
||||
|
||||
var _asap = require("@react-dnd/asap");
|
||||
|
||||
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; }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
function getNextHandlerId(role) {
|
||||
var id = (0, _getNextUniqueId.getNextUniqueId)().toString();
|
||||
|
||||
switch (role) {
|
||||
case _interfaces.HandlerRole.SOURCE:
|
||||
return "S".concat(id);
|
||||
|
||||
case _interfaces.HandlerRole.TARGET:
|
||||
return "T".concat(id);
|
||||
|
||||
default:
|
||||
throw new Error("Unknown Handler Role: ".concat(role));
|
||||
}
|
||||
}
|
||||
|
||||
function parseRoleFromHandlerId(handlerId) {
|
||||
switch (handlerId[0]) {
|
||||
case 'S':
|
||||
return _interfaces.HandlerRole.SOURCE;
|
||||
|
||||
case 'T':
|
||||
return _interfaces.HandlerRole.TARGET;
|
||||
|
||||
default:
|
||||
(0, _invariant.invariant)(false, "Cannot parse handler ID: ".concat(handlerId));
|
||||
}
|
||||
}
|
||||
|
||||
function mapContainsValue(map, searchValue) {
|
||||
var entries = map.entries();
|
||||
var isDone = false;
|
||||
|
||||
do {
|
||||
var _entries$next = entries.next(),
|
||||
done = _entries$next.done,
|
||||
_entries$next$value = _slicedToArray(_entries$next.value, 2),
|
||||
value = _entries$next$value[1];
|
||||
|
||||
if (value === searchValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
isDone = !!done;
|
||||
} while (!isDone);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var HandlerRegistryImpl = /*#__PURE__*/function () {
|
||||
function HandlerRegistryImpl(store) {
|
||||
_classCallCheck(this, HandlerRegistryImpl);
|
||||
|
||||
_defineProperty(this, "types", new Map());
|
||||
|
||||
_defineProperty(this, "dragSources", new Map());
|
||||
|
||||
_defineProperty(this, "dropTargets", new Map());
|
||||
|
||||
_defineProperty(this, "pinnedSourceId", null);
|
||||
|
||||
_defineProperty(this, "pinnedSource", null);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
_createClass(HandlerRegistryImpl, [{
|
||||
key: "addSource",
|
||||
value: function addSource(type, source) {
|
||||
(0, _contracts.validateType)(type);
|
||||
(0, _contracts.validateSourceContract)(source);
|
||||
var sourceId = this.addHandler(_interfaces.HandlerRole.SOURCE, type, source);
|
||||
this.store.dispatch((0, _registry.addSource)(sourceId));
|
||||
return sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "addTarget",
|
||||
value: function addTarget(type, target) {
|
||||
(0, _contracts.validateType)(type, true);
|
||||
(0, _contracts.validateTargetContract)(target);
|
||||
var targetId = this.addHandler(_interfaces.HandlerRole.TARGET, type, target);
|
||||
this.store.dispatch((0, _registry.addTarget)(targetId));
|
||||
return targetId;
|
||||
}
|
||||
}, {
|
||||
key: "containsHandler",
|
||||
value: function containsHandler(handler) {
|
||||
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
|
||||
}
|
||||
}, {
|
||||
key: "getSource",
|
||||
value: function getSource(sourceId) {
|
||||
var includePinned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
(0, _invariant.invariant)(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
var isPinned = includePinned && sourceId === this.pinnedSourceId;
|
||||
var source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);
|
||||
return source;
|
||||
}
|
||||
}, {
|
||||
key: "getTarget",
|
||||
value: function getTarget(targetId) {
|
||||
(0, _invariant.invariant)(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.dropTargets.get(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "getSourceType",
|
||||
value: function getSourceType(sourceId) {
|
||||
(0, _invariant.invariant)(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
return this.types.get(sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "getTargetType",
|
||||
value: function getTargetType(targetId) {
|
||||
(0, _invariant.invariant)(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.types.get(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "isSourceId",
|
||||
value: function isSourceId(handlerId) {
|
||||
var role = parseRoleFromHandlerId(handlerId);
|
||||
return role === _interfaces.HandlerRole.SOURCE;
|
||||
}
|
||||
}, {
|
||||
key: "isTargetId",
|
||||
value: function isTargetId(handlerId) {
|
||||
var role = parseRoleFromHandlerId(handlerId);
|
||||
return role === _interfaces.HandlerRole.TARGET;
|
||||
}
|
||||
}, {
|
||||
key: "removeSource",
|
||||
value: function removeSource(sourceId) {
|
||||
var _this = this;
|
||||
|
||||
(0, _invariant.invariant)(this.getSource(sourceId), 'Expected an existing source.');
|
||||
this.store.dispatch((0, _registry.removeSource)(sourceId));
|
||||
(0, _asap.asap)(function () {
|
||||
_this.dragSources.delete(sourceId);
|
||||
|
||||
_this.types.delete(sourceId);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "removeTarget",
|
||||
value: function removeTarget(targetId) {
|
||||
(0, _invariant.invariant)(this.getTarget(targetId), 'Expected an existing target.');
|
||||
this.store.dispatch((0, _registry.removeTarget)(targetId));
|
||||
this.dropTargets.delete(targetId);
|
||||
this.types.delete(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "pinSource",
|
||||
value: function pinSource(sourceId) {
|
||||
var source = this.getSource(sourceId);
|
||||
(0, _invariant.invariant)(source, 'Expected an existing source.');
|
||||
this.pinnedSourceId = sourceId;
|
||||
this.pinnedSource = source;
|
||||
}
|
||||
}, {
|
||||
key: "unpinSource",
|
||||
value: function unpinSource() {
|
||||
(0, _invariant.invariant)(this.pinnedSource, 'No source is pinned at the time.');
|
||||
this.pinnedSourceId = null;
|
||||
this.pinnedSource = null;
|
||||
}
|
||||
}, {
|
||||
key: "addHandler",
|
||||
value: function addHandler(role, type, handler) {
|
||||
var id = getNextHandlerId(role);
|
||||
this.types.set(id, type);
|
||||
|
||||
if (role === _interfaces.HandlerRole.SOURCE) {
|
||||
this.dragSources.set(id, handler);
|
||||
} else if (role === _interfaces.HandlerRole.TARGET) {
|
||||
this.dropTargets.set(id, handler);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}]);
|
||||
|
||||
return HandlerRegistryImpl;
|
||||
}();
|
||||
|
||||
exports.HandlerRegistryImpl = HandlerRegistryImpl;
|
||||
35
node_modules/dnd-core/dist/cjs/contracts.js
generated
vendored
Normal file
35
node_modules/dnd-core/dist/cjs/contracts.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.validateSourceContract = validateSourceContract;
|
||||
exports.validateTargetContract = validateTargetContract;
|
||||
exports.validateType = validateType;
|
||||
|
||||
var _invariant = require("@react-dnd/invariant");
|
||||
|
||||
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); }
|
||||
|
||||
function validateSourceContract(source) {
|
||||
(0, _invariant.invariant)(typeof source.canDrag === 'function', 'Expected canDrag to be a function.');
|
||||
(0, _invariant.invariant)(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.');
|
||||
(0, _invariant.invariant)(typeof source.endDrag === 'function', 'Expected endDrag to be a function.');
|
||||
}
|
||||
|
||||
function validateTargetContract(target) {
|
||||
(0, _invariant.invariant)(typeof target.canDrop === 'function', 'Expected canDrop to be a function.');
|
||||
(0, _invariant.invariant)(typeof target.hover === 'function', 'Expected hover to be a function.');
|
||||
(0, _invariant.invariant)(typeof target.drop === 'function', 'Expected beginDrag to be a function.');
|
||||
}
|
||||
|
||||
function validateType(type, allowArray) {
|
||||
if (allowArray && Array.isArray(type)) {
|
||||
type.forEach(function (t) {
|
||||
return validateType(t, false);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _invariant.invariant)(typeof type === 'string' || _typeof(type) === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.');
|
||||
}
|
||||
38
node_modules/dnd-core/dist/cjs/createDragDropManager.js
generated
vendored
Normal file
38
node_modules/dnd-core/dist/cjs/createDragDropManager.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createDragDropManager = createDragDropManager;
|
||||
|
||||
var _DragDropManagerImpl = require("./classes/DragDropManagerImpl");
|
||||
|
||||
var _redux = require("redux");
|
||||
|
||||
var _reducers = require("./reducers");
|
||||
|
||||
var _DragDropMonitorImpl = require("./classes/DragDropMonitorImpl");
|
||||
|
||||
var _HandlerRegistryImpl = require("./classes/HandlerRegistryImpl");
|
||||
|
||||
function createDragDropManager(backendFactory) {
|
||||
var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
||||
var backendOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var debugMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
var store = makeStoreInstance(debugMode);
|
||||
var monitor = new _DragDropMonitorImpl.DragDropMonitorImpl(store, new _HandlerRegistryImpl.HandlerRegistryImpl(store));
|
||||
var manager = new _DragDropManagerImpl.DragDropManagerImpl(store, monitor);
|
||||
var backend = backendFactory(manager, globalContext, backendOptions);
|
||||
manager.receiveBackend(backend);
|
||||
return manager;
|
||||
}
|
||||
|
||||
function makeStoreInstance(debugMode) {
|
||||
// TODO: if we ever make a react-native version of this,
|
||||
// we'll need to consider how to pull off dev-tooling
|
||||
var reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__;
|
||||
return (0, _redux.createStore)(_reducers.reduce, debugMode && reduxDevTools && reduxDevTools({
|
||||
name: 'dnd-core',
|
||||
instanceId: 'dnd-core'
|
||||
}));
|
||||
}
|
||||
31
node_modules/dnd-core/dist/cjs/index.js
generated
vendored
Normal file
31
node_modules/dnd-core/dist/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _interfaces = require("./interfaces");
|
||||
|
||||
Object.keys(_interfaces).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _interfaces[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interfaces[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _createDragDropManager = require("./createDragDropManager");
|
||||
|
||||
Object.keys(_createDragDropManager).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _createDragDropManager[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _createDragDropManager[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
13
node_modules/dnd-core/dist/cjs/interfaces.js
generated
vendored
Normal file
13
node_modules/dnd-core/dist/cjs/interfaces.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.HandlerRole = void 0;
|
||||
var HandlerRole;
|
||||
exports.HandlerRole = HandlerRole;
|
||||
|
||||
(function (HandlerRole) {
|
||||
HandlerRole["SOURCE"] = "SOURCE";
|
||||
HandlerRole["TARGET"] = "TARGET";
|
||||
})(HandlerRole || (exports.HandlerRole = HandlerRole = {}));
|
||||
69
node_modules/dnd-core/dist/cjs/reducers/dirtyHandlerIds.js
generated
vendored
Normal file
69
node_modules/dnd-core/dist/cjs/reducers/dirtyHandlerIds.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
var _dragDrop = require("../actions/dragDrop");
|
||||
|
||||
var _registry = require("../actions/registry");
|
||||
|
||||
var _equality = require("../utils/equality");
|
||||
|
||||
var _dirtiness = require("../utils/dirtiness");
|
||||
|
||||
var _js_utils = require("../utils/js_utils");
|
||||
|
||||
function reduce() {
|
||||
var _state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _dirtiness.NONE;
|
||||
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
switch (action.type) {
|
||||
case _dragDrop.HOVER:
|
||||
break;
|
||||
|
||||
case _registry.ADD_SOURCE:
|
||||
case _registry.ADD_TARGET:
|
||||
case _registry.REMOVE_TARGET:
|
||||
case _registry.REMOVE_SOURCE:
|
||||
return _dirtiness.NONE;
|
||||
|
||||
case _dragDrop.BEGIN_DRAG:
|
||||
case _dragDrop.PUBLISH_DRAG_SOURCE:
|
||||
case _dragDrop.END_DRAG:
|
||||
case _dragDrop.DROP:
|
||||
default:
|
||||
return _dirtiness.ALL;
|
||||
}
|
||||
|
||||
var _action$payload = action.payload,
|
||||
_action$payload$targe = _action$payload.targetIds,
|
||||
targetIds = _action$payload$targe === void 0 ? [] : _action$payload$targe,
|
||||
_action$payload$prevT = _action$payload.prevTargetIds,
|
||||
prevTargetIds = _action$payload$prevT === void 0 ? [] : _action$payload$prevT;
|
||||
var result = (0, _js_utils.xor)(targetIds, prevTargetIds);
|
||||
var didChange = result.length > 0 || !(0, _equality.areArraysEqual)(targetIds, prevTargetIds);
|
||||
|
||||
if (!didChange) {
|
||||
return _dirtiness.NONE;
|
||||
} // Check the target ids at the innermost position. If they are valid, add them
|
||||
// to the result
|
||||
|
||||
|
||||
var prevInnermostTargetId = prevTargetIds[prevTargetIds.length - 1];
|
||||
var innermostTargetId = targetIds[targetIds.length - 1];
|
||||
|
||||
if (prevInnermostTargetId !== innermostTargetId) {
|
||||
if (prevInnermostTargetId) {
|
||||
result.push(prevInnermostTargetId);
|
||||
}
|
||||
|
||||
if (innermostTargetId) {
|
||||
result.push(innermostTargetId);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
54
node_modules/dnd-core/dist/cjs/reducers/dragOffset.js
generated
vendored
Normal file
54
node_modules/dnd-core/dist/cjs/reducers/dragOffset.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
var _dragDrop = require("../actions/dragDrop");
|
||||
|
||||
var _equality = require("../utils/equality");
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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; }
|
||||
|
||||
var initialState = {
|
||||
initialSourceClientOffset: null,
|
||||
initialClientOffset: null,
|
||||
clientOffset: null
|
||||
};
|
||||
|
||||
function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
var payload = action.payload;
|
||||
|
||||
switch (action.type) {
|
||||
case _dragDrop.INIT_COORDS:
|
||||
case _dragDrop.BEGIN_DRAG:
|
||||
return {
|
||||
initialSourceClientOffset: payload.sourceClientOffset,
|
||||
initialClientOffset: payload.clientOffset,
|
||||
clientOffset: payload.clientOffset
|
||||
};
|
||||
|
||||
case _dragDrop.HOVER:
|
||||
if ((0, _equality.areCoordsEqual)(state.clientOffset, payload.clientOffset)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
clientOffset: payload.clientOffset
|
||||
});
|
||||
|
||||
case _dragDrop.END_DRAG:
|
||||
case _dragDrop.DROP:
|
||||
return initialState;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
86
node_modules/dnd-core/dist/cjs/reducers/dragOperation.js
generated
vendored
Normal file
86
node_modules/dnd-core/dist/cjs/reducers/dragOperation.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
var _dragDrop = require("../actions/dragDrop");
|
||||
|
||||
var _registry = require("../actions/registry");
|
||||
|
||||
var _js_utils = require("../utils/js_utils");
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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; }
|
||||
|
||||
var initialState = {
|
||||
itemType: null,
|
||||
item: null,
|
||||
sourceId: null,
|
||||
targetIds: [],
|
||||
dropResult: null,
|
||||
didDrop: false,
|
||||
isSourcePublic: null
|
||||
};
|
||||
|
||||
function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
var payload = action.payload;
|
||||
|
||||
switch (action.type) {
|
||||
case _dragDrop.BEGIN_DRAG:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
itemType: payload.itemType,
|
||||
item: payload.item,
|
||||
sourceId: payload.sourceId,
|
||||
isSourcePublic: payload.isSourcePublic,
|
||||
dropResult: null,
|
||||
didDrop: false
|
||||
});
|
||||
|
||||
case _dragDrop.PUBLISH_DRAG_SOURCE:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
isSourcePublic: true
|
||||
});
|
||||
|
||||
case _dragDrop.HOVER:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
targetIds: payload.targetIds
|
||||
});
|
||||
|
||||
case _registry.REMOVE_TARGET:
|
||||
if (state.targetIds.indexOf(payload.targetId) === -1) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
targetIds: (0, _js_utils.without)(state.targetIds, payload.targetId)
|
||||
});
|
||||
|
||||
case _dragDrop.DROP:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
dropResult: payload.dropResult,
|
||||
didDrop: true,
|
||||
targetIds: []
|
||||
});
|
||||
|
||||
case _dragDrop.END_DRAG:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
itemType: null,
|
||||
item: null,
|
||||
sourceId: null,
|
||||
dropResult: null,
|
||||
didDrop: false,
|
||||
isSourcePublic: null,
|
||||
targetIds: []
|
||||
});
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
41
node_modules/dnd-core/dist/cjs/reducers/index.js
generated
vendored
Normal file
41
node_modules/dnd-core/dist/cjs/reducers/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
var _dragOffset = require("./dragOffset");
|
||||
|
||||
var _dragOperation = require("./dragOperation");
|
||||
|
||||
var _refCount = require("./refCount");
|
||||
|
||||
var _dirtyHandlerIds = require("./dirtyHandlerIds");
|
||||
|
||||
var _stateId = require("./stateId");
|
||||
|
||||
var _js_utils = require("../utils/js_utils");
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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; }
|
||||
|
||||
function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
return {
|
||||
dirtyHandlerIds: (0, _dirtyHandlerIds.reduce)(state.dirtyHandlerIds, {
|
||||
type: action.type,
|
||||
payload: _objectSpread(_objectSpread({}, action.payload), {}, {
|
||||
prevTargetIds: (0, _js_utils.get)(state, 'dragOperation.targetIds', [])
|
||||
})
|
||||
}),
|
||||
dragOffset: (0, _dragOffset.reduce)(state.dragOffset, action),
|
||||
refCount: (0, _refCount.reduce)(state.refCount, action),
|
||||
dragOperation: (0, _dragOperation.reduce)(state.dragOperation, action),
|
||||
stateId: (0, _stateId.reduce)(state.stateId)
|
||||
};
|
||||
}
|
||||
26
node_modules/dnd-core/dist/cjs/reducers/refCount.js
generated
vendored
Normal file
26
node_modules/dnd-core/dist/cjs/reducers/refCount.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
var _registry = require("../actions/registry");
|
||||
|
||||
function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
switch (action.type) {
|
||||
case _registry.ADD_SOURCE:
|
||||
case _registry.ADD_TARGET:
|
||||
return state + 1;
|
||||
|
||||
case _registry.REMOVE_SOURCE:
|
||||
case _registry.REMOVE_TARGET:
|
||||
return state - 1;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
11
node_modules/dnd-core/dist/cjs/reducers/stateId.js
generated
vendored
Normal file
11
node_modules/dnd-core/dist/cjs/reducers/stateId.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.reduce = reduce;
|
||||
|
||||
function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
||||
return state + 1;
|
||||
}
|
||||
72
node_modules/dnd-core/dist/cjs/utils/coords.js
generated
vendored
Normal file
72
node_modules/dnd-core/dist/cjs/utils/coords.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.add = add;
|
||||
exports.subtract = subtract;
|
||||
exports.getSourceClientOffset = getSourceClientOffset;
|
||||
exports.getDifferenceFromInitialOffset = getDifferenceFromInitialOffset;
|
||||
|
||||
/**
|
||||
* Coordinate addition
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
function add(a, b) {
|
||||
return {
|
||||
x: a.x + b.x,
|
||||
y: a.y + b.y
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Coordinate subtraction
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
|
||||
|
||||
function subtract(a, b) {
|
||||
return {
|
||||
x: a.x - b.x,
|
||||
y: a.y - b.y
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the cartesian distance of the drag source component's position, based on its position
|
||||
* at the time when the current drag operation has started, and the movement difference.
|
||||
*
|
||||
* Returns null if no item is being dragged.
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
|
||||
|
||||
function getSourceClientOffset(state) {
|
||||
var clientOffset = state.clientOffset,
|
||||
initialClientOffset = state.initialClientOffset,
|
||||
initialSourceClientOffset = state.initialSourceClientOffset;
|
||||
|
||||
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
|
||||
}
|
||||
/**
|
||||
* Determines the x,y offset between the client offset and the initial client offset
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
|
||||
|
||||
function getDifferenceFromInitialOffset(state) {
|
||||
var clientOffset = state.clientOffset,
|
||||
initialClientOffset = state.initialClientOffset;
|
||||
|
||||
if (!clientOffset || !initialClientOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return subtract(clientOffset, initialClientOffset);
|
||||
}
|
||||
35
node_modules/dnd-core/dist/cjs/utils/dirtiness.js
generated
vendored
Normal file
35
node_modules/dnd-core/dist/cjs/utils/dirtiness.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.areDirty = areDirty;
|
||||
exports.ALL = exports.NONE = void 0;
|
||||
|
||||
var _js_utils = require("./js_utils");
|
||||
|
||||
var NONE = [];
|
||||
exports.NONE = NONE;
|
||||
var ALL = [];
|
||||
exports.ALL = ALL;
|
||||
NONE.__IS_NONE__ = true;
|
||||
ALL.__IS_ALL__ = true;
|
||||
/**
|
||||
* Determines if the given handler IDs are dirty or not.
|
||||
*
|
||||
* @param dirtyIds The set of dirty handler ids
|
||||
* @param handlerIds The set of handler ids to check
|
||||
*/
|
||||
|
||||
function areDirty(dirtyIds, handlerIds) {
|
||||
if (dirtyIds === NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var commonIds = (0, _js_utils.intersection)(handlerIds, dirtyIds);
|
||||
return commonIds.length > 0;
|
||||
}
|
||||
52
node_modules/dnd-core/dist/cjs/utils/equality.js
generated
vendored
Normal file
52
node_modules/dnd-core/dist/cjs/utils/equality.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.areCoordsEqual = areCoordsEqual;
|
||||
exports.areArraysEqual = areArraysEqual;
|
||||
exports.strictEquality = void 0;
|
||||
|
||||
var strictEquality = function strictEquality(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
/**
|
||||
* Determine if two cartesian coordinate offsets are equal
|
||||
* @param offsetA
|
||||
* @param offsetB
|
||||
*/
|
||||
|
||||
|
||||
exports.strictEquality = strictEquality;
|
||||
|
||||
function areCoordsEqual(offsetA, offsetB) {
|
||||
if (!offsetA && !offsetB) {
|
||||
return true;
|
||||
} else if (!offsetA || !offsetB) {
|
||||
return false;
|
||||
} else {
|
||||
return offsetA.x === offsetB.x && offsetA.y === offsetB.y;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determines if two arrays of items are equal
|
||||
* @param a The first array of items
|
||||
* @param b The second array of items
|
||||
*/
|
||||
|
||||
|
||||
function areArraysEqual(a, b) {
|
||||
var isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : strictEquality;
|
||||
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (!isEqual(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
11
node_modules/dnd-core/dist/cjs/utils/getNextUniqueId.js
generated
vendored
Normal file
11
node_modules/dnd-core/dist/cjs/utils/getNextUniqueId.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getNextUniqueId = getNextUniqueId;
|
||||
var nextUniqueId = 0;
|
||||
|
||||
function getNextUniqueId() {
|
||||
return nextUniqueId++;
|
||||
}
|
||||
91
node_modules/dnd-core/dist/cjs/utils/js_utils.js
generated
vendored
Normal file
91
node_modules/dnd-core/dist/cjs/utils/js_utils.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.get = get;
|
||||
exports.without = without;
|
||||
exports.isString = isString;
|
||||
exports.isObject = isObject;
|
||||
exports.xor = xor;
|
||||
exports.intersection = intersection;
|
||||
|
||||
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); }
|
||||
|
||||
// cheap lodash replacements
|
||||
|
||||
/**
|
||||
* drop-in replacement for _.get
|
||||
* @param obj
|
||||
* @param path
|
||||
* @param defaultValue
|
||||
*/
|
||||
function get(obj, path, defaultValue) {
|
||||
return path.split('.').reduce(function (a, c) {
|
||||
return a && a[c] ? a[c] : defaultValue || null;
|
||||
}, obj);
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.without
|
||||
*/
|
||||
|
||||
|
||||
function without(items, item) {
|
||||
return items.filter(function (i) {
|
||||
return i !== item;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
|
||||
|
||||
function isString(input) {
|
||||
return typeof input === 'string';
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
|
||||
|
||||
function isObject(input) {
|
||||
return _typeof(input) === 'object';
|
||||
}
|
||||
/**
|
||||
* repalcement for _.xor
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
|
||||
|
||||
function xor(itemsA, itemsB) {
|
||||
var map = new Map();
|
||||
|
||||
var insertItem = function insertItem(item) {
|
||||
map.set(item, map.has(item) ? map.get(item) + 1 : 1);
|
||||
};
|
||||
|
||||
itemsA.forEach(insertItem);
|
||||
itemsB.forEach(insertItem);
|
||||
var result = [];
|
||||
map.forEach(function (count, key) {
|
||||
if (count === 1) {
|
||||
result.push(key);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* replacement for _.intersection
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
|
||||
|
||||
function intersection(itemsA, itemsB) {
|
||||
return itemsA.filter(function (t) {
|
||||
return itemsB.indexOf(t) > -1;
|
||||
});
|
||||
}
|
||||
16
node_modules/dnd-core/dist/cjs/utils/matchesType.js
generated
vendored
Normal file
16
node_modules/dnd-core/dist/cjs/utils/matchesType.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.matchesType = matchesType;
|
||||
|
||||
function matchesType(targetType, draggedItemType) {
|
||||
if (draggedItemType === null) {
|
||||
return targetType === null;
|
||||
}
|
||||
|
||||
return Array.isArray(targetType) ? targetType.some(function (t) {
|
||||
return t === draggedItemType;
|
||||
}) : targetType === draggedItemType;
|
||||
}
|
||||
99
node_modules/dnd-core/dist/esm/actions/dragDrop/beginDrag.js
generated
vendored
Normal file
99
node_modules/dnd-core/dist/esm/actions/dragDrop/beginDrag.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { setClientOffset } from './local/setClientOffset';
|
||||
import { isObject } from '../../utils/js_utils';
|
||||
import { BEGIN_DRAG, INIT_COORDS } from './types';
|
||||
var ResetCoordinatesAction = {
|
||||
type: INIT_COORDS,
|
||||
payload: {
|
||||
clientOffset: null,
|
||||
sourceClientOffset: null
|
||||
}
|
||||
};
|
||||
export function createBeginDrag(manager) {
|
||||
return function beginDrag() {
|
||||
var sourceIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
publishSource: true
|
||||
};
|
||||
var _options$publishSourc = options.publishSource,
|
||||
publishSource = _options$publishSourc === void 0 ? true : _options$publishSourc,
|
||||
clientOffset = options.clientOffset,
|
||||
getSourceClientOffset = options.getSourceClientOffset;
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry(); // Initialize the coordinates using the client offset
|
||||
|
||||
manager.dispatch(setClientOffset(clientOffset));
|
||||
verifyInvariants(sourceIds, monitor, registry); // Get the draggable source
|
||||
|
||||
var sourceId = getDraggableSource(sourceIds, monitor);
|
||||
|
||||
if (sourceId === null) {
|
||||
manager.dispatch(ResetCoordinatesAction);
|
||||
return;
|
||||
} // Get the source client offset
|
||||
|
||||
|
||||
var sourceClientOffset = null;
|
||||
|
||||
if (clientOffset) {
|
||||
if (!getSourceClientOffset) {
|
||||
throw new Error('getSourceClientOffset must be defined');
|
||||
}
|
||||
|
||||
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset);
|
||||
sourceClientOffset = getSourceClientOffset(sourceId);
|
||||
} // Initialize the full coordinates
|
||||
|
||||
|
||||
manager.dispatch(setClientOffset(clientOffset, sourceClientOffset));
|
||||
var source = registry.getSource(sourceId);
|
||||
var item = source.beginDrag(monitor, sourceId); // If source.beginDrag returns null, this is an indicator to cancel the drag
|
||||
|
||||
if (item == null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
verifyItemIsObject(item);
|
||||
registry.pinSource(sourceId);
|
||||
var itemType = registry.getSourceType(sourceId);
|
||||
return {
|
||||
type: BEGIN_DRAG,
|
||||
payload: {
|
||||
itemType: itemType,
|
||||
item: item,
|
||||
sourceId: sourceId,
|
||||
clientOffset: clientOffset || null,
|
||||
sourceClientOffset: sourceClientOffset || null,
|
||||
isSourcePublic: !!publishSource
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyInvariants(sourceIds, monitor, registry) {
|
||||
invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.');
|
||||
sourceIds.forEach(function (sourceId) {
|
||||
invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.');
|
||||
});
|
||||
}
|
||||
|
||||
function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) {
|
||||
invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.');
|
||||
}
|
||||
|
||||
function verifyItemIsObject(item) {
|
||||
invariant(isObject(item), 'Item must be an object.');
|
||||
}
|
||||
|
||||
function getDraggableSource(sourceIds, monitor) {
|
||||
var sourceId = null;
|
||||
|
||||
for (var i = sourceIds.length - 1; i >= 0; i--) {
|
||||
if (monitor.canDragSource(sourceIds[i])) {
|
||||
sourceId = sourceIds[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return sourceId;
|
||||
}
|
||||
56
node_modules/dnd-core/dist/esm/actions/dragDrop/drop.js
generated
vendored
Normal file
56
node_modules/dnd-core/dist/esm/actions/dragDrop/drop.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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';
|
||||
import { DROP } from './types';
|
||||
import { isObject } from '../../utils/js_utils';
|
||||
export function createDrop(manager) {
|
||||
return function drop() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
verifyInvariants(monitor);
|
||||
var targetIds = getDroppableTargets(monitor); // Multiple actions are dispatched here, which is why this doesn't return an action
|
||||
|
||||
targetIds.forEach(function (targetId, index) {
|
||||
var dropResult = determineDropResult(targetId, index, registry, monitor);
|
||||
var action = {
|
||||
type: DROP,
|
||||
payload: {
|
||||
dropResult: _objectSpread(_objectSpread({}, options), dropResult)
|
||||
}
|
||||
};
|
||||
manager.dispatch(action);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function verifyInvariants(monitor) {
|
||||
invariant(monitor.isDragging(), 'Cannot call drop while not dragging.');
|
||||
invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.');
|
||||
}
|
||||
|
||||
function determineDropResult(targetId, index, registry, monitor) {
|
||||
var target = registry.getTarget(targetId);
|
||||
var dropResult = target ? target.drop(monitor, targetId) : undefined;
|
||||
verifyDropResultType(dropResult);
|
||||
|
||||
if (typeof dropResult === 'undefined') {
|
||||
dropResult = index === 0 ? {} : monitor.getDropResult();
|
||||
}
|
||||
|
||||
return dropResult;
|
||||
}
|
||||
|
||||
function verifyDropResultType(dropResult) {
|
||||
invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.');
|
||||
}
|
||||
|
||||
function getDroppableTargets(monitor) {
|
||||
var targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor);
|
||||
targetIds.reverse();
|
||||
return targetIds;
|
||||
}
|
||||
24
node_modules/dnd-core/dist/esm/actions/dragDrop/endDrag.js
generated
vendored
Normal file
24
node_modules/dnd-core/dist/esm/actions/dragDrop/endDrag.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { END_DRAG } from './types';
|
||||
export function createEndDrag(manager) {
|
||||
return function endDrag() {
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
verifyIsDragging(monitor);
|
||||
var sourceId = monitor.getSourceId();
|
||||
|
||||
if (sourceId != null) {
|
||||
var source = registry.getSource(sourceId, true);
|
||||
source.endDrag(monitor, sourceId);
|
||||
registry.unpinSource();
|
||||
}
|
||||
|
||||
return {
|
||||
type: END_DRAG
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyIsDragging(monitor) {
|
||||
invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.');
|
||||
}
|
||||
63
node_modules/dnd-core/dist/esm/actions/dragDrop/hover.js
generated
vendored
Normal file
63
node_modules/dnd-core/dist/esm/actions/dragDrop/hover.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { matchesType } from '../../utils/matchesType';
|
||||
import { HOVER } from './types';
|
||||
export function createHover(manager) {
|
||||
return function hover(targetIdsArg) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
clientOffset = _ref.clientOffset;
|
||||
|
||||
verifyTargetIdsIsArray(targetIdsArg);
|
||||
var targetIds = targetIdsArg.slice(0);
|
||||
var monitor = manager.getMonitor();
|
||||
var registry = manager.getRegistry();
|
||||
checkInvariants(targetIds, monitor, registry);
|
||||
var draggedItemType = monitor.getItemType();
|
||||
removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
|
||||
hoverAllTargets(targetIds, monitor, registry);
|
||||
return {
|
||||
type: HOVER,
|
||||
payload: {
|
||||
targetIds: targetIds,
|
||||
clientOffset: clientOffset || null
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function verifyTargetIdsIsArray(targetIdsArg) {
|
||||
invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.');
|
||||
}
|
||||
|
||||
function checkInvariants(targetIds, monitor, registry) {
|
||||
invariant(monitor.isDragging(), 'Cannot call hover while not dragging.');
|
||||
invariant(!monitor.didDrop(), 'Cannot call hover after drop.');
|
||||
|
||||
for (var i = 0; i < targetIds.length; i++) {
|
||||
var targetId = targetIds[i];
|
||||
invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
|
||||
var target = registry.getTarget(targetId);
|
||||
invariant(target, 'Expected targetIds to be registered.');
|
||||
}
|
||||
}
|
||||
|
||||
function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) {
|
||||
// Remove those targetIds that don't match the targetType. This
|
||||
// fixes shallow isOver which would only be non-shallow because of
|
||||
// non-matching targets.
|
||||
for (var i = targetIds.length - 1; i >= 0; i--) {
|
||||
var targetId = targetIds[i];
|
||||
var targetType = registry.getTargetType(targetId);
|
||||
|
||||
if (!matchesType(targetType, draggedItemType)) {
|
||||
targetIds.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function hoverAllTargets(targetIds, monitor, registry) {
|
||||
// Finally call hover on all matching targets.
|
||||
targetIds.forEach(function (targetId) {
|
||||
var target = registry.getTarget(targetId);
|
||||
target.hover(monitor, targetId);
|
||||
});
|
||||
}
|
||||
15
node_modules/dnd-core/dist/esm/actions/dragDrop/index.js
generated
vendored
Normal file
15
node_modules/dnd-core/dist/esm/actions/dragDrop/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createBeginDrag } from './beginDrag';
|
||||
import { createPublishDragSource } from './publishDragSource';
|
||||
import { createHover } from './hover';
|
||||
import { createDrop } from './drop';
|
||||
import { createEndDrag } from './endDrag';
|
||||
export * from './types';
|
||||
export function createDragDropActions(manager) {
|
||||
return {
|
||||
beginDrag: createBeginDrag(manager),
|
||||
publishDragSource: createPublishDragSource(manager),
|
||||
hover: createHover(manager),
|
||||
drop: createDrop(manager),
|
||||
endDrag: createEndDrag(manager)
|
||||
};
|
||||
}
|
||||
10
node_modules/dnd-core/dist/esm/actions/dragDrop/local/setClientOffset.js
generated
vendored
Normal file
10
node_modules/dnd-core/dist/esm/actions/dragDrop/local/setClientOffset.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { INIT_COORDS } from '../types';
|
||||
export function setClientOffset(clientOffset, sourceClientOffset) {
|
||||
return {
|
||||
type: INIT_COORDS,
|
||||
payload: {
|
||||
sourceClientOffset: sourceClientOffset || null,
|
||||
clientOffset: clientOffset || null
|
||||
}
|
||||
};
|
||||
}
|
||||
12
node_modules/dnd-core/dist/esm/actions/dragDrop/publishDragSource.js
generated
vendored
Normal file
12
node_modules/dnd-core/dist/esm/actions/dragDrop/publishDragSource.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { PUBLISH_DRAG_SOURCE } from './types';
|
||||
export function createPublishDragSource(manager) {
|
||||
return function publishDragSource() {
|
||||
var monitor = manager.getMonitor();
|
||||
|
||||
if (monitor.isDragging()) {
|
||||
return {
|
||||
type: PUBLISH_DRAG_SOURCE
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
6
node_modules/dnd-core/dist/esm/actions/dragDrop/types.js
generated
vendored
Normal file
6
node_modules/dnd-core/dist/esm/actions/dragDrop/types.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export var INIT_COORDS = 'dnd-core/INIT_COORDS';
|
||||
export var BEGIN_DRAG = 'dnd-core/BEGIN_DRAG';
|
||||
export var PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE';
|
||||
export var HOVER = 'dnd-core/HOVER';
|
||||
export var DROP = 'dnd-core/DROP';
|
||||
export var END_DRAG = 'dnd-core/END_DRAG';
|
||||
36
node_modules/dnd-core/dist/esm/actions/registry.js
generated
vendored
Normal file
36
node_modules/dnd-core/dist/esm/actions/registry.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
export var ADD_SOURCE = 'dnd-core/ADD_SOURCE';
|
||||
export var ADD_TARGET = 'dnd-core/ADD_TARGET';
|
||||
export var REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE';
|
||||
export var REMOVE_TARGET = 'dnd-core/REMOVE_TARGET';
|
||||
export function addSource(sourceId) {
|
||||
return {
|
||||
type: ADD_SOURCE,
|
||||
payload: {
|
||||
sourceId: sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function addTarget(targetId) {
|
||||
return {
|
||||
type: ADD_TARGET,
|
||||
payload: {
|
||||
targetId: targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function removeSource(sourceId) {
|
||||
return {
|
||||
type: REMOVE_SOURCE,
|
||||
payload: {
|
||||
sourceId: sourceId
|
||||
}
|
||||
};
|
||||
}
|
||||
export function removeTarget(targetId) {
|
||||
return {
|
||||
type: REMOVE_TARGET,
|
||||
payload: {
|
||||
targetId: targetId
|
||||
}
|
||||
};
|
||||
}
|
||||
101
node_modules/dnd-core/dist/esm/classes/DragDropManagerImpl.js
generated
vendored
Normal file
101
node_modules/dnd-core/dist/esm/classes/DragDropManagerImpl.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
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 { createDragDropActions } from '../actions/dragDrop';
|
||||
export var DragDropManagerImpl = /*#__PURE__*/function () {
|
||||
function DragDropManagerImpl(store, monitor) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, DragDropManagerImpl);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
_defineProperty(this, "monitor", void 0);
|
||||
|
||||
_defineProperty(this, "backend", void 0);
|
||||
|
||||
_defineProperty(this, "isSetUp", false);
|
||||
|
||||
_defineProperty(this, "handleRefCountChange", function () {
|
||||
var shouldSetUp = _this.store.getState().refCount > 0;
|
||||
|
||||
if (_this.backend) {
|
||||
if (shouldSetUp && !_this.isSetUp) {
|
||||
_this.backend.setup();
|
||||
|
||||
_this.isSetUp = true;
|
||||
} else if (!shouldSetUp && _this.isSetUp) {
|
||||
_this.backend.teardown();
|
||||
|
||||
_this.isSetUp = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.store = store;
|
||||
this.monitor = monitor;
|
||||
store.subscribe(this.handleRefCountChange);
|
||||
}
|
||||
|
||||
_createClass(DragDropManagerImpl, [{
|
||||
key: "receiveBackend",
|
||||
value: function receiveBackend(backend) {
|
||||
this.backend = backend;
|
||||
}
|
||||
}, {
|
||||
key: "getMonitor",
|
||||
value: function getMonitor() {
|
||||
return this.monitor;
|
||||
}
|
||||
}, {
|
||||
key: "getBackend",
|
||||
value: function getBackend() {
|
||||
return this.backend;
|
||||
}
|
||||
}, {
|
||||
key: "getRegistry",
|
||||
value: function getRegistry() {
|
||||
return this.monitor.registry;
|
||||
}
|
||||
}, {
|
||||
key: "getActions",
|
||||
value: function getActions() {
|
||||
/* eslint-disable-next-line @typescript-eslint/no-this-alias */
|
||||
var manager = this;
|
||||
var dispatch = this.store.dispatch;
|
||||
|
||||
function bindActionCreator(actionCreator) {
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var action = actionCreator.apply(manager, args);
|
||||
|
||||
if (typeof action !== 'undefined') {
|
||||
dispatch(action);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var actions = createDragDropActions(this);
|
||||
return Object.keys(actions).reduce(function (boundActions, key) {
|
||||
var action = actions[key];
|
||||
boundActions[key] = bindActionCreator(action);
|
||||
return boundActions;
|
||||
}, {});
|
||||
}
|
||||
}, {
|
||||
key: "dispatch",
|
||||
value: function dispatch(action) {
|
||||
this.store.dispatch(action);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DragDropManagerImpl;
|
||||
}();
|
||||
243
node_modules/dnd-core/dist/esm/classes/DragDropMonitorImpl.js
generated
vendored
Normal file
243
node_modules/dnd-core/dist/esm/classes/DragDropMonitorImpl.js
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
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';
|
||||
import { matchesType } from '../utils/matchesType';
|
||||
import { getSourceClientOffset as _getSourceClientOffset, getDifferenceFromInitialOffset as _getDifferenceFromInitialOffset } from '../utils/coords';
|
||||
import { areDirty } from '../utils/dirtiness';
|
||||
export var DragDropMonitorImpl = /*#__PURE__*/function () {
|
||||
function DragDropMonitorImpl(store, registry) {
|
||||
_classCallCheck(this, DragDropMonitorImpl);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
_defineProperty(this, "registry", void 0);
|
||||
|
||||
this.store = store;
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
_createClass(DragDropMonitorImpl, [{
|
||||
key: "subscribeToStateChange",
|
||||
value: function subscribeToStateChange(listener) {
|
||||
var _this = this;
|
||||
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
handlerIds: undefined
|
||||
};
|
||||
var handlerIds = options.handlerIds;
|
||||
invariant(typeof listener === 'function', 'listener must be a function.');
|
||||
invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.');
|
||||
var prevStateId = this.store.getState().stateId;
|
||||
|
||||
var handleChange = function handleChange() {
|
||||
var state = _this.store.getState();
|
||||
|
||||
var currentStateId = state.stateId;
|
||||
|
||||
try {
|
||||
var canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds);
|
||||
|
||||
if (!canSkipListener) {
|
||||
listener();
|
||||
}
|
||||
} finally {
|
||||
prevStateId = currentStateId;
|
||||
}
|
||||
};
|
||||
|
||||
return this.store.subscribe(handleChange);
|
||||
}
|
||||
}, {
|
||||
key: "subscribeToOffsetChange",
|
||||
value: function subscribeToOffsetChange(listener) {
|
||||
var _this2 = this;
|
||||
|
||||
invariant(typeof listener === 'function', 'listener must be a function.');
|
||||
var previousState = this.store.getState().dragOffset;
|
||||
|
||||
var handleChange = function handleChange() {
|
||||
var nextState = _this2.store.getState().dragOffset;
|
||||
|
||||
if (nextState === previousState) {
|
||||
return;
|
||||
}
|
||||
|
||||
previousState = nextState;
|
||||
listener();
|
||||
};
|
||||
|
||||
return this.store.subscribe(handleChange);
|
||||
}
|
||||
}, {
|
||||
key: "canDragSource",
|
||||
value: function canDragSource(sourceId) {
|
||||
if (!sourceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var source = this.registry.getSource(sourceId);
|
||||
invariant(source, "Expected to find a valid source. sourceId=".concat(sourceId));
|
||||
|
||||
if (this.isDragging()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return source.canDrag(this, sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "canDropOnTarget",
|
||||
value: function canDropOnTarget(targetId) {
|
||||
// undefined on initial render
|
||||
if (!targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var target = this.registry.getTarget(targetId);
|
||||
invariant(target, "Expected to find a valid target. targetId=".concat(targetId));
|
||||
|
||||
if (!this.isDragging() || this.didDrop()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetType = this.registry.getTargetType(targetId);
|
||||
var draggedItemType = this.getItemType();
|
||||
return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId);
|
||||
}
|
||||
}, {
|
||||
key: "isDragging",
|
||||
value: function isDragging() {
|
||||
return Boolean(this.getItemType());
|
||||
}
|
||||
}, {
|
||||
key: "isDraggingSource",
|
||||
value: function isDraggingSource(sourceId) {
|
||||
// undefined on initial render
|
||||
if (!sourceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var source = this.registry.getSource(sourceId, true);
|
||||
invariant(source, "Expected to find a valid source. sourceId=".concat(sourceId));
|
||||
|
||||
if (!this.isDragging() || !this.isSourcePublic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var sourceType = this.registry.getSourceType(sourceId);
|
||||
var draggedItemType = this.getItemType();
|
||||
|
||||
if (sourceType !== draggedItemType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return source.isDragging(this, sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "isOverTarget",
|
||||
value: function isOverTarget(targetId) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
shallow: false
|
||||
};
|
||||
|
||||
// undefined on initial render
|
||||
if (!targetId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var shallow = options.shallow;
|
||||
|
||||
if (!this.isDragging()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetType = this.registry.getTargetType(targetId);
|
||||
var draggedItemType = this.getItemType();
|
||||
|
||||
if (draggedItemType && !matchesType(targetType, draggedItemType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetIds = this.getTargetIds();
|
||||
|
||||
if (!targetIds.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var index = targetIds.indexOf(targetId);
|
||||
|
||||
if (shallow) {
|
||||
return index === targetIds.length - 1;
|
||||
} else {
|
||||
return index > -1;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getItemType",
|
||||
value: function getItemType() {
|
||||
return this.store.getState().dragOperation.itemType;
|
||||
}
|
||||
}, {
|
||||
key: "getItem",
|
||||
value: function getItem() {
|
||||
return this.store.getState().dragOperation.item;
|
||||
}
|
||||
}, {
|
||||
key: "getSourceId",
|
||||
value: function getSourceId() {
|
||||
return this.store.getState().dragOperation.sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "getTargetIds",
|
||||
value: function getTargetIds() {
|
||||
return this.store.getState().dragOperation.targetIds;
|
||||
}
|
||||
}, {
|
||||
key: "getDropResult",
|
||||
value: function getDropResult() {
|
||||
return this.store.getState().dragOperation.dropResult;
|
||||
}
|
||||
}, {
|
||||
key: "didDrop",
|
||||
value: function didDrop() {
|
||||
return this.store.getState().dragOperation.didDrop;
|
||||
}
|
||||
}, {
|
||||
key: "isSourcePublic",
|
||||
value: function isSourcePublic() {
|
||||
return Boolean(this.store.getState().dragOperation.isSourcePublic);
|
||||
}
|
||||
}, {
|
||||
key: "getInitialClientOffset",
|
||||
value: function getInitialClientOffset() {
|
||||
return this.store.getState().dragOffset.initialClientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getInitialSourceClientOffset",
|
||||
value: function getInitialSourceClientOffset() {
|
||||
return this.store.getState().dragOffset.initialSourceClientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getClientOffset",
|
||||
value: function getClientOffset() {
|
||||
return this.store.getState().dragOffset.clientOffset;
|
||||
}
|
||||
}, {
|
||||
key: "getSourceClientOffset",
|
||||
value: function getSourceClientOffset() {
|
||||
return _getSourceClientOffset(this.store.getState().dragOffset);
|
||||
}
|
||||
}, {
|
||||
key: "getDifferenceFromInitialOffset",
|
||||
value: function getDifferenceFromInitialOffset() {
|
||||
return _getDifferenceFromInitialOffset(this.store.getState().dragOffset);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DragDropMonitorImpl;
|
||||
}();
|
||||
210
node_modules/dnd-core/dist/esm/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
210
node_modules/dnd-core/dist/esm/classes/HandlerRegistryImpl.js
generated
vendored
Normal file
@@ -0,0 +1,210 @@
|
||||
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; }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
import { addSource as _addSource, addTarget as _addTarget, removeSource as _removeSource, removeTarget as _removeTarget } from '../actions/registry';
|
||||
import { getNextUniqueId } from '../utils/getNextUniqueId';
|
||||
import { HandlerRole } from '../interfaces';
|
||||
import { validateSourceContract, validateTargetContract, validateType } from '../contracts';
|
||||
import { asap } from '@react-dnd/asap';
|
||||
|
||||
function getNextHandlerId(role) {
|
||||
var id = getNextUniqueId().toString();
|
||||
|
||||
switch (role) {
|
||||
case HandlerRole.SOURCE:
|
||||
return "S".concat(id);
|
||||
|
||||
case HandlerRole.TARGET:
|
||||
return "T".concat(id);
|
||||
|
||||
default:
|
||||
throw new Error("Unknown Handler Role: ".concat(role));
|
||||
}
|
||||
}
|
||||
|
||||
function parseRoleFromHandlerId(handlerId) {
|
||||
switch (handlerId[0]) {
|
||||
case 'S':
|
||||
return HandlerRole.SOURCE;
|
||||
|
||||
case 'T':
|
||||
return HandlerRole.TARGET;
|
||||
|
||||
default:
|
||||
invariant(false, "Cannot parse handler ID: ".concat(handlerId));
|
||||
}
|
||||
}
|
||||
|
||||
function mapContainsValue(map, searchValue) {
|
||||
var entries = map.entries();
|
||||
var isDone = false;
|
||||
|
||||
do {
|
||||
var _entries$next = entries.next(),
|
||||
done = _entries$next.done,
|
||||
_entries$next$value = _slicedToArray(_entries$next.value, 2),
|
||||
value = _entries$next$value[1];
|
||||
|
||||
if (value === searchValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
isDone = !!done;
|
||||
} while (!isDone);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export var HandlerRegistryImpl = /*#__PURE__*/function () {
|
||||
function HandlerRegistryImpl(store) {
|
||||
_classCallCheck(this, HandlerRegistryImpl);
|
||||
|
||||
_defineProperty(this, "types", new Map());
|
||||
|
||||
_defineProperty(this, "dragSources", new Map());
|
||||
|
||||
_defineProperty(this, "dropTargets", new Map());
|
||||
|
||||
_defineProperty(this, "pinnedSourceId", null);
|
||||
|
||||
_defineProperty(this, "pinnedSource", null);
|
||||
|
||||
_defineProperty(this, "store", void 0);
|
||||
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
_createClass(HandlerRegistryImpl, [{
|
||||
key: "addSource",
|
||||
value: function addSource(type, source) {
|
||||
validateType(type);
|
||||
validateSourceContract(source);
|
||||
var sourceId = this.addHandler(HandlerRole.SOURCE, type, source);
|
||||
this.store.dispatch(_addSource(sourceId));
|
||||
return sourceId;
|
||||
}
|
||||
}, {
|
||||
key: "addTarget",
|
||||
value: function addTarget(type, target) {
|
||||
validateType(type, true);
|
||||
validateTargetContract(target);
|
||||
var targetId = this.addHandler(HandlerRole.TARGET, type, target);
|
||||
this.store.dispatch(_addTarget(targetId));
|
||||
return targetId;
|
||||
}
|
||||
}, {
|
||||
key: "containsHandler",
|
||||
value: function containsHandler(handler) {
|
||||
return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler);
|
||||
}
|
||||
}, {
|
||||
key: "getSource",
|
||||
value: function getSource(sourceId) {
|
||||
var includePinned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
var isPinned = includePinned && sourceId === this.pinnedSourceId;
|
||||
var source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId);
|
||||
return source;
|
||||
}
|
||||
}, {
|
||||
key: "getTarget",
|
||||
value: function getTarget(targetId) {
|
||||
invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.dropTargets.get(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "getSourceType",
|
||||
value: function getSourceType(sourceId) {
|
||||
invariant(this.isSourceId(sourceId), 'Expected a valid source ID.');
|
||||
return this.types.get(sourceId);
|
||||
}
|
||||
}, {
|
||||
key: "getTargetType",
|
||||
value: function getTargetType(targetId) {
|
||||
invariant(this.isTargetId(targetId), 'Expected a valid target ID.');
|
||||
return this.types.get(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "isSourceId",
|
||||
value: function isSourceId(handlerId) {
|
||||
var role = parseRoleFromHandlerId(handlerId);
|
||||
return role === HandlerRole.SOURCE;
|
||||
}
|
||||
}, {
|
||||
key: "isTargetId",
|
||||
value: function isTargetId(handlerId) {
|
||||
var role = parseRoleFromHandlerId(handlerId);
|
||||
return role === HandlerRole.TARGET;
|
||||
}
|
||||
}, {
|
||||
key: "removeSource",
|
||||
value: function removeSource(sourceId) {
|
||||
var _this = this;
|
||||
|
||||
invariant(this.getSource(sourceId), 'Expected an existing source.');
|
||||
this.store.dispatch(_removeSource(sourceId));
|
||||
asap(function () {
|
||||
_this.dragSources.delete(sourceId);
|
||||
|
||||
_this.types.delete(sourceId);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "removeTarget",
|
||||
value: function removeTarget(targetId) {
|
||||
invariant(this.getTarget(targetId), 'Expected an existing target.');
|
||||
this.store.dispatch(_removeTarget(targetId));
|
||||
this.dropTargets.delete(targetId);
|
||||
this.types.delete(targetId);
|
||||
}
|
||||
}, {
|
||||
key: "pinSource",
|
||||
value: function pinSource(sourceId) {
|
||||
var source = this.getSource(sourceId);
|
||||
invariant(source, 'Expected an existing source.');
|
||||
this.pinnedSourceId = sourceId;
|
||||
this.pinnedSource = source;
|
||||
}
|
||||
}, {
|
||||
key: "unpinSource",
|
||||
value: function unpinSource() {
|
||||
invariant(this.pinnedSource, 'No source is pinned at the time.');
|
||||
this.pinnedSourceId = null;
|
||||
this.pinnedSource = null;
|
||||
}
|
||||
}, {
|
||||
key: "addHandler",
|
||||
value: function addHandler(role, type, handler) {
|
||||
var id = getNextHandlerId(role);
|
||||
this.types.set(id, type);
|
||||
|
||||
if (role === HandlerRole.SOURCE) {
|
||||
this.dragSources.set(id, handler);
|
||||
} else if (role === HandlerRole.TARGET) {
|
||||
this.dropTargets.set(id, handler);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}]);
|
||||
|
||||
return HandlerRegistryImpl;
|
||||
}();
|
||||
23
node_modules/dnd-core/dist/esm/contracts.js
generated
vendored
Normal file
23
node_modules/dnd-core/dist/esm/contracts.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
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); }
|
||||
|
||||
import { invariant } from '@react-dnd/invariant';
|
||||
export function validateSourceContract(source) {
|
||||
invariant(typeof source.canDrag === 'function', 'Expected canDrag to be a function.');
|
||||
invariant(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.');
|
||||
invariant(typeof source.endDrag === 'function', 'Expected endDrag to be a function.');
|
||||
}
|
||||
export function validateTargetContract(target) {
|
||||
invariant(typeof target.canDrop === 'function', 'Expected canDrop to be a function.');
|
||||
invariant(typeof target.hover === 'function', 'Expected hover to be a function.');
|
||||
invariant(typeof target.drop === 'function', 'Expected beginDrag to be a function.');
|
||||
}
|
||||
export function validateType(type, allowArray) {
|
||||
if (allowArray && Array.isArray(type)) {
|
||||
type.forEach(function (t) {
|
||||
return validateType(t, false);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
invariant(typeof type === 'string' || _typeof(type) === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.');
|
||||
}
|
||||
26
node_modules/dnd-core/dist/esm/createDragDropManager.js
generated
vendored
Normal file
26
node_modules/dnd-core/dist/esm/createDragDropManager.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { DragDropManagerImpl } from './classes/DragDropManagerImpl';
|
||||
import { createStore } from 'redux';
|
||||
import { reduce } from './reducers';
|
||||
import { DragDropMonitorImpl } from './classes/DragDropMonitorImpl';
|
||||
import { HandlerRegistryImpl } from './classes/HandlerRegistryImpl';
|
||||
export function createDragDropManager(backendFactory) {
|
||||
var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
||||
var backendOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var debugMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
||||
var store = makeStoreInstance(debugMode);
|
||||
var monitor = new DragDropMonitorImpl(store, new HandlerRegistryImpl(store));
|
||||
var manager = new DragDropManagerImpl(store, monitor);
|
||||
var backend = backendFactory(manager, globalContext, backendOptions);
|
||||
manager.receiveBackend(backend);
|
||||
return manager;
|
||||
}
|
||||
|
||||
function makeStoreInstance(debugMode) {
|
||||
// TODO: if we ever make a react-native version of this,
|
||||
// we'll need to consider how to pull off dev-tooling
|
||||
var reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__;
|
||||
return createStore(reduce, debugMode && reduxDevTools && reduxDevTools({
|
||||
name: 'dnd-core',
|
||||
instanceId: 'dnd-core'
|
||||
}));
|
||||
}
|
||||
2
node_modules/dnd-core/dist/esm/index.js
generated
vendored
Normal file
2
node_modules/dnd-core/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './interfaces';
|
||||
export * from './createDragDropManager';
|
||||
6
node_modules/dnd-core/dist/esm/interfaces.js
generated
vendored
Normal file
6
node_modules/dnd-core/dist/esm/interfaces.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export var HandlerRole;
|
||||
|
||||
(function (HandlerRole) {
|
||||
HandlerRole["SOURCE"] = "SOURCE";
|
||||
HandlerRole["TARGET"] = "TARGET";
|
||||
})(HandlerRole || (HandlerRole = {}));
|
||||
57
node_modules/dnd-core/dist/esm/reducers/dirtyHandlerIds.js
generated
vendored
Normal file
57
node_modules/dnd-core/dist/esm/reducers/dirtyHandlerIds.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
|
||||
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry';
|
||||
import { areArraysEqual } from '../utils/equality';
|
||||
import { NONE, ALL } from '../utils/dirtiness';
|
||||
import { xor } from '../utils/js_utils';
|
||||
export function reduce() {
|
||||
var _state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NONE;
|
||||
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
switch (action.type) {
|
||||
case HOVER:
|
||||
break;
|
||||
|
||||
case ADD_SOURCE:
|
||||
case ADD_TARGET:
|
||||
case REMOVE_TARGET:
|
||||
case REMOVE_SOURCE:
|
||||
return NONE;
|
||||
|
||||
case BEGIN_DRAG:
|
||||
case PUBLISH_DRAG_SOURCE:
|
||||
case END_DRAG:
|
||||
case DROP:
|
||||
default:
|
||||
return ALL;
|
||||
}
|
||||
|
||||
var _action$payload = action.payload,
|
||||
_action$payload$targe = _action$payload.targetIds,
|
||||
targetIds = _action$payload$targe === void 0 ? [] : _action$payload$targe,
|
||||
_action$payload$prevT = _action$payload.prevTargetIds,
|
||||
prevTargetIds = _action$payload$prevT === void 0 ? [] : _action$payload$prevT;
|
||||
var result = xor(targetIds, prevTargetIds);
|
||||
var didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds);
|
||||
|
||||
if (!didChange) {
|
||||
return NONE;
|
||||
} // Check the target ids at the innermost position. If they are valid, add them
|
||||
// to the result
|
||||
|
||||
|
||||
var prevInnermostTargetId = prevTargetIds[prevTargetIds.length - 1];
|
||||
var innermostTargetId = targetIds[targetIds.length - 1];
|
||||
|
||||
if (prevInnermostTargetId !== innermostTargetId) {
|
||||
if (prevInnermostTargetId) {
|
||||
result.push(prevInnermostTargetId);
|
||||
}
|
||||
|
||||
if (innermostTargetId) {
|
||||
result.push(innermostTargetId);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
44
node_modules/dnd-core/dist/esm/reducers/dragOffset.js
generated
vendored
Normal file
44
node_modules/dnd-core/dist/esm/reducers/dragOffset.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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 { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
|
||||
import { areCoordsEqual } from '../utils/equality';
|
||||
var initialState = {
|
||||
initialSourceClientOffset: null,
|
||||
initialClientOffset: null,
|
||||
clientOffset: null
|
||||
};
|
||||
export function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
var payload = action.payload;
|
||||
|
||||
switch (action.type) {
|
||||
case INIT_COORDS:
|
||||
case BEGIN_DRAG:
|
||||
return {
|
||||
initialSourceClientOffset: payload.sourceClientOffset,
|
||||
initialClientOffset: payload.clientOffset,
|
||||
clientOffset: payload.clientOffset
|
||||
};
|
||||
|
||||
case HOVER:
|
||||
if (areCoordsEqual(state.clientOffset, payload.clientOffset)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
clientOffset: payload.clientOffset
|
||||
});
|
||||
|
||||
case END_DRAG:
|
||||
case DROP:
|
||||
return initialState;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
75
node_modules/dnd-core/dist/esm/reducers/dragOperation.js
generated
vendored
Normal file
75
node_modules/dnd-core/dist/esm/reducers/dragOperation.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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 { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop';
|
||||
import { REMOVE_TARGET } from '../actions/registry';
|
||||
import { without } from '../utils/js_utils';
|
||||
var initialState = {
|
||||
itemType: null,
|
||||
item: null,
|
||||
sourceId: null,
|
||||
targetIds: [],
|
||||
dropResult: null,
|
||||
didDrop: false,
|
||||
isSourcePublic: null
|
||||
};
|
||||
export function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
var payload = action.payload;
|
||||
|
||||
switch (action.type) {
|
||||
case BEGIN_DRAG:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
itemType: payload.itemType,
|
||||
item: payload.item,
|
||||
sourceId: payload.sourceId,
|
||||
isSourcePublic: payload.isSourcePublic,
|
||||
dropResult: null,
|
||||
didDrop: false
|
||||
});
|
||||
|
||||
case PUBLISH_DRAG_SOURCE:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
isSourcePublic: true
|
||||
});
|
||||
|
||||
case HOVER:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
targetIds: payload.targetIds
|
||||
});
|
||||
|
||||
case REMOVE_TARGET:
|
||||
if (state.targetIds.indexOf(payload.targetId) === -1) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
targetIds: without(state.targetIds, payload.targetId)
|
||||
});
|
||||
|
||||
case DROP:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
dropResult: payload.dropResult,
|
||||
didDrop: true,
|
||||
targetIds: []
|
||||
});
|
||||
|
||||
case END_DRAG:
|
||||
return _objectSpread(_objectSpread({}, state), {}, {
|
||||
itemType: null,
|
||||
item: null,
|
||||
sourceId: null,
|
||||
dropResult: null,
|
||||
didDrop: false,
|
||||
isSourcePublic: null,
|
||||
targetIds: []
|
||||
});
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
28
node_modules/dnd-core/dist/esm/reducers/index.js
generated
vendored
Normal file
28
node_modules/dnd-core/dist/esm/reducers/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
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 { reduce as dragOffset } from './dragOffset';
|
||||
import { reduce as dragOperation } from './dragOperation';
|
||||
import { reduce as refCount } from './refCount';
|
||||
import { reduce as dirtyHandlerIds } from './dirtyHandlerIds';
|
||||
import { reduce as stateId } from './stateId';
|
||||
import { get } from '../utils/js_utils';
|
||||
export function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
return {
|
||||
dirtyHandlerIds: dirtyHandlerIds(state.dirtyHandlerIds, {
|
||||
type: action.type,
|
||||
payload: _objectSpread(_objectSpread({}, action.payload), {}, {
|
||||
prevTargetIds: get(state, 'dragOperation.targetIds', [])
|
||||
})
|
||||
}),
|
||||
dragOffset: dragOffset(state.dragOffset, action),
|
||||
refCount: refCount(state.refCount, action),
|
||||
dragOperation: dragOperation(state.dragOperation, action),
|
||||
stateId: stateId(state.stateId)
|
||||
};
|
||||
}
|
||||
18
node_modules/dnd-core/dist/esm/reducers/refCount.js
generated
vendored
Normal file
18
node_modules/dnd-core/dist/esm/reducers/refCount.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry';
|
||||
export function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
||||
var action = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
switch (action.type) {
|
||||
case ADD_SOURCE:
|
||||
case ADD_TARGET:
|
||||
return state + 1;
|
||||
|
||||
case REMOVE_SOURCE:
|
||||
case REMOVE_TARGET:
|
||||
return state - 1;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
4
node_modules/dnd-core/dist/esm/reducers/stateId.js
generated
vendored
Normal file
4
node_modules/dnd-core/dist/esm/reducers/stateId.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export function reduce() {
|
||||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
||||
return state + 1;
|
||||
}
|
||||
59
node_modules/dnd-core/dist/esm/utils/coords.js
generated
vendored
Normal file
59
node_modules/dnd-core/dist/esm/utils/coords.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Coordinate addition
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
export function add(a, b) {
|
||||
return {
|
||||
x: a.x + b.x,
|
||||
y: a.y + b.y
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Coordinate subtraction
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
|
||||
export function subtract(a, b) {
|
||||
return {
|
||||
x: a.x - b.x,
|
||||
y: a.y - b.y
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Returns the cartesian distance of the drag source component's position, based on its position
|
||||
* at the time when the current drag operation has started, and the movement difference.
|
||||
*
|
||||
* Returns null if no item is being dragged.
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
|
||||
export function getSourceClientOffset(state) {
|
||||
var clientOffset = state.clientOffset,
|
||||
initialClientOffset = state.initialClientOffset,
|
||||
initialSourceClientOffset = state.initialSourceClientOffset;
|
||||
|
||||
if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset);
|
||||
}
|
||||
/**
|
||||
* Determines the x,y offset between the client offset and the initial client offset
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
|
||||
export function getDifferenceFromInitialOffset(state) {
|
||||
var clientOffset = state.clientOffset,
|
||||
initialClientOffset = state.initialClientOffset;
|
||||
|
||||
if (!clientOffset || !initialClientOffset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return subtract(clientOffset, initialClientOffset);
|
||||
}
|
||||
24
node_modules/dnd-core/dist/esm/utils/dirtiness.js
generated
vendored
Normal file
24
node_modules/dnd-core/dist/esm/utils/dirtiness.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { intersection } from './js_utils';
|
||||
export var NONE = [];
|
||||
export var ALL = [];
|
||||
NONE.__IS_NONE__ = true;
|
||||
ALL.__IS_ALL__ = true;
|
||||
/**
|
||||
* Determines if the given handler IDs are dirty or not.
|
||||
*
|
||||
* @param dirtyIds The set of dirty handler ids
|
||||
* @param handlerIds The set of handler ids to check
|
||||
*/
|
||||
|
||||
export function areDirty(dirtyIds, handlerIds) {
|
||||
if (dirtyIds === NONE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dirtyIds === ALL || typeof handlerIds === 'undefined') {
|
||||
return true;
|
||||
}
|
||||
|
||||
var commonIds = intersection(handlerIds, dirtyIds);
|
||||
return commonIds.length > 0;
|
||||
}
|
||||
39
node_modules/dnd-core/dist/esm/utils/equality.js
generated
vendored
Normal file
39
node_modules/dnd-core/dist/esm/utils/equality.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
export var strictEquality = function strictEquality(a, b) {
|
||||
return a === b;
|
||||
};
|
||||
/**
|
||||
* Determine if two cartesian coordinate offsets are equal
|
||||
* @param offsetA
|
||||
* @param offsetB
|
||||
*/
|
||||
|
||||
export function areCoordsEqual(offsetA, offsetB) {
|
||||
if (!offsetA && !offsetB) {
|
||||
return true;
|
||||
} else if (!offsetA || !offsetB) {
|
||||
return false;
|
||||
} else {
|
||||
return offsetA.x === offsetB.x && offsetA.y === offsetB.y;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determines if two arrays of items are equal
|
||||
* @param a The first array of items
|
||||
* @param b The second array of items
|
||||
*/
|
||||
|
||||
export function areArraysEqual(a, b) {
|
||||
var isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : strictEquality;
|
||||
|
||||
if (a.length !== b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (!isEqual(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
4
node_modules/dnd-core/dist/esm/utils/getNextUniqueId.js
generated
vendored
Normal file
4
node_modules/dnd-core/dist/esm/utils/getNextUniqueId.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var nextUniqueId = 0;
|
||||
export function getNextUniqueId() {
|
||||
return nextUniqueId++;
|
||||
}
|
||||
74
node_modules/dnd-core/dist/esm/utils/js_utils.js
generated
vendored
Normal file
74
node_modules/dnd-core/dist/esm/utils/js_utils.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
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); }
|
||||
|
||||
// cheap lodash replacements
|
||||
|
||||
/**
|
||||
* drop-in replacement for _.get
|
||||
* @param obj
|
||||
* @param path
|
||||
* @param defaultValue
|
||||
*/
|
||||
export function get(obj, path, defaultValue) {
|
||||
return path.split('.').reduce(function (a, c) {
|
||||
return a && a[c] ? a[c] : defaultValue || null;
|
||||
}, obj);
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.without
|
||||
*/
|
||||
|
||||
export function without(items, item) {
|
||||
return items.filter(function (i) {
|
||||
return i !== item;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
|
||||
export function isString(input) {
|
||||
return typeof input === 'string';
|
||||
}
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
|
||||
export function isObject(input) {
|
||||
return _typeof(input) === 'object';
|
||||
}
|
||||
/**
|
||||
* repalcement for _.xor
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
|
||||
export function xor(itemsA, itemsB) {
|
||||
var map = new Map();
|
||||
|
||||
var insertItem = function insertItem(item) {
|
||||
map.set(item, map.has(item) ? map.get(item) + 1 : 1);
|
||||
};
|
||||
|
||||
itemsA.forEach(insertItem);
|
||||
itemsB.forEach(insertItem);
|
||||
var result = [];
|
||||
map.forEach(function (count, key) {
|
||||
if (count === 1) {
|
||||
result.push(key);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* replacement for _.intersection
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
|
||||
export function intersection(itemsA, itemsB) {
|
||||
return itemsA.filter(function (t) {
|
||||
return itemsB.indexOf(t) > -1;
|
||||
});
|
||||
}
|
||||
9
node_modules/dnd-core/dist/esm/utils/matchesType.js
generated
vendored
Normal file
9
node_modules/dnd-core/dist/esm/utils/matchesType.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export function matchesType(targetType, draggedItemType) {
|
||||
if (draggedItemType === null) {
|
||||
return targetType === null;
|
||||
}
|
||||
|
||||
return Array.isArray(targetType) ? targetType.some(function (t) {
|
||||
return t === draggedItemType;
|
||||
}) : targetType === draggedItemType;
|
||||
}
|
||||
2
node_modules/dnd-core/dist/types/actions/dragDrop/beginDrag.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/actions/dragDrop/beginDrag.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Action, DragDropManager, BeginDragPayload, BeginDragOptions, Identifier } from '../../interfaces';
|
||||
export declare function createBeginDrag(manager: DragDropManager): (sourceIds?: Identifier[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined;
|
||||
2
node_modules/dnd-core/dist/types/actions/dragDrop/drop.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/actions/dragDrop/drop.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { DragDropManager } from '../../interfaces';
|
||||
export declare function createDrop(manager: DragDropManager): (options?: {}) => void;
|
||||
2
node_modules/dnd-core/dist/types/actions/dragDrop/endDrag.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/actions/dragDrop/endDrag.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { DragDropManager, SentinelAction } from '../../interfaces';
|
||||
export declare function createEndDrag(manager: DragDropManager): () => SentinelAction;
|
||||
2
node_modules/dnd-core/dist/types/actions/dragDrop/hover.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/actions/dragDrop/hover.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Action, DragDropManager, HoverPayload, HoverOptions } from '../../interfaces';
|
||||
export declare function createHover(manager: DragDropManager): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>;
|
||||
3
node_modules/dnd-core/dist/types/actions/dragDrop/index.d.ts
generated
vendored
Normal file
3
node_modules/dnd-core/dist/types/actions/dragDrop/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { DragDropManager, DragDropActions } from '../../interfaces';
|
||||
export * from './types';
|
||||
export declare function createDragDropActions(manager: DragDropManager): DragDropActions;
|
||||
3
node_modules/dnd-core/dist/types/actions/dragDrop/local/setClientOffset.d.ts
generated
vendored
Normal file
3
node_modules/dnd-core/dist/types/actions/dragDrop/local/setClientOffset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { XYCoord } from '../../../interfaces';
|
||||
import { AnyAction } from 'redux';
|
||||
export declare function setClientOffset(clientOffset: XYCoord | null | undefined, sourceClientOffset?: XYCoord | null | undefined): AnyAction;
|
||||
2
node_modules/dnd-core/dist/types/actions/dragDrop/publishDragSource.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/actions/dragDrop/publishDragSource.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { DragDropManager, SentinelAction } from '../../interfaces';
|
||||
export declare function createPublishDragSource(manager: DragDropManager): () => SentinelAction | undefined;
|
||||
6
node_modules/dnd-core/dist/types/actions/dragDrop/types.d.ts
generated
vendored
Normal file
6
node_modules/dnd-core/dist/types/actions/dragDrop/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export declare const INIT_COORDS = "dnd-core/INIT_COORDS";
|
||||
export declare const BEGIN_DRAG = "dnd-core/BEGIN_DRAG";
|
||||
export declare const PUBLISH_DRAG_SOURCE = "dnd-core/PUBLISH_DRAG_SOURCE";
|
||||
export declare const HOVER = "dnd-core/HOVER";
|
||||
export declare const DROP = "dnd-core/DROP";
|
||||
export declare const END_DRAG = "dnd-core/END_DRAG";
|
||||
9
node_modules/dnd-core/dist/types/actions/registry.d.ts
generated
vendored
Normal file
9
node_modules/dnd-core/dist/types/actions/registry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Action, SourceIdPayload, TargetIdPayload } from '../interfaces';
|
||||
export declare const ADD_SOURCE = "dnd-core/ADD_SOURCE";
|
||||
export declare const ADD_TARGET = "dnd-core/ADD_TARGET";
|
||||
export declare const REMOVE_SOURCE = "dnd-core/REMOVE_SOURCE";
|
||||
export declare const REMOVE_TARGET = "dnd-core/REMOVE_TARGET";
|
||||
export declare function addSource(sourceId: string): Action<SourceIdPayload>;
|
||||
export declare function addTarget(targetId: string): Action<TargetIdPayload>;
|
||||
export declare function removeSource(sourceId: string): Action<SourceIdPayload>;
|
||||
export declare function removeTarget(targetId: string): Action<TargetIdPayload>;
|
||||
17
node_modules/dnd-core/dist/types/classes/DragDropManagerImpl.d.ts
generated
vendored
Normal file
17
node_modules/dnd-core/dist/types/classes/DragDropManagerImpl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Store, Action } from 'redux';
|
||||
import { Backend, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from '../interfaces';
|
||||
import { State } from '../reducers';
|
||||
export declare class DragDropManagerImpl implements DragDropManager {
|
||||
private store;
|
||||
private monitor;
|
||||
private backend;
|
||||
private isSetUp;
|
||||
constructor(store: Store<State>, monitor: DragDropMonitor);
|
||||
receiveBackend(backend: Backend): void;
|
||||
getMonitor(): DragDropMonitor;
|
||||
getBackend(): Backend;
|
||||
getRegistry(): HandlerRegistry;
|
||||
getActions(): DragDropActions;
|
||||
dispatch(action: Action<any>): void;
|
||||
private handleRefCountChange;
|
||||
}
|
||||
31
node_modules/dnd-core/dist/types/classes/DragDropMonitorImpl.d.ts
generated
vendored
Normal file
31
node_modules/dnd-core/dist/types/classes/DragDropMonitorImpl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Store } from 'redux';
|
||||
import { State } from '../reducers';
|
||||
import { DragDropMonitor, Listener, Unsubscribe, XYCoord, HandlerRegistry, Identifier } from '../interfaces';
|
||||
export declare class DragDropMonitorImpl implements DragDropMonitor {
|
||||
private store;
|
||||
readonly registry: HandlerRegistry;
|
||||
constructor(store: Store<State>, registry: HandlerRegistry);
|
||||
subscribeToStateChange(listener: Listener, options?: {
|
||||
handlerIds: string[] | undefined;
|
||||
}): Unsubscribe;
|
||||
subscribeToOffsetChange(listener: Listener): Unsubscribe;
|
||||
canDragSource(sourceId: string | undefined): boolean;
|
||||
canDropOnTarget(targetId: string | undefined): boolean;
|
||||
isDragging(): boolean;
|
||||
isDraggingSource(sourceId: string | undefined): boolean;
|
||||
isOverTarget(targetId: string | undefined, options?: {
|
||||
shallow: boolean;
|
||||
}): boolean;
|
||||
getItemType(): Identifier;
|
||||
getItem(): any;
|
||||
getSourceId(): string | null;
|
||||
getTargetIds(): string[];
|
||||
getDropResult(): any;
|
||||
didDrop(): boolean;
|
||||
isSourcePublic(): boolean;
|
||||
getInitialClientOffset(): XYCoord | null;
|
||||
getInitialSourceClientOffset(): XYCoord | null;
|
||||
getClientOffset(): XYCoord | null;
|
||||
getSourceClientOffset(): XYCoord | null;
|
||||
getDifferenceFromInitialOffset(): XYCoord | null;
|
||||
}
|
||||
26
node_modules/dnd-core/dist/types/classes/HandlerRegistryImpl.d.ts
generated
vendored
Normal file
26
node_modules/dnd-core/dist/types/classes/HandlerRegistryImpl.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Store } from 'redux';
|
||||
import { State } from '../reducers';
|
||||
import { DragSource, DropTarget, SourceType, TargetType, Identifier, HandlerRegistry } from '../interfaces';
|
||||
export declare class HandlerRegistryImpl implements HandlerRegistry {
|
||||
private types;
|
||||
private dragSources;
|
||||
private dropTargets;
|
||||
private pinnedSourceId;
|
||||
private pinnedSource;
|
||||
private store;
|
||||
constructor(store: Store<State>);
|
||||
addSource(type: SourceType, source: DragSource): string;
|
||||
addTarget(type: TargetType, target: DropTarget): string;
|
||||
containsHandler(handler: DragSource | DropTarget): boolean;
|
||||
getSource(sourceId: string, includePinned?: boolean): DragSource;
|
||||
getTarget(targetId: string): DropTarget;
|
||||
getSourceType(sourceId: string): Identifier;
|
||||
getTargetType(targetId: string): Identifier | Identifier[];
|
||||
isSourceId(handlerId: string): boolean;
|
||||
isTargetId(handlerId: string): boolean;
|
||||
removeSource(sourceId: string): void;
|
||||
removeTarget(targetId: string): void;
|
||||
pinSource(sourceId: string): void;
|
||||
unpinSource(): void;
|
||||
private addHandler;
|
||||
}
|
||||
4
node_modules/dnd-core/dist/types/contracts.d.ts
generated
vendored
Normal file
4
node_modules/dnd-core/dist/types/contracts.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { DragSource, DropTarget, Identifier } from './interfaces';
|
||||
export declare function validateSourceContract(source: DragSource): void;
|
||||
export declare function validateTargetContract(target: DropTarget): void;
|
||||
export declare function validateType(type: Identifier | Identifier[], allowArray?: boolean): void;
|
||||
2
node_modules/dnd-core/dist/types/createDragDropManager.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/createDragDropManager.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { DragDropManager, BackendFactory } from './interfaces';
|
||||
export declare function createDragDropManager(backendFactory: BackendFactory, globalContext?: unknown, backendOptions?: unknown, debugMode?: boolean): DragDropManager;
|
||||
2
node_modules/dnd-core/dist/types/index.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './interfaces';
|
||||
export * from './createDragDropManager';
|
||||
170
node_modules/dnd-core/dist/types/interfaces.d.ts
generated
vendored
Normal file
170
node_modules/dnd-core/dist/types/interfaces.d.ts
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
export declare type Identifier = string | symbol;
|
||||
export declare type SourceType = Identifier;
|
||||
export declare type TargetType = Identifier | Identifier[];
|
||||
export declare type Unsubscribe = () => void;
|
||||
export declare type Listener = () => void;
|
||||
export interface XYCoord {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
export declare enum HandlerRole {
|
||||
SOURCE = "SOURCE",
|
||||
TARGET = "TARGET"
|
||||
}
|
||||
export interface Backend {
|
||||
setup(): void;
|
||||
teardown(): void;
|
||||
connectDragSource(sourceId: any, node?: any, options?: any): Unsubscribe;
|
||||
connectDragPreview(sourceId: any, node?: any, options?: any): Unsubscribe;
|
||||
connectDropTarget(targetId: any, node?: any, options?: any): Unsubscribe;
|
||||
profile(): Record<string, number>;
|
||||
}
|
||||
export interface DragDropMonitor {
|
||||
subscribeToStateChange(listener: Listener, options?: {
|
||||
handlerIds: Identifier[] | undefined;
|
||||
}): Unsubscribe;
|
||||
subscribeToOffsetChange(listener: Listener): Unsubscribe;
|
||||
canDragSource(sourceId: Identifier | undefined): boolean;
|
||||
canDropOnTarget(targetId: Identifier | undefined): boolean;
|
||||
/**
|
||||
* Returns true if a drag operation is in progress, and either the owner initiated the drag, or its isDragging()
|
||||
* is defined and returns true.
|
||||
*/
|
||||
isDragging(): boolean;
|
||||
isDraggingSource(sourceId: Identifier | undefined): boolean;
|
||||
isOverTarget(targetId: Identifier | undefined, options?: {
|
||||
shallow?: boolean;
|
||||
}): boolean;
|
||||
/**
|
||||
* Returns a string or a symbol identifying the type of the current dragged item. Returns null if no item is being dragged.
|
||||
*/
|
||||
getItemType(): Identifier | null;
|
||||
/**
|
||||
* Returns a plain object representing the currently dragged item. Every drag source must specify it by returning an object
|
||||
* from its beginDrag() method. Returns null if no item is being dragged.
|
||||
*/
|
||||
getItem(): any;
|
||||
getSourceId(): Identifier | null;
|
||||
getTargetIds(): Identifier[];
|
||||
/**
|
||||
* Returns a plain object representing the last recorded drop result. The drop targets may optionally specify it by returning an
|
||||
* object from their drop() methods. When a chain of drop() is dispatched for the nested targets, bottom up, any parent that
|
||||
* explicitly returns its own result from drop() overrides the child drop result previously set by the child. Returns null if
|
||||
* called outside endDrag().
|
||||
*/
|
||||
getDropResult(): any;
|
||||
/**
|
||||
* Returns true if some drop target has handled the drop event, false otherwise. Even if a target did not return a drop result,
|
||||
* didDrop() returns true. Use it inside endDrag() to test whether any drop target has handled the drop. Returns false if called
|
||||
* outside endDrag().
|
||||
*/
|
||||
didDrop(): boolean;
|
||||
isSourcePublic(): boolean | null;
|
||||
/**
|
||||
* Returns the { x, y } client offset of the pointer at the time when the current drag operation has started.
|
||||
* Returns null if no item is being dragged.
|
||||
*/
|
||||
getInitialClientOffset(): XYCoord | null;
|
||||
/**
|
||||
* Returns the { x, y } client offset of the drag source component's root DOM node at the time when the current drag
|
||||
* operation has started. Returns null if no item is being dragged.
|
||||
*/
|
||||
getInitialSourceClientOffset(): XYCoord | null;
|
||||
/**
|
||||
* Returns the last recorded { x, y } client offset of the pointer while a drag operation is in progress.
|
||||
* Returns null if no item is being dragged.
|
||||
*/
|
||||
getClientOffset(): XYCoord | null;
|
||||
/**
|
||||
* Returns the projected { x, y } client offset of the drag source component's root DOM node, based on its position at the time
|
||||
* when the current drag operation has started, and the movement difference. Returns null if no item is being dragged.
|
||||
*/
|
||||
getSourceClientOffset(): XYCoord | null;
|
||||
/**
|
||||
* Returns the { x, y } difference between the last recorded client offset of the pointer and the client offset when the current
|
||||
* drag operation has started. Returns null if no item is being dragged.
|
||||
*/
|
||||
getDifferenceFromInitialOffset(): XYCoord | null;
|
||||
}
|
||||
export interface HandlerRegistry {
|
||||
addSource(type: SourceType, source: DragSource): Identifier;
|
||||
addTarget(type: TargetType, target: DropTarget): Identifier;
|
||||
containsHandler(handler: DragSource | DropTarget): boolean;
|
||||
getSource(sourceId: Identifier, includePinned?: boolean): DragSource;
|
||||
getSourceType(sourceId: Identifier): SourceType;
|
||||
getTargetType(targetId: Identifier): TargetType;
|
||||
getTarget(targetId: Identifier): DropTarget;
|
||||
isSourceId(handlerId: Identifier): boolean;
|
||||
isTargetId(handlerId: Identifier): boolean;
|
||||
removeSource(sourceId: Identifier): void;
|
||||
removeTarget(targetId: Identifier): void;
|
||||
pinSource(sourceId: Identifier): void;
|
||||
unpinSource(): void;
|
||||
}
|
||||
export interface Action<Payload> {
|
||||
type: Identifier;
|
||||
payload: Payload;
|
||||
}
|
||||
export interface SentinelAction {
|
||||
type: Identifier;
|
||||
}
|
||||
export declare type ActionCreator<Payload> = (args: any[]) => Action<Payload>;
|
||||
export interface BeginDragOptions {
|
||||
publishSource?: boolean;
|
||||
clientOffset?: XYCoord;
|
||||
getSourceClientOffset?: (sourceId: Identifier) => XYCoord;
|
||||
}
|
||||
export interface InitCoordsPayload {
|
||||
clientOffset: XYCoord | null;
|
||||
sourceClientOffset: XYCoord | null;
|
||||
}
|
||||
export interface BeginDragPayload {
|
||||
itemType: Identifier;
|
||||
item: any;
|
||||
sourceId: Identifier;
|
||||
clientOffset: XYCoord | null;
|
||||
sourceClientOffset: XYCoord | null;
|
||||
isSourcePublic: boolean;
|
||||
}
|
||||
export interface HoverPayload {
|
||||
targetIds: Identifier[];
|
||||
clientOffset: XYCoord | null;
|
||||
}
|
||||
export interface HoverOptions {
|
||||
clientOffset?: XYCoord;
|
||||
}
|
||||
export interface DropPayload {
|
||||
dropResult: any;
|
||||
}
|
||||
export interface TargetIdPayload {
|
||||
targetId: Identifier;
|
||||
}
|
||||
export interface SourceIdPayload {
|
||||
sourceId: Identifier;
|
||||
}
|
||||
export interface DragDropActions {
|
||||
beginDrag(sourceIds?: Identifier[], options?: any): Action<BeginDragPayload> | undefined;
|
||||
publishDragSource(): SentinelAction | undefined;
|
||||
hover(targetIds: Identifier[], options?: any): Action<HoverPayload>;
|
||||
drop(options?: any): void;
|
||||
endDrag(): SentinelAction;
|
||||
}
|
||||
export interface DragDropManager {
|
||||
getMonitor(): DragDropMonitor;
|
||||
getBackend(): Backend;
|
||||
getRegistry(): HandlerRegistry;
|
||||
getActions(): DragDropActions;
|
||||
dispatch(action: any): void;
|
||||
}
|
||||
export declare type BackendFactory = (manager: DragDropManager, globalContext?: any, configuration?: any) => Backend;
|
||||
export interface DragSource {
|
||||
beginDrag(monitor: DragDropMonitor, targetId: Identifier): void;
|
||||
endDrag(monitor: DragDropMonitor, targetId: Identifier): void;
|
||||
canDrag(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
||||
isDragging(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
||||
}
|
||||
export interface DropTarget {
|
||||
canDrop(monitor: DragDropMonitor, targetId: Identifier): boolean;
|
||||
hover(monitor: DragDropMonitor, targetId: Identifier): void;
|
||||
drop(monitor: DragDropMonitor, targetId: Identifier): any;
|
||||
}
|
||||
7
node_modules/dnd-core/dist/types/reducers/dirtyHandlerIds.d.ts
generated
vendored
Normal file
7
node_modules/dnd-core/dist/types/reducers/dirtyHandlerIds.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Action } from '../interfaces';
|
||||
export declare type State = string[];
|
||||
export interface DirtyHandlerIdPayload {
|
||||
targetIds: string[];
|
||||
prevTargetIds: string[];
|
||||
}
|
||||
export declare function reduce(_state: State | undefined, action: Action<DirtyHandlerIdPayload>): State;
|
||||
10
node_modules/dnd-core/dist/types/reducers/dragOffset.d.ts
generated
vendored
Normal file
10
node_modules/dnd-core/dist/types/reducers/dragOffset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { XYCoord, Action } from '../interfaces';
|
||||
export interface State {
|
||||
initialSourceClientOffset: XYCoord | null;
|
||||
initialClientOffset: XYCoord | null;
|
||||
clientOffset: XYCoord | null;
|
||||
}
|
||||
export declare function reduce(state: State | undefined, action: Action<{
|
||||
sourceClientOffset: XYCoord;
|
||||
clientOffset: XYCoord;
|
||||
}>): State;
|
||||
19
node_modules/dnd-core/dist/types/reducers/dragOperation.d.ts
generated
vendored
Normal file
19
node_modules/dnd-core/dist/types/reducers/dragOperation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Identifier, Action } from '../interfaces';
|
||||
export interface State {
|
||||
itemType: Identifier | Identifier[] | null;
|
||||
item: any;
|
||||
sourceId: string | null;
|
||||
targetIds: string[];
|
||||
dropResult: any;
|
||||
didDrop: boolean;
|
||||
isSourcePublic: boolean | null;
|
||||
}
|
||||
export declare function reduce(state: State | undefined, action: Action<{
|
||||
itemType: Identifier | Identifier[];
|
||||
item: any;
|
||||
sourceId: string;
|
||||
targetId: string;
|
||||
targetIds: string[];
|
||||
isSourcePublic: boolean;
|
||||
dropResult: any;
|
||||
}>): State;
|
||||
14
node_modules/dnd-core/dist/types/reducers/index.d.ts
generated
vendored
Normal file
14
node_modules/dnd-core/dist/types/reducers/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { State as DragOffsetState } from './dragOffset';
|
||||
import { State as DragOperationState } from './dragOperation';
|
||||
import { State as RefCountState } from './refCount';
|
||||
import { State as DirtyHandlerIdsState } from './dirtyHandlerIds';
|
||||
import { State as StateIdState } from './stateId';
|
||||
import { Action } from '../interfaces';
|
||||
export interface State {
|
||||
dirtyHandlerIds: DirtyHandlerIdsState;
|
||||
dragOffset: DragOffsetState;
|
||||
refCount: RefCountState;
|
||||
dragOperation: DragOperationState;
|
||||
stateId: StateIdState;
|
||||
}
|
||||
export declare function reduce(state: State | undefined, action: Action<any>): State;
|
||||
3
node_modules/dnd-core/dist/types/reducers/refCount.d.ts
generated
vendored
Normal file
3
node_modules/dnd-core/dist/types/reducers/refCount.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Action } from '../interfaces';
|
||||
export declare type State = number;
|
||||
export declare function reduce(state: number | undefined, action: Action<any>): State;
|
||||
2
node_modules/dnd-core/dist/types/reducers/stateId.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/reducers/stateId.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare type State = number;
|
||||
export declare function reduce(state?: State): State;
|
||||
29
node_modules/dnd-core/dist/types/utils/coords.d.ts
generated
vendored
Normal file
29
node_modules/dnd-core/dist/types/utils/coords.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { State } from '../reducers/dragOffset';
|
||||
import { XYCoord } from '..';
|
||||
/**
|
||||
* Coordinate addition
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
export declare function add(a: XYCoord, b: XYCoord): XYCoord;
|
||||
/**
|
||||
* Coordinate subtraction
|
||||
* @param a The first coordinate
|
||||
* @param b The second coordinate
|
||||
*/
|
||||
export declare function subtract(a: XYCoord, b: XYCoord): XYCoord;
|
||||
/**
|
||||
* Returns the cartesian distance of the drag source component's position, based on its position
|
||||
* at the time when the current drag operation has started, and the movement difference.
|
||||
*
|
||||
* Returns null if no item is being dragged.
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
export declare function getSourceClientOffset(state: State): XYCoord | null;
|
||||
/**
|
||||
* Determines the x,y offset between the client offset and the initial client offset
|
||||
*
|
||||
* @param state The offset state to compute from
|
||||
*/
|
||||
export declare function getDifferenceFromInitialOffset(state: State): XYCoord | null;
|
||||
9
node_modules/dnd-core/dist/types/utils/dirtiness.d.ts
generated
vendored
Normal file
9
node_modules/dnd-core/dist/types/utils/dirtiness.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare const NONE: string[];
|
||||
export declare const ALL: string[];
|
||||
/**
|
||||
* Determines if the given handler IDs are dirty or not.
|
||||
*
|
||||
* @param dirtyIds The set of dirty handler ids
|
||||
* @param handlerIds The set of handler ids to check
|
||||
*/
|
||||
export declare function areDirty(dirtyIds: string[], handlerIds: string[] | undefined): boolean;
|
||||
15
node_modules/dnd-core/dist/types/utils/equality.d.ts
generated
vendored
Normal file
15
node_modules/dnd-core/dist/types/utils/equality.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { XYCoord } from '../interfaces';
|
||||
export declare type EqualityCheck<T> = (a: T, b: T) => boolean;
|
||||
export declare const strictEquality: <T>(a: T, b: T) => boolean;
|
||||
/**
|
||||
* Determine if two cartesian coordinate offsets are equal
|
||||
* @param offsetA
|
||||
* @param offsetB
|
||||
*/
|
||||
export declare function areCoordsEqual(offsetA: XYCoord | null | undefined, offsetB: XYCoord | null | undefined): boolean;
|
||||
/**
|
||||
* Determines if two arrays of items are equal
|
||||
* @param a The first array of items
|
||||
* @param b The second array of items
|
||||
*/
|
||||
export declare function areArraysEqual<T>(a: T[], b: T[], isEqual?: EqualityCheck<T>): boolean;
|
||||
1
node_modules/dnd-core/dist/types/utils/getNextUniqueId.d.ts
generated
vendored
Normal file
1
node_modules/dnd-core/dist/types/utils/getNextUniqueId.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function getNextUniqueId(): number;
|
||||
33
node_modules/dnd-core/dist/types/utils/js_utils.d.ts
generated
vendored
Normal file
33
node_modules/dnd-core/dist/types/utils/js_utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* drop-in replacement for _.get
|
||||
* @param obj
|
||||
* @param path
|
||||
* @param defaultValue
|
||||
*/
|
||||
export declare function get<T>(obj: any, path: string, defaultValue: T): T;
|
||||
/**
|
||||
* drop-in replacement for _.without
|
||||
*/
|
||||
export declare function without<T>(items: T[], item: T): T[];
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
export declare function isString(input: any): boolean;
|
||||
/**
|
||||
* drop-in replacement for _.isString
|
||||
* @param input
|
||||
*/
|
||||
export declare function isObject(input: any): boolean;
|
||||
/**
|
||||
* repalcement for _.xor
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
export declare function xor<T extends string | number>(itemsA: T[], itemsB: T[]): T[];
|
||||
/**
|
||||
* replacement for _.intersection
|
||||
* @param itemsA
|
||||
* @param itemsB
|
||||
*/
|
||||
export declare function intersection<T>(itemsA: T[], itemsB: T[]): T[];
|
||||
2
node_modules/dnd-core/dist/types/utils/matchesType.d.ts
generated
vendored
Normal file
2
node_modules/dnd-core/dist/types/utils/matchesType.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Identifier } from '../interfaces';
|
||||
export declare function matchesType(targetType: Identifier | Identifier[] | null, draggedItemType: Identifier | null): boolean;
|
||||
Reference in New Issue
Block a user