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/lib/actions/dragDrop/ drwxr-xr-x | |
| Viewing file: Select action/file-type: import { invariant } from '@react-dnd/invariant';
import matchesType from '../../utils/matchesType';
import { HOVER } from './types';
export default function createHover(manager) {
return function hover(targetIdsArg, { clientOffset } = {}) {
verifyTargetIdsIsArray(targetIdsArg);
const targetIds = targetIdsArg.slice(0);
const monitor = manager.getMonitor();
const registry = manager.getRegistry();
checkInvariants(targetIds, monitor, registry);
const draggedItemType = monitor.getItemType();
removeNonMatchingTargetIds(targetIds, registry, draggedItemType);
hoverAllTargets(targetIds, monitor, registry);
return {
type: HOVER,
payload: {
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 (let i = 0; i < targetIds.length; i++) {
const targetId = targetIds[i];
invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.');
const 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 (let i = targetIds.length - 1; i >= 0; i--) {
const targetId = targetIds[i];
const 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) {
const target = registry.getTarget(targetId);
target.hover(monitor, targetId);
});
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0387 ]-- |