| Current Path : /home/emeraadmin/www/4d695/ |
| Current File : /home/emeraadmin/www/4d695/react-dnd-html5-backend.zip |
PK H[�\�(| | package.jsonnu �[��� {
"_from": "react-dnd-html5-backend@^11.1.3",
"_id": "react-dnd-html5-backend@11.1.3",
"_inBundle": false,
"_integrity": "sha512-/1FjNlJbW/ivkUxlxQd7o3trA5DE33QiRZgxent3zKme8DwF4Nbw3OFVhTRFGaYhHFNL1rZt6Rdj1D78BjnNLw==",
"_location": "/react-dnd-html5-backend",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "react-dnd-html5-backend@^11.1.3",
"name": "react-dnd-html5-backend",
"escapedName": "react-dnd-html5-backend",
"rawSpec": "^11.1.3",
"saveSpec": null,
"fetchSpec": "^11.1.3"
},
"_requiredBy": [
"/mui-datatables",
"/react-sortable-tree-patch-react-17"
],
"_resolved": "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-11.1.3.tgz",
"_shasum": "2749f04f416ec230ea193f5c1fbea2de7dffb8f7",
"_spec": "react-dnd-html5-backend@^11.1.3",
"_where": "C:\\xampp\\htdocs\\emeraltd\\node_modules\\mui-datatables",
"bugs": {
"url": "https://github.com/react-dnd/react-dnd/issues"
},
"bundleDependencies": false,
"dependencies": {
"dnd-core": "^11.1.3"
},
"deprecated": false,
"description": "HTML5 backend for React DnD",
"devDependencies": {
"@types/react": "^16.9.35",
"react": "^16.12.0",
"react-dnd-test-backend": "^11.1.3",
"react-dom": "^16.12.0"
},
"gitHead": "32f16c09f0e8560c2a439f3a7fc2e0e8aec3b973",
"homepage": "https://github.com/react-dnd/react-dnd#readme",
"license": "MIT",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"name": "react-dnd-html5-backend",
"repository": {
"type": "git",
"url": "git+https://github.com/react-dnd/react-dnd.git"
},
"scripts": {
"build": "../../../scripts/build_package.sh",
"clean": "../../../scripts/clean_package.sh",
"start": "../../../scripts/watch_package.sh"
},
"sideEffects": false,
"types": "lib/index.d.ts",
"version": "11.1.3"
}
PK H[�\n�� � lib/OptionsReader.jsnu �[��� export class OptionsReader {
constructor(globalContext) {
this.globalContext = globalContext;
}
get window() {
if (this.globalContext) {
return this.globalContext;
}
else if (typeof window !== 'undefined') {
return window;
}
return undefined;
}
get document() {
if (this.window) {
return this.window.document;
}
return undefined;
}
}
PK H[�\�g� � 0 lib/NativeDragSources/getDataFromDataTransfer.jsnu �[��� export function getDataFromDataTransfer(dataTransfer, typesToTry, defaultValue) {
const result = typesToTry.reduce((resultSoFar, typeToTry) => resultSoFar || dataTransfer.getData(typeToTry), '');
return result != null ? result : defaultValue;
}
PK H[�\�0�� � 2 lib/NativeDragSources/getDataFromDataTransfer.d.tsnu �[��� export declare function getDataFromDataTransfer(dataTransfer: DataTransfer, typesToTry: string[], defaultValue: string): string;
PK H[�\v ƽW W , lib/NativeDragSources/nativeTypesConfig.d.tsnu �[��� export interface NativeItemConfigExposePropreties {
[property: string]: (dataTransfer: DataTransfer, matchesTypes: string[]) => any;
}
export interface NativeItemConfig {
exposeProperties: NativeItemConfigExposePropreties;
matchesTypes: string[];
}
export declare const nativeTypesConfig: {
[key: string]: NativeItemConfig;
};
PK H[�\G5�� � lib/NativeDragSources/index.jsnu �[��� import { nativeTypesConfig } from './nativeTypesConfig';
import { NativeDragSource } from './NativeDragSource';
export function createNativeDragSource(type, dataTransfer) {
const result = new NativeDragSource(nativeTypesConfig[type]);
result.loadDataTransfer(dataTransfer);
return result;
}
export function matchNativeItemType(dataTransfer) {
if (!dataTransfer) {
return null;
}
const dataTransferTypes = Array.prototype.slice.call(dataTransfer.types || []);
return (Object.keys(nativeTypesConfig).filter((nativeItemType) => {
const { matchesTypes } = nativeTypesConfig[nativeItemType];
return matchesTypes.some((t) => dataTransferTypes.indexOf(t) > -1);
})[0] || null);
}
PK H[�\Ë8� � ) lib/NativeDragSources/NativeDragSource.jsnu �[��� export class NativeDragSource {
constructor(config) {
this.config = config;
this.item = {};
this.initializeExposedProperties();
}
initializeExposedProperties() {
Object.keys(this.config.exposeProperties).forEach((property) => {
Object.defineProperty(this.item, property, {
configurable: true,
enumerable: true,
get() {
// eslint-disable-next-line no-console
console.warn(`Browser doesn't allow reading "${property}" until the drop event.`);
return null;
},
});
});
}
loadDataTransfer(dataTransfer) {
if (dataTransfer) {
const newProperties = {};
Object.keys(this.config.exposeProperties).forEach((property) => {
newProperties[property] = {
value: this.config.exposeProperties[property](dataTransfer, this.config.matchesTypes),
configurable: true,
enumerable: true,
};
});
Object.defineProperties(this.item, newProperties);
}
}
canDrag() {
return true;
}
beginDrag() {
return this.item;
}
isDragging(monitor, handle) {
return handle === monitor.getSourceId();
}
endDrag() {
// empty
}
}
PK H[�\!���` ` * lib/NativeDragSources/nativeTypesConfig.jsnu �[��� import * as NativeTypes from '../NativeTypes';
import { getDataFromDataTransfer } from './getDataFromDataTransfer';
export const nativeTypesConfig = {
[NativeTypes.FILE]: {
exposeProperties: {
files: (dataTransfer) => Array.prototype.slice.call(dataTransfer.files),
items: (dataTransfer) => dataTransfer.items,
},
matchesTypes: ['Files'],
},
[NativeTypes.URL]: {
exposeProperties: {
urls: (dataTransfer, matchesTypes) => getDataFromDataTransfer(dataTransfer, matchesTypes, '').split('\n'),
},
matchesTypes: ['Url', 'text/uri-list'],
},
[NativeTypes.TEXT]: {
exposeProperties: {
text: (dataTransfer, matchesTypes) => getDataFromDataTransfer(dataTransfer, matchesTypes, ''),
},
matchesTypes: ['Text', 'text/plain'],
},
};
PK H[�\�s
� lib/NativeDragSources/index.d.tsnu �[��� import { NativeDragSource } from './NativeDragSource';
export declare function createNativeDragSource(type: string, dataTransfer?: DataTransfer): NativeDragSource;
export declare function matchNativeItemType(dataTransfer: DataTransfer | null): string | null;
PK H[�\:ʕg� � + lib/NativeDragSources/NativeDragSource.d.tsnu �[��� import { NativeItemConfig } from './nativeTypesConfig';
import { DragDropMonitor } from 'dnd-core';
export declare class NativeDragSource {
item: any;
private config;
constructor(config: NativeItemConfig);
private initializeExposedProperties;
loadDataTransfer(dataTransfer: DataTransfer | null | undefined): void;
canDrag(): boolean;
beginDrag(): any;
isDragging(monitor: DragDropMonitor, handle: string): boolean;
endDrag(): void;
}
PK H[�\ lib/types.jsnu �[��� PK H[�\7):�R R lib/EnterLeaveCounter.jsnu �[��� import { union, without } from './utils/js_utils';
export class EnterLeaveCounter {
constructor(isNodeInDocument) {
this.entered = [];
this.isNodeInDocument = isNodeInDocument;
}
enter(enteringNode) {
const previousLength = this.entered.length;
const isNodeEntered = (node) => this.isNodeInDocument(node) &&
(!node.contains || node.contains(enteringNode));
this.entered = union(this.entered.filter(isNodeEntered), [enteringNode]);
return previousLength === 0 && this.entered.length > 0;
}
leave(leavingNode) {
const previousLength = this.entered.length;
this.entered = without(this.entered.filter(this.isNodeInDocument), leavingNode);
return previousLength > 0 && this.entered.length === 0;
}
reset() {
this.entered = [];
}
}
PK H[�\iH��� � lib/MonotonicInterpolant.d.tsnu �[��� export declare class MonotonicInterpolant {
private xs;
private ys;
private c1s;
private c2s;
private c3s;
constructor(xs: number[], ys: number[]);
interpolate(x: number): number;
}
PK H[�\���Z� � lib/utils/js_utils.d.tsnu �[��� export declare function memoize<T>(fn: () => T): () => T;
/**
* drop-in replacement for _.without
*/
export declare function without<T>(items: T[], item: T): T[];
export declare function union<T extends string | number>(itemsA: T[], itemsB: T[]): T[];
PK H[�\?V�$p p lib/utils/js_utils.jsnu �[��� // cheap lodash replacements
export function memoize(fn) {
let result = null;
const memoized = () => {
if (result == null) {
result = fn();
}
return result;
};
return memoized;
}
/**
* drop-in replacement for _.without
*/
export function without(items, item) {
return items.filter(i => i !== item);
}
export function union(itemsA, itemsB) {
const set = new Set();
const insertItem = (item) => set.add(item);
itemsA.forEach(insertItem);
itemsB.forEach(insertItem);
const result = [];
set.forEach(key => result.push(key));
return result;
}
PK H[�\�@�V V lib/HTML5BackendImpl.jsnu �[��� import { EnterLeaveCounter } from './EnterLeaveCounter';
import { isFirefox } from './BrowserDetector';
import { getNodeClientOffset, getEventClientOffset, getDragPreviewOffset, } from './OffsetUtils';
import { createNativeDragSource, matchNativeItemType, } from './NativeDragSources';
import * as NativeTypes from './NativeTypes';
import { OptionsReader } from './OptionsReader';
export class HTML5BackendImpl {
constructor(manager, globalContext) {
this.sourcePreviewNodes = new Map();
this.sourcePreviewNodeOptions = new Map();
this.sourceNodes = new Map();
this.sourceNodeOptions = new Map();
this.dragStartSourceIds = null;
this.dropTargetIds = [];
this.dragEnterTargetIds = [];
this.currentNativeSource = null;
this.currentNativeHandle = null;
this.currentDragSourceNode = null;
this.altKeyPressed = false;
this.mouseMoveTimeoutTimer = null;
this.asyncEndDragFrameId = null;
this.dragOverTargetIds = null;
this.getSourceClientOffset = (sourceId) => {
const source = this.sourceNodes.get(sourceId);
return (source && getNodeClientOffset(source)) || null;
};
this.endDragNativeItem = () => {
if (!this.isDraggingNativeItem()) {
return;
}
this.actions.endDrag();
if (this.currentNativeHandle) {
this.registry.removeSource(this.currentNativeHandle);
}
this.currentNativeHandle = null;
this.currentNativeSource = null;
};
this.isNodeInDocument = (node) => {
// Check the node either in the main document or in the current context
return Boolean(node &&
this.document &&
this.document.body &&
document.body.contains(node));
};
this.endDragIfSourceWasRemovedFromDOM = () => {
const node = this.currentDragSourceNode;
if (this.isNodeInDocument(node)) {
return;
}
if (this.clearCurrentDragSourceNode()) {
this.actions.endDrag();
}
};
this.handleTopDragStartCapture = () => {
this.clearCurrentDragSourceNode();
this.dragStartSourceIds = [];
};
this.handleTopDragStart = (e) => {
if (e.defaultPrevented) {
return;
}
const { dragStartSourceIds } = this;
this.dragStartSourceIds = null;
const clientOffset = getEventClientOffset(e);
// Avoid crashing if we missed a drop event or our previous drag died
if (this.monitor.isDragging()) {
this.actions.endDrag();
}
// Don't publish the source just yet (see why below)
this.actions.beginDrag(dragStartSourceIds || [], {
publishSource: false,
getSourceClientOffset: this.getSourceClientOffset,
clientOffset,
});
const { dataTransfer } = e;
const nativeType = matchNativeItemType(dataTransfer);
if (this.monitor.isDragging()) {
if (dataTransfer && typeof dataTransfer.setDragImage === 'function') {
// Use custom drag image if user specifies it.
// If child drag source refuses drag but parent agrees,
// use parent's node as drag image. Neither works in IE though.
const sourceId = this.monitor.getSourceId();
const sourceNode = this.sourceNodes.get(sourceId);
const dragPreview = this.sourcePreviewNodes.get(sourceId) || sourceNode;
if (dragPreview) {
const { anchorX, anchorY, offsetX, offsetY, } = this.getCurrentSourcePreviewNodeOptions();
const anchorPoint = { anchorX, anchorY };
const offsetPoint = { offsetX, offsetY };
const dragPreviewOffset = getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint);
dataTransfer.setDragImage(dragPreview, dragPreviewOffset.x, dragPreviewOffset.y);
}
}
try {
// Firefox won't drag without setting data
dataTransfer?.setData('application/json', {});
}
catch (err) {
// IE doesn't support MIME types in setData
}
// Store drag source node so we can check whether
// it is removed from DOM and trigger endDrag manually.
this.setCurrentDragSourceNode(e.target);
// Now we are ready to publish the drag source.. or are we not?
const { captureDraggingState } = this.getCurrentSourcePreviewNodeOptions();
if (!captureDraggingState) {
// Usually we want to publish it in the next tick so that browser
// is able to screenshot the current (not yet dragging) state.
//
// It also neatly avoids a situation where render() returns null
// in the same tick for the source element, and browser freaks out.
setTimeout(() => this.actions.publishDragSource(), 0);
}
else {
// In some cases the user may want to override this behavior, e.g.
// to work around IE not supporting custom drag previews.
//
// When using a custom drag layer, the only way to prevent
// the default drag preview from drawing in IE is to screenshot
// the dragging state in which the node itself has zero opacity
// and height. In this case, though, returning null from render()
// will abruptly end the dragging, which is not obvious.
//
// This is the reason such behavior is strictly opt-in.
this.actions.publishDragSource();
}
}
else if (nativeType) {
// A native item (such as URL) dragged from inside the document
this.beginDragNativeItem(nativeType);
}
else if (dataTransfer &&
!dataTransfer.types &&
((e.target && !e.target.hasAttribute) ||
!e.target.hasAttribute('draggable'))) {
// Looks like a Safari bug: dataTransfer.types is null, but there was no draggable.
// Just let it drag. It's a native type (URL or text) and will be picked up in
// dragenter handler.
return;
}
else {
// If by this time no drag source reacted, tell browser not to drag.
e.preventDefault();
}
};
this.handleTopDragEndCapture = () => {
if (this.clearCurrentDragSourceNode()) {
// Firefox can dispatch this event in an infinite loop
// if dragend handler does something like showing an alert.
// Only proceed if we have not handled it already.
this.actions.endDrag();
}
};
this.handleTopDragEnterCapture = (e) => {
this.dragEnterTargetIds = [];
const isFirstEnter = this.enterLeaveCounter.enter(e.target);
if (!isFirstEnter || this.monitor.isDragging()) {
return;
}
const { dataTransfer } = e;
const nativeType = matchNativeItemType(dataTransfer);
if (nativeType) {
// A native item (such as file or URL) dragged from outside the document
this.beginDragNativeItem(nativeType, dataTransfer);
}
};
this.handleTopDragEnter = (e) => {
const { dragEnterTargetIds } = this;
this.dragEnterTargetIds = [];
if (!this.monitor.isDragging()) {
// This is probably a native item type we don't understand.
return;
}
this.altKeyPressed = e.altKey;
if (!isFirefox()) {
// Don't emit hover in `dragenter` on Firefox due to an edge case.
// If the target changes position as the result of `dragenter`, Firefox
// will still happily dispatch `dragover` despite target being no longer
// there. The easy solution is to only fire `hover` in `dragover` on FF.
this.actions.hover(dragEnterTargetIds, {
clientOffset: getEventClientOffset(e),
});
}
const canDrop = dragEnterTargetIds.some((targetId) => this.monitor.canDropOnTarget(targetId));
if (canDrop) {
// IE requires this to fire dragover events
e.preventDefault();
if (e.dataTransfer) {
e.dataTransfer.dropEffect = this.getCurrentDropEffect();
}
}
};
this.handleTopDragOverCapture = () => {
this.dragOverTargetIds = [];
};
this.handleTopDragOver = (e) => {
const { dragOverTargetIds } = this;
this.dragOverTargetIds = [];
if (!this.monitor.isDragging()) {
// This is probably a native item type we don't understand.
// Prevent default "drop and blow away the whole document" action.
e.preventDefault();
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'none';
}
return;
}
this.altKeyPressed = e.altKey;
this.actions.hover(dragOverTargetIds || [], {
clientOffset: getEventClientOffset(e),
});
const canDrop = (dragOverTargetIds || []).some((targetId) => this.monitor.canDropOnTarget(targetId));
if (canDrop) {
// Show user-specified drop effect.
e.preventDefault();
if (e.dataTransfer) {
e.dataTransfer.dropEffect = this.getCurrentDropEffect();
}
}
else if (this.isDraggingNativeItem()) {
// Don't show a nice cursor but still prevent default
// "drop and blow away the whole document" action.
e.preventDefault();
}
else {
e.preventDefault();
if (e.dataTransfer) {
e.dataTransfer.dropEffect = 'none';
}
}
};
this.handleTopDragLeaveCapture = (e) => {
if (this.isDraggingNativeItem()) {
e.preventDefault();
}
const isLastLeave = this.enterLeaveCounter.leave(e.target);
if (!isLastLeave) {
return;
}
if (this.isDraggingNativeItem()) {
this.endDragNativeItem();
}
};
this.handleTopDropCapture = (e) => {
this.dropTargetIds = [];
e.preventDefault();
if (this.isDraggingNativeItem()) {
this.currentNativeSource?.loadDataTransfer(e.dataTransfer);
}
this.enterLeaveCounter.reset();
};
this.handleTopDrop = (e) => {
const { dropTargetIds } = this;
this.dropTargetIds = [];
this.actions.hover(dropTargetIds, {
clientOffset: getEventClientOffset(e),
});
this.actions.drop({ dropEffect: this.getCurrentDropEffect() });
if (this.isDraggingNativeItem()) {
this.endDragNativeItem();
}
else {
this.endDragIfSourceWasRemovedFromDOM();
}
};
this.handleSelectStart = (e) => {
const target = e.target;
// Only IE requires us to explicitly say
// we want drag drop operation to start
if (typeof target.dragDrop !== 'function') {
return;
}
// Inputs and textareas should be selectable
if (target.tagName === 'INPUT' ||
target.tagName === 'SELECT' ||
target.tagName === 'TEXTAREA' ||
target.isContentEditable) {
return;
}
// For other targets, ask IE
// to enable drag and drop
e.preventDefault();
target.dragDrop();
};
this.options = new OptionsReader(globalContext);
this.actions = manager.getActions();
this.monitor = manager.getMonitor();
this.registry = manager.getRegistry();
this.enterLeaveCounter = new EnterLeaveCounter(this.isNodeInDocument);
}
/**
* Generate profiling statistics for the HTML5Backend.
*/
profile() {
return {
sourcePreviewNodes: this.sourcePreviewNodes.size,
sourcePreviewNodeOptions: this.sourcePreviewNodeOptions.size,
sourceNodeOptions: this.sourceNodeOptions.size,
sourceNodes: this.sourceNodes.size,
dragStartSourceIds: this.dragStartSourceIds?.length || 0,
dropTargetIds: this.dropTargetIds.length,
dragEnterTargetIds: this.dragEnterTargetIds.length,
dragOverTargetIds: this.dragOverTargetIds?.length || 0,
};
}
// public for test
get window() {
return this.options.window;
}
get document() {
return this.options.document;
}
setup() {
if (this.window === undefined) {
return;
}
if (this.window.__isReactDndBackendSetUp) {
throw new Error('Cannot have two HTML5 backends at the same time.');
}
this.window.__isReactDndBackendSetUp = true;
this.addEventListeners(this.window);
}
teardown() {
if (this.window === undefined) {
return;
}
this.window.__isReactDndBackendSetUp = false;
this.removeEventListeners(this.window);
this.clearCurrentDragSourceNode();
if (this.asyncEndDragFrameId) {
this.window.cancelAnimationFrame(this.asyncEndDragFrameId);
}
}
connectDragPreview(sourceId, node, options) {
this.sourcePreviewNodeOptions.set(sourceId, options);
this.sourcePreviewNodes.set(sourceId, node);
return () => {
this.sourcePreviewNodes.delete(sourceId);
this.sourcePreviewNodeOptions.delete(sourceId);
};
}
connectDragSource(sourceId, node, options) {
this.sourceNodes.set(sourceId, node);
this.sourceNodeOptions.set(sourceId, options);
const handleDragStart = (e) => this.handleDragStart(e, sourceId);
const handleSelectStart = (e) => this.handleSelectStart(e);
node.setAttribute('draggable', 'true');
node.addEventListener('dragstart', handleDragStart);
node.addEventListener('selectstart', handleSelectStart);
return () => {
this.sourceNodes.delete(sourceId);
this.sourceNodeOptions.delete(sourceId);
node.removeEventListener('dragstart', handleDragStart);
node.removeEventListener('selectstart', handleSelectStart);
node.setAttribute('draggable', 'false');
};
}
connectDropTarget(targetId, node) {
const handleDragEnter = (e) => this.handleDragEnter(e, targetId);
const handleDragOver = (e) => this.handleDragOver(e, targetId);
const handleDrop = (e) => this.handleDrop(e, targetId);
node.addEventListener('dragenter', handleDragEnter);
node.addEventListener('dragover', handleDragOver);
node.addEventListener('drop', handleDrop);
return () => {
node.removeEventListener('dragenter', handleDragEnter);
node.removeEventListener('dragover', handleDragOver);
node.removeEventListener('drop', handleDrop);
};
}
addEventListeners(target) {
// SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
if (!target.addEventListener) {
return;
}
target.addEventListener('dragstart', this.handleTopDragStart);
target.addEventListener('dragstart', this.handleTopDragStartCapture, true);
target.addEventListener('dragend', this.handleTopDragEndCapture, true);
target.addEventListener('dragenter', this.handleTopDragEnter);
target.addEventListener('dragenter', this.handleTopDragEnterCapture, true);
target.addEventListener('dragleave', this.handleTopDragLeaveCapture, true);
target.addEventListener('dragover', this.handleTopDragOver);
target.addEventListener('dragover', this.handleTopDragOverCapture, true);
target.addEventListener('drop', this.handleTopDrop);
target.addEventListener('drop', this.handleTopDropCapture, true);
}
removeEventListeners(target) {
// SSR Fix (https://github.com/react-dnd/react-dnd/pull/813
if (!target.removeEventListener) {
return;
}
target.removeEventListener('dragstart', this.handleTopDragStart);
target.removeEventListener('dragstart', this.handleTopDragStartCapture, true);
target.removeEventListener('dragend', this.handleTopDragEndCapture, true);
target.removeEventListener('dragenter', this.handleTopDragEnter);
target.removeEventListener('dragenter', this.handleTopDragEnterCapture, true);
target.removeEventListener('dragleave', this.handleTopDragLeaveCapture, true);
target.removeEventListener('dragover', this.handleTopDragOver);
target.removeEventListener('dragover', this.handleTopDragOverCapture, true);
target.removeEventListener('drop', this.handleTopDrop);
target.removeEventListener('drop', this.handleTopDropCapture, true);
}
getCurrentSourceNodeOptions() {
const sourceId = this.monitor.getSourceId();
const sourceNodeOptions = this.sourceNodeOptions.get(sourceId);
return {
dropEffect: this.altKeyPressed ? 'copy' : 'move',
...(sourceNodeOptions || {}),
};
}
getCurrentDropEffect() {
if (this.isDraggingNativeItem()) {
// It makes more sense to default to 'copy' for native resources
return 'copy';
}
return this.getCurrentSourceNodeOptions().dropEffect;
}
getCurrentSourcePreviewNodeOptions() {
const sourceId = this.monitor.getSourceId();
const sourcePreviewNodeOptions = this.sourcePreviewNodeOptions.get(sourceId);
return {
anchorX: 0.5,
anchorY: 0.5,
captureDraggingState: false,
...(sourcePreviewNodeOptions || {}),
};
}
isDraggingNativeItem() {
const itemType = this.monitor.getItemType();
return Object.keys(NativeTypes).some((key) => NativeTypes[key] === itemType);
}
beginDragNativeItem(type, dataTransfer) {
this.clearCurrentDragSourceNode();
this.currentNativeSource = createNativeDragSource(type, dataTransfer);
this.currentNativeHandle = this.registry.addSource(type, this.currentNativeSource);
this.actions.beginDrag([this.currentNativeHandle]);
}
setCurrentDragSourceNode(node) {
this.clearCurrentDragSourceNode();
this.currentDragSourceNode = node;
// A timeout of > 0 is necessary to resolve Firefox issue referenced
// See:
// * https://github.com/react-dnd/react-dnd/pull/928
// * https://github.com/react-dnd/react-dnd/issues/869
const MOUSE_MOVE_TIMEOUT = 1000;
// Receiving a mouse event in the middle of a dragging operation
// means it has ended and the drag source node disappeared from DOM,
// so the browser didn't dispatch the dragend event.
//
// We need to wait before we start listening for mousemove events.
// This is needed because the drag preview needs to be drawn or else it fires an 'mousemove' event
// immediately in some browsers.
//
// See:
// * https://github.com/react-dnd/react-dnd/pull/928
// * https://github.com/react-dnd/react-dnd/issues/869
//
this.mouseMoveTimeoutTimer = setTimeout(() => {
return (this.window &&
this.window.addEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true));
}, MOUSE_MOVE_TIMEOUT);
}
clearCurrentDragSourceNode() {
if (this.currentDragSourceNode) {
this.currentDragSourceNode = null;
if (this.window) {
this.window.clearTimeout(this.mouseMoveTimeoutTimer || undefined);
this.window.removeEventListener('mousemove', this.endDragIfSourceWasRemovedFromDOM, true);
}
this.mouseMoveTimeoutTimer = null;
return true;
}
return false;
}
handleDragStart(e, sourceId) {
if (e.defaultPrevented) {
return;
}
if (!this.dragStartSourceIds) {
this.dragStartSourceIds = [];
}
this.dragStartSourceIds.unshift(sourceId);
}
handleDragEnter(e, targetId) {
this.dragEnterTargetIds.unshift(targetId);
}
handleDragOver(e, targetId) {
if (this.dragOverTargetIds === null) {
this.dragOverTargetIds = [];
}
this.dragOverTargetIds.unshift(targetId);
}
handleDrop(e, targetId) {
this.dropTargetIds.unshift(targetId);
}
}
PK H[�\�2+ + lib/index.jsnu �[��� import { HTML5BackendImpl } from './HTML5BackendImpl';
import * as NativeTypes from './NativeTypes';
export { getEmptyImage } from './getEmptyImage';
export { NativeTypes };
export const HTML5Backend = function createBackend(manager, context) {
return new HTML5BackendImpl(manager, context);
};
PK H[�\mW=� � lib/BrowserDetector.d.tsnu �[��� declare global {
interface Window extends HTMLElement {
safari: any;
}
}
export declare type Predicate = () => boolean;
export declare const isFirefox: Predicate;
export declare const isSafari: Predicate;
PK H[�\�*�� � lib/OffsetUtils.d.tsnu �[��� import { XYCoord } from 'dnd-core';
export declare function getNodeClientOffset(node: Node): XYCoord | null;
export declare function getEventClientOffset(e: MouseEvent): XYCoord;
export declare function getDragPreviewOffset(sourceNode: HTMLElement, dragPreview: HTMLElement, clientOffset: XYCoord, anchorPoint: {
anchorX: number;
anchorY: number;
}, offsetPoint: {
offsetX: number;
offsetY: number;
}): XYCoord;
PK H[�\cUa�; ; lib/getEmptyImage.d.tsnu �[��� export declare function getEmptyImage(): HTMLImageElement;
PK H[�\���
7 7 lib/OffsetUtils.jsnu �[��� import { isSafari, isFirefox } from './BrowserDetector';
import { MonotonicInterpolant } from './MonotonicInterpolant';
const ELEMENT_NODE = 1;
export function getNodeClientOffset(node) {
const el = node.nodeType === ELEMENT_NODE ? node : node.parentElement;
if (!el) {
return null;
}
const { top, left } = el.getBoundingClientRect();
return { x: left, y: top };
}
export function getEventClientOffset(e) {
return {
x: e.clientX,
y: e.clientY,
};
}
function isImageNode(node) {
return (node.nodeName === 'IMG' &&
(isFirefox() || !document.documentElement?.contains(node)));
}
function getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight) {
let dragPreviewWidth = isImage ? dragPreview.width : sourceWidth;
let dragPreviewHeight = isImage ? dragPreview.height : sourceHeight;
// Work around @2x coordinate discrepancies in browsers
if (isSafari() && isImage) {
dragPreviewHeight /= window.devicePixelRatio;
dragPreviewWidth /= window.devicePixelRatio;
}
return { dragPreviewWidth, dragPreviewHeight };
}
export function getDragPreviewOffset(sourceNode, dragPreview, clientOffset, anchorPoint, offsetPoint) {
// The browsers will use the image intrinsic size under different conditions.
// Firefox only cares if it's an image, but WebKit also wants it to be detached.
const isImage = isImageNode(dragPreview);
const dragPreviewNode = isImage ? sourceNode : dragPreview;
const dragPreviewNodeOffsetFromClient = getNodeClientOffset(dragPreviewNode);
const offsetFromDragPreview = {
x: clientOffset.x - dragPreviewNodeOffsetFromClient.x,
y: clientOffset.y - dragPreviewNodeOffsetFromClient.y,
};
const { offsetWidth: sourceWidth, offsetHeight: sourceHeight } = sourceNode;
const { anchorX, anchorY } = anchorPoint;
const { dragPreviewWidth, dragPreviewHeight } = getDragPreviewSize(isImage, dragPreview, sourceWidth, sourceHeight);
const calculateYOffset = () => {
const interpolantY = new MonotonicInterpolant([0, 0.5, 1], [
// Dock to the top
offsetFromDragPreview.y,
// Align at the center
(offsetFromDragPreview.y / sourceHeight) * dragPreviewHeight,
// Dock to the bottom
offsetFromDragPreview.y + dragPreviewHeight - sourceHeight,
]);
let y = interpolantY.interpolate(anchorY);
// Work around Safari 8 positioning bug
if (isSafari() && isImage) {
// We'll have to wait for @3x to see if this is entirely correct
y += (window.devicePixelRatio - 1) * dragPreviewHeight;
}
return y;
};
const calculateXOffset = () => {
// Interpolate coordinates depending on anchor point
// If you know a simpler way to do this, let me know
const interpolantX = new MonotonicInterpolant([0, 0.5, 1], [
// Dock to the left
offsetFromDragPreview.x,
// Align at the center
(offsetFromDragPreview.x / sourceWidth) * dragPreviewWidth,
// Dock to the right
offsetFromDragPreview.x + dragPreviewWidth - sourceWidth,
]);
return interpolantX.interpolate(anchorX);
};
// Force offsets if specified in the options.
const { offsetX, offsetY } = offsetPoint;
const isManualOffsetX = offsetX === 0 || offsetX;
const isManualOffsetY = offsetY === 0 || offsetY;
return {
x: isManualOffsetX ? offsetX : calculateXOffset(),
y: isManualOffsetY ? offsetY : calculateYOffset(),
};
}
PK H[�\}��� � lib/getEmptyImage.jsnu �[��� let emptyImage;
export function getEmptyImage() {
if (!emptyImage) {
emptyImage = new Image();
emptyImage.src =
'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
}
return emptyImage;
}
PK H[�\�eܐ8
8
lib/HTML5BackendImpl.d.tsnu �[��� import { Backend, DragDropManager, Unsubscribe } from 'dnd-core';
import { HTML5BackendContext } from './types';
declare global {
interface Window {
__isReactDndBackendSetUp: boolean | undefined;
}
}
export declare class HTML5BackendImpl implements Backend {
private options;
private actions;
private monitor;
private registry;
private enterLeaveCounter;
private sourcePreviewNodes;
private sourcePreviewNodeOptions;
private sourceNodes;
private sourceNodeOptions;
private dragStartSourceIds;
private dropTargetIds;
private dragEnterTargetIds;
private currentNativeSource;
private currentNativeHandle;
private currentDragSourceNode;
private altKeyPressed;
private mouseMoveTimeoutTimer;
private asyncEndDragFrameId;
private dragOverTargetIds;
constructor(manager: DragDropManager, globalContext?: HTML5BackendContext);
/**
* Generate profiling statistics for the HTML5Backend.
*/
profile(): Record<string, number>;
get window(): Window | undefined;
get document(): Document | undefined;
setup(): void;
teardown(): void;
connectDragPreview(sourceId: string, node: Element, options: any): Unsubscribe;
connectDragSource(sourceId: string, node: Element, options: any): Unsubscribe;
connectDropTarget(targetId: string, node: HTMLElement): Unsubscribe;
private addEventListeners;
private removeEventListeners;
private getCurrentSourceNodeOptions;
private getCurrentDropEffect;
private getCurrentSourcePreviewNodeOptions;
private getSourceClientOffset;
private isDraggingNativeItem;
private beginDragNativeItem;
private endDragNativeItem;
private isNodeInDocument;
private endDragIfSourceWasRemovedFromDOM;
private setCurrentDragSourceNode;
private clearCurrentDragSourceNode;
handleTopDragStartCapture: () => void;
handleDragStart(e: DragEvent, sourceId: string): void;
handleTopDragStart: (e: DragEvent) => void;
handleTopDragEndCapture: () => void;
handleTopDragEnterCapture: (e: DragEvent) => void;
handleDragEnter(e: DragEvent, targetId: string): void;
handleTopDragEnter: (e: DragEvent) => void;
handleTopDragOverCapture: () => void;
handleDragOver(e: DragEvent, targetId: string): void;
handleTopDragOver: (e: DragEvent) => void;
handleTopDragLeaveCapture: (e: DragEvent) => void;
handleTopDropCapture: (e: DragEvent) => void;
handleDrop(e: DragEvent, targetId: string): void;
handleTopDrop: (e: DragEvent) => void;
handleSelectStart: (e: DragEvent) => void;
}
PK H[�\��*�s s lib/NativeTypes.jsnu �[��� export const FILE = '__NATIVE_FILE__';
export const URL = '__NATIVE_URL__';
export const TEXT = '__NATIVE_TEXT__';
PK H[�\`ܗ� � lib/index.d.tsnu �[��� import * as NativeTypes from './NativeTypes';
import { BackendFactory } from 'dnd-core';
export { getEmptyImage } from './getEmptyImage';
export { NativeTypes };
export declare const HTML5Backend: BackendFactory;
PK H[�\��b b lib/EnterLeaveCounter.d.tsnu �[��� declare type NodePredicate = (node: Node | null | undefined) => boolean;
export declare class EnterLeaveCounter {
private entered;
private isNodeInDocument;
constructor(isNodeInDocument: NodePredicate);
enter(enteringNode: EventTarget | null): boolean;
leave(leavingNode: EventTarget | null): boolean;
reset(): void;
}
export {};
PK H[�\�J��>