Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/dnd-core/dist/esm/actions/dragDrop/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 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 default 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) {
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);
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;
} |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0049 ]-- |