Files
coopgo/node_modules/react-dnd/dist/esm/hooks/useDrag/DragSourceImpl.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

84 lines
3.0 KiB
JavaScript

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 _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; }
export var DragSourceImpl = /*#__PURE__*/function () {
function DragSourceImpl(spec, monitor, connector) {
_classCallCheck(this, DragSourceImpl);
_defineProperty(this, "spec", void 0);
_defineProperty(this, "monitor", void 0);
_defineProperty(this, "connector", void 0);
this.spec = spec;
this.monitor = monitor;
this.connector = connector;
}
_createClass(DragSourceImpl, [{
key: "beginDrag",
value: function beginDrag() {
var _result;
var spec = this.spec;
var monitor = this.monitor;
var result = null;
if (_typeof(spec.item) === 'object') {
result = spec.item;
} else if (typeof spec.item === 'function') {
result = spec.item(monitor);
} else {
result = {};
}
return (_result = result) !== null && _result !== void 0 ? _result : null;
}
}, {
key: "canDrag",
value: function canDrag() {
var spec = this.spec;
var monitor = this.monitor;
if (typeof spec.canDrag === 'boolean') {
return spec.canDrag;
} else if (typeof spec.canDrag === 'function') {
return spec.canDrag(monitor);
} else {
return true;
}
}
}, {
key: "isDragging",
value: function isDragging(globalMonitor, target) {
var spec = this.spec;
var monitor = this.monitor;
var isDragging = spec.isDragging;
return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
}
}, {
key: "endDrag",
value: function endDrag() {
var spec = this.spec;
var monitor = this.monitor;
var connector = this.connector;
var end = spec.end;
if (end) {
end(monitor.getItem(), monitor);
}
connector.reconnect();
}
}]);
return DragSourceImpl;
}();