Add yet-another-react-lightbox package and update .gitignore to exclude node_modules

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-12 18:50:30 +00:00
parent bd2a5570a9
commit c92f4a5edd
9304 changed files with 29 additions and 2008667 deletions

View File

@@ -1,33 +0,0 @@
import type { DragDropManager, Identifier, Listener, Unsubscribe, XYCoord } from 'dnd-core';
import type { DragSourceMonitor } from '../types/index.js';
export declare class DragSourceMonitorImpl implements DragSourceMonitor {
private internalMonitor;
private sourceId;
constructor(manager: DragDropManager);
receiveHandlerId(sourceId: Identifier | null): void;
getHandlerId(): Identifier | null;
canDrag(): boolean;
isDragging(): boolean;
subscribeToStateChange(listener: Listener, options?: {
handlerIds?: Identifier[];
}): Unsubscribe;
isDraggingSource(sourceId: Identifier): boolean;
isOverTarget(targetId: Identifier, options?: {
shallow: boolean;
}): boolean;
getTargetIds(): Identifier[];
isSourcePublic(): boolean | null;
getSourceId(): Identifier | null;
subscribeToOffsetChange(listener: Listener): Unsubscribe;
canDragSource(sourceId: Identifier): boolean;
canDropOnTarget(targetId: Identifier): boolean;
getItemType(): Identifier | null;
getItem(): any;
getDropResult(): any;
didDrop(): boolean;
getInitialClientOffset(): XYCoord | null;
getInitialSourceClientOffset(): XYCoord | null;
getSourceClientOffset(): XYCoord | null;
getClientOffset(): XYCoord | null;
getDifferenceFromInitialOffset(): XYCoord | null;
}

View File

@@ -1,92 +0,0 @@
import { invariant } from '@react-dnd/invariant';
let isCallingCanDrag = false;
let isCallingIsDragging = false;
export class DragSourceMonitorImpl {
receiveHandlerId(sourceId) {
this.sourceId = sourceId;
}
getHandlerId() {
return this.sourceId;
}
canDrag() {
invariant(!isCallingCanDrag, 'You may not call monitor.canDrag() inside your canDrag() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
try {
isCallingCanDrag = true;
return this.internalMonitor.canDragSource(this.sourceId);
} finally{
isCallingCanDrag = false;
}
}
isDragging() {
if (!this.sourceId) {
return false;
}
invariant(!isCallingIsDragging, 'You may not call monitor.isDragging() inside your isDragging() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
try {
isCallingIsDragging = true;
return this.internalMonitor.isDraggingSource(this.sourceId);
} finally{
isCallingIsDragging = false;
}
}
subscribeToStateChange(listener, options) {
return this.internalMonitor.subscribeToStateChange(listener, options);
}
isDraggingSource(sourceId) {
return this.internalMonitor.isDraggingSource(sourceId);
}
isOverTarget(targetId, options) {
return this.internalMonitor.isOverTarget(targetId, options);
}
getTargetIds() {
return this.internalMonitor.getTargetIds();
}
isSourcePublic() {
return this.internalMonitor.isSourcePublic();
}
getSourceId() {
return this.internalMonitor.getSourceId();
}
subscribeToOffsetChange(listener) {
return this.internalMonitor.subscribeToOffsetChange(listener);
}
canDragSource(sourceId) {
return this.internalMonitor.canDragSource(sourceId);
}
canDropOnTarget(targetId) {
return this.internalMonitor.canDropOnTarget(targetId);
}
getItemType() {
return this.internalMonitor.getItemType();
}
getItem() {
return this.internalMonitor.getItem();
}
getDropResult() {
return this.internalMonitor.getDropResult();
}
didDrop() {
return this.internalMonitor.didDrop();
}
getInitialClientOffset() {
return this.internalMonitor.getInitialClientOffset();
}
getInitialSourceClientOffset() {
return this.internalMonitor.getInitialSourceClientOffset();
}
getSourceClientOffset() {
return this.internalMonitor.getSourceClientOffset();
}
getClientOffset() {
return this.internalMonitor.getClientOffset();
}
getDifferenceFromInitialOffset() {
return this.internalMonitor.getDifferenceFromInitialOffset();
}
constructor(manager){
this.sourceId = null;
this.internalMonitor = manager.getMonitor();
}
}
//# sourceMappingURL=DragSourceMonitorImpl.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,25 +0,0 @@
import type { DragDropManager, Identifier, Listener, Unsubscribe, XYCoord } from 'dnd-core';
import type { DropTargetMonitor } from '../types/index.js';
export declare class DropTargetMonitorImpl implements DropTargetMonitor {
private internalMonitor;
private targetId;
constructor(manager: DragDropManager);
receiveHandlerId(targetId: Identifier | null): void;
getHandlerId(): Identifier | null;
subscribeToStateChange(listener: Listener, options?: {
handlerIds?: Identifier[];
}): Unsubscribe;
canDrop(): boolean;
isOver(options?: {
shallow?: boolean;
}): boolean;
getItemType(): Identifier | null;
getItem(): any;
getDropResult(): any;
didDrop(): boolean;
getInitialClientOffset(): XYCoord | null;
getInitialSourceClientOffset(): XYCoord | null;
getSourceClientOffset(): XYCoord | null;
getClientOffset(): XYCoord | null;
getDifferenceFromInitialOffset(): XYCoord | null;
}

View File

@@ -1,67 +0,0 @@
import { invariant } from '@react-dnd/invariant';
let isCallingCanDrop = false;
export class DropTargetMonitorImpl {
receiveHandlerId(targetId) {
this.targetId = targetId;
}
getHandlerId() {
return this.targetId;
}
subscribeToStateChange(listener, options) {
return this.internalMonitor.subscribeToStateChange(listener, options);
}
canDrop() {
// Cut out early if the target id has not been set. This should prevent errors
// where the user has an older version of dnd-core like in
// https://github.com/react-dnd/react-dnd/issues/1310
if (!this.targetId) {
return false;
}
invariant(!isCallingCanDrop, 'You may not call monitor.canDrop() inside your canDrop() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor');
try {
isCallingCanDrop = true;
return this.internalMonitor.canDropOnTarget(this.targetId);
} finally{
isCallingCanDrop = false;
}
}
isOver(options) {
if (!this.targetId) {
return false;
}
return this.internalMonitor.isOverTarget(this.targetId, options);
}
getItemType() {
return this.internalMonitor.getItemType();
}
getItem() {
return this.internalMonitor.getItem();
}
getDropResult() {
return this.internalMonitor.getDropResult();
}
didDrop() {
return this.internalMonitor.didDrop();
}
getInitialClientOffset() {
return this.internalMonitor.getInitialClientOffset();
}
getInitialSourceClientOffset() {
return this.internalMonitor.getInitialSourceClientOffset();
}
getSourceClientOffset() {
return this.internalMonitor.getSourceClientOffset();
}
getClientOffset() {
return this.internalMonitor.getClientOffset();
}
getDifferenceFromInitialOffset() {
return this.internalMonitor.getDifferenceFromInitialOffset();
}
constructor(manager){
this.targetId = null;
this.internalMonitor = manager.getMonitor();
}
}
//# sourceMappingURL=DropTargetMonitorImpl.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/internals/DropTargetMonitorImpl.ts"],"sourcesContent":["import { invariant } from '@react-dnd/invariant'\nimport type {\n\tDragDropManager,\n\tDragDropMonitor,\n\tIdentifier,\n\tListener,\n\tUnsubscribe,\n\tXYCoord,\n} from 'dnd-core'\n\nimport type { DropTargetMonitor } from '../types/index.js'\n\nlet isCallingCanDrop = false\n\nexport class DropTargetMonitorImpl implements DropTargetMonitor {\n\tprivate internalMonitor: DragDropMonitor\n\tprivate targetId: Identifier | null = null\n\n\tpublic constructor(manager: DragDropManager) {\n\t\tthis.internalMonitor = manager.getMonitor()\n\t}\n\n\tpublic receiveHandlerId(targetId: Identifier | null): void {\n\t\tthis.targetId = targetId\n\t}\n\n\tpublic getHandlerId(): Identifier | null {\n\t\treturn this.targetId\n\t}\n\n\tpublic subscribeToStateChange(\n\t\tlistener: Listener,\n\t\toptions?: { handlerIds?: Identifier[] },\n\t): Unsubscribe {\n\t\treturn this.internalMonitor.subscribeToStateChange(listener, options)\n\t}\n\n\tpublic canDrop(): boolean {\n\t\t// Cut out early if the target id has not been set. This should prevent errors\n\t\t// where the user has an older version of dnd-core like in\n\t\t// https://github.com/react-dnd/react-dnd/issues/1310\n\t\tif (!this.targetId) {\n\t\t\treturn false\n\t\t}\n\t\tinvariant(\n\t\t\t!isCallingCanDrop,\n\t\t\t'You may not call monitor.canDrop() inside your canDrop() implementation. ' +\n\t\t\t\t'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor',\n\t\t)\n\n\t\ttry {\n\t\t\tisCallingCanDrop = true\n\t\t\treturn this.internalMonitor.canDropOnTarget(this.targetId)\n\t\t} finally {\n\t\t\tisCallingCanDrop = false\n\t\t}\n\t}\n\n\tpublic isOver(options?: { shallow?: boolean }): boolean {\n\t\tif (!this.targetId) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.internalMonitor.isOverTarget(this.targetId, options)\n\t}\n\n\tpublic getItemType(): Identifier | null {\n\t\treturn this.internalMonitor.getItemType()\n\t}\n\n\tpublic getItem(): any {\n\t\treturn this.internalMonitor.getItem()\n\t}\n\n\tpublic getDropResult(): any {\n\t\treturn this.internalMonitor.getDropResult()\n\t}\n\n\tpublic didDrop(): boolean {\n\t\treturn this.internalMonitor.didDrop()\n\t}\n\n\tpublic getInitialClientOffset(): XYCoord | null {\n\t\treturn this.internalMonitor.getInitialClientOffset()\n\t}\n\n\tpublic getInitialSourceClientOffset(): XYCoord | null {\n\t\treturn this.internalMonitor.getInitialSourceClientOffset()\n\t}\n\n\tpublic getSourceClientOffset(): XYCoord | null {\n\t\treturn this.internalMonitor.getSourceClientOffset()\n\t}\n\n\tpublic getClientOffset(): XYCoord | null {\n\t\treturn this.internalMonitor.getClientOffset()\n\t}\n\n\tpublic getDifferenceFromInitialOffset(): XYCoord | null {\n\t\treturn this.internalMonitor.getDifferenceFromInitialOffset()\n\t}\n}\n"],"names":["invariant","isCallingCanDrop","DropTargetMonitorImpl","receiveHandlerId","targetId","getHandlerId","subscribeToStateChange","listener","options","internalMonitor","canDrop","canDropOnTarget","isOver","isOverTarget","getItemType","getItem","getDropResult","didDrop","getInitialClientOffset","getInitialSourceClientOffset","getSourceClientOffset","getClientOffset","getDifferenceFromInitialOffset","manager","getMonitor"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sBAAsB,CAAA;AAYhD,IAAIC,gBAAgB,GAAG,KAAK;AAE5B,OAAO,MAAMC,qBAAqB;IAQjC,AAAOC,gBAAgB,CAACC,QAA2B,EAAQ;QAC1D,IAAI,CAACA,QAAQ,GAAGA,QAAQ;KACxB;IAED,AAAOC,YAAY,GAAsB;QACxC,OAAO,IAAI,CAACD,QAAQ,CAAA;KACpB;IAED,AAAOE,sBAAsB,CAC5BC,QAAkB,EAClBC,OAAuC,EACzB;QACd,OAAO,IAAI,CAACC,eAAe,CAACH,sBAAsB,CAACC,QAAQ,EAAEC,OAAO,CAAC,CAAA;KACrE;IAED,AAAOE,OAAO,GAAY;QACzB,8EAA8E;QAC9E,0DAA0D;QAC1D,qDAAqD;QACrD,IAAI,CAAC,IAAI,CAACN,QAAQ,EAAE;YACnB,OAAO,KAAK,CAAA;SACZ;QACDJ,SAAS,CACR,CAACC,gBAAgB,EACjB,2EAA2E,GAC1E,8EAA8E,CAC/E;QAED,IAAI;YACHA,gBAAgB,GAAG,IAAI;YACvB,OAAO,IAAI,CAACQ,eAAe,CAACE,eAAe,CAAC,IAAI,CAACP,QAAQ,CAAC,CAAA;SAC1D,QAAS;YACTH,gBAAgB,GAAG,KAAK;SACxB;KACD;IAED,AAAOW,MAAM,CAACJ,OAA+B,EAAW;QACvD,IAAI,CAAC,IAAI,CAACJ,QAAQ,EAAE;YACnB,OAAO,KAAK,CAAA;SACZ;QACD,OAAO,IAAI,CAACK,eAAe,CAACI,YAAY,CAAC,IAAI,CAACT,QAAQ,EAAEI,OAAO,CAAC,CAAA;KAChE;IAED,AAAOM,WAAW,GAAsB;QACvC,OAAO,IAAI,CAACL,eAAe,CAACK,WAAW,EAAE,CAAA;KACzC;IAED,AAAOC,OAAO,GAAQ;QACrB,OAAO,IAAI,CAACN,eAAe,CAACM,OAAO,EAAE,CAAA;KACrC;IAED,AAAOC,aAAa,GAAQ;QAC3B,OAAO,IAAI,CAACP,eAAe,CAACO,aAAa,EAAE,CAAA;KAC3C;IAED,AAAOC,OAAO,GAAY;QACzB,OAAO,IAAI,CAACR,eAAe,CAACQ,OAAO,EAAE,CAAA;KACrC;IAED,AAAOC,sBAAsB,GAAmB;QAC/C,OAAO,IAAI,CAACT,eAAe,CAACS,sBAAsB,EAAE,CAAA;KACpD;IAED,AAAOC,4BAA4B,GAAmB;QACrD,OAAO,IAAI,CAACV,eAAe,CAACU,4BAA4B,EAAE,CAAA;KAC1D;IAED,AAAOC,qBAAqB,GAAmB;QAC9C,OAAO,IAAI,CAACX,eAAe,CAACW,qBAAqB,EAAE,CAAA;KACnD;IAED,AAAOC,eAAe,GAAmB;QACxC,OAAO,IAAI,CAACZ,eAAe,CAACY,eAAe,EAAE,CAAA;KAC7C;IAED,AAAOC,8BAA8B,GAAmB;QACvD,OAAO,IAAI,CAACb,eAAe,CAACa,8BAA8B,EAAE,CAAA;KAC5D;IAjFD,YAAmBC,OAAwB,CAAE;QAF7C,KAAQnB,QAAQ,GAAsB,IAAI,AAhB3C,CAgB2C;QAGzC,IAAI,CAACK,eAAe,GAAGc,OAAO,CAACC,UAAU,EAAE;KAC3C;CAgFD"}

View File

@@ -1,47 +0,0 @@
import type { Backend, Identifier } from 'dnd-core';
import type { DragPreviewOptions, DragSourceOptions } from '../types/index.js';
export interface Connector {
hooks: any;
connectTarget: any;
receiveHandlerId(handlerId: Identifier | null): void;
reconnect(): void;
}
export declare class SourceConnector implements Connector {
hooks: any;
private handlerId;
private dragSourceRef;
private dragSourceNode;
private dragSourceOptionsInternal;
private dragSourceUnsubscribe;
private dragPreviewRef;
private dragPreviewNode;
private dragPreviewOptionsInternal;
private dragPreviewUnsubscribe;
private lastConnectedHandlerId;
private lastConnectedDragSource;
private lastConnectedDragSourceOptions;
private lastConnectedDragPreview;
private lastConnectedDragPreviewOptions;
private readonly backend;
constructor(backend: Backend);
receiveHandlerId(newHandlerId: Identifier | null): void;
get connectTarget(): any;
get dragSourceOptions(): DragSourceOptions | null;
set dragSourceOptions(options: DragSourceOptions | null);
get dragPreviewOptions(): DragPreviewOptions | null;
set dragPreviewOptions(options: DragPreviewOptions | null);
reconnect(): void;
private reconnectDragSource;
private reconnectDragPreview;
private didHandlerIdChange;
private didConnectedDragSourceChange;
private didConnectedDragPreviewChange;
private didDragSourceOptionsChange;
private didDragPreviewOptionsChange;
disconnectDragSource(): void;
disconnectDragPreview(): void;
private get dragSource();
private get dragPreview();
private clearDragSource;
private clearDragPreview;
}

View File

@@ -1,156 +0,0 @@
import { shallowEqual } from '@react-dnd/shallowequal';
import { isRef } from './isRef.js';
import { wrapConnectorHooks } from './wrapConnectorHooks.js';
export class SourceConnector {
receiveHandlerId(newHandlerId) {
if (this.handlerId === newHandlerId) {
return;
}
this.handlerId = newHandlerId;
this.reconnect();
}
get connectTarget() {
return this.dragSource;
}
get dragSourceOptions() {
return this.dragSourceOptionsInternal;
}
set dragSourceOptions(options) {
this.dragSourceOptionsInternal = options;
}
get dragPreviewOptions() {
return this.dragPreviewOptionsInternal;
}
set dragPreviewOptions(options) {
this.dragPreviewOptionsInternal = options;
}
reconnect() {
const didChange = this.reconnectDragSource();
this.reconnectDragPreview(didChange);
}
reconnectDragSource() {
const dragSource = this.dragSource;
// if nothing has changed then don't resubscribe
const didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
if (didChange) {
this.disconnectDragSource();
}
if (!this.handlerId) {
return didChange;
}
if (!dragSource) {
this.lastConnectedDragSource = dragSource;
return didChange;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragSource = dragSource;
this.lastConnectedDragSourceOptions = this.dragSourceOptions;
this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
}
return didChange;
}
reconnectDragPreview(forceDidChange = false) {
const dragPreview = this.dragPreview;
// if nothing has changed then don't resubscribe
const didChange = forceDidChange || this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
if (didChange) {
this.disconnectDragPreview();
}
if (!this.handlerId) {
return;
}
if (!dragPreview) {
this.lastConnectedDragPreview = dragPreview;
return;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDragPreview = dragPreview;
this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
}
}
didHandlerIdChange() {
return this.lastConnectedHandlerId !== this.handlerId;
}
didConnectedDragSourceChange() {
return this.lastConnectedDragSource !== this.dragSource;
}
didConnectedDragPreviewChange() {
return this.lastConnectedDragPreview !== this.dragPreview;
}
didDragSourceOptionsChange() {
return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
}
didDragPreviewOptionsChange() {
return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
}
disconnectDragSource() {
if (this.dragSourceUnsubscribe) {
this.dragSourceUnsubscribe();
this.dragSourceUnsubscribe = undefined;
}
}
disconnectDragPreview() {
if (this.dragPreviewUnsubscribe) {
this.dragPreviewUnsubscribe();
this.dragPreviewUnsubscribe = undefined;
this.dragPreviewNode = null;
this.dragPreviewRef = null;
}
}
get dragSource() {
return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
}
get dragPreview() {
return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
}
clearDragSource() {
this.dragSourceNode = null;
this.dragSourceRef = null;
}
clearDragPreview() {
this.dragPreviewNode = null;
this.dragPreviewRef = null;
}
constructor(backend){
this.hooks = wrapConnectorHooks({
dragSource: (node, options)=>{
this.clearDragSource();
this.dragSourceOptions = options || null;
if (isRef(node)) {
this.dragSourceRef = node;
} else {
this.dragSourceNode = node;
}
this.reconnectDragSource();
},
dragPreview: (node, options)=>{
this.clearDragPreview();
this.dragPreviewOptions = options || null;
if (isRef(node)) {
this.dragPreviewRef = node;
} else {
this.dragPreviewNode = node;
}
this.reconnectDragPreview();
}
});
this.handlerId = null;
// The drop target may either be attached via ref or connect function
this.dragSourceRef = null;
this.dragSourceOptionsInternal = null;
// The drag preview may either be attached via ref or connect function
this.dragPreviewRef = null;
this.dragPreviewOptionsInternal = null;
this.lastConnectedHandlerId = null;
this.lastConnectedDragSource = null;
this.lastConnectedDragSourceOptions = null;
this.lastConnectedDragPreview = null;
this.lastConnectedDragPreviewOptions = null;
this.backend = backend;
}
}
//# sourceMappingURL=SourceConnector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,27 +0,0 @@
import type { Backend, Identifier } from 'dnd-core';
import type { DropTargetOptions } from '../types/index.js';
import type { Connector } from './SourceConnector.js';
export declare class TargetConnector implements Connector {
hooks: any;
private handlerId;
private dropTargetRef;
private dropTargetNode;
private dropTargetOptionsInternal;
private unsubscribeDropTarget;
private lastConnectedHandlerId;
private lastConnectedDropTarget;
private lastConnectedDropTargetOptions;
private readonly backend;
constructor(backend: Backend);
get connectTarget(): any;
reconnect(): void;
receiveHandlerId(newHandlerId: Identifier | null): void;
get dropTargetOptions(): DropTargetOptions;
set dropTargetOptions(options: DropTargetOptions);
private didHandlerIdChange;
private didDropTargetChange;
private didOptionsChange;
disconnectDropTarget(): void;
private get dropTarget();
private clearDropTarget;
}

View File

@@ -1,88 +0,0 @@
import { shallowEqual } from '@react-dnd/shallowequal';
import { isRef } from './isRef.js';
import { wrapConnectorHooks } from './wrapConnectorHooks.js';
export class TargetConnector {
get connectTarget() {
return this.dropTarget;
}
reconnect() {
// if nothing has changed then don't resubscribe
const didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
if (didChange) {
this.disconnectDropTarget();
}
const dropTarget = this.dropTarget;
if (!this.handlerId) {
return;
}
if (!dropTarget) {
this.lastConnectedDropTarget = dropTarget;
return;
}
if (didChange) {
this.lastConnectedHandlerId = this.handlerId;
this.lastConnectedDropTarget = dropTarget;
this.lastConnectedDropTargetOptions = this.dropTargetOptions;
this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
}
}
receiveHandlerId(newHandlerId) {
if (newHandlerId === this.handlerId) {
return;
}
this.handlerId = newHandlerId;
this.reconnect();
}
get dropTargetOptions() {
return this.dropTargetOptionsInternal;
}
set dropTargetOptions(options) {
this.dropTargetOptionsInternal = options;
}
didHandlerIdChange() {
return this.lastConnectedHandlerId !== this.handlerId;
}
didDropTargetChange() {
return this.lastConnectedDropTarget !== this.dropTarget;
}
didOptionsChange() {
return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
}
disconnectDropTarget() {
if (this.unsubscribeDropTarget) {
this.unsubscribeDropTarget();
this.unsubscribeDropTarget = undefined;
}
}
get dropTarget() {
return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
}
clearDropTarget() {
this.dropTargetRef = null;
this.dropTargetNode = null;
}
constructor(backend){
this.hooks = wrapConnectorHooks({
dropTarget: (node, options)=>{
this.clearDropTarget();
this.dropTargetOptions = options;
if (isRef(node)) {
this.dropTargetRef = node;
} else {
this.dropTargetNode = node;
}
this.reconnect();
}
});
this.handlerId = null;
// The drop target may either be attached via ref or connect function
this.dropTargetRef = null;
this.dropTargetOptionsInternal = null;
this.lastConnectedHandlerId = null;
this.lastConnectedDropTarget = null;
this.lastConnectedDropTargetOptions = null;
this.backend = backend;
}
}
//# sourceMappingURL=TargetConnector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +0,0 @@
export * from './DragSourceMonitorImpl.js';
export * from './DropTargetMonitorImpl.js';
export * from './registration.js';
export * from './SourceConnector.js';
export * from './TargetConnector.js';

View File

@@ -1,7 +0,0 @@
export * from './DragSourceMonitorImpl.js';
export * from './DropTargetMonitorImpl.js';
export * from './registration.js';
export * from './SourceConnector.js';
export * from './TargetConnector.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/internals/index.ts"],"sourcesContent":["export * from './DragSourceMonitorImpl.js'\nexport * from './DropTargetMonitorImpl.js'\nexport * from './registration.js'\nexport * from './SourceConnector.js'\nexport * from './TargetConnector.js'\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA"}

View File

@@ -1,4 +0,0 @@
export interface Ref<T> {
current: T;
}
export declare function isRef(obj: unknown): boolean;

View File

@@ -1,6 +0,0 @@
export function isRef(obj) {
return(// eslint-disable-next-line no-prototype-builtins
obj !== null && typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current'));
}
//# sourceMappingURL=isRef.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/internals/isRef.ts"],"sourcesContent":["export interface Ref<T> {\n\tcurrent: T\n}\n\nexport function isRef(obj: unknown): boolean {\n\treturn (\n\t\t// eslint-disable-next-line no-prototype-builtins\n\t\tobj !== null &&\n\t\ttypeof obj === 'object' &&\n\t\tObject.prototype.hasOwnProperty.call(obj, 'current')\n\t)\n}\n"],"names":["isRef","obj","Object","prototype","hasOwnProperty","call"],"mappings":"AAIA,OAAO,SAASA,KAAK,CAACC,GAAY,EAAW;IAC5C,OACC,iDAAiD;IACjDA,GAAG,KAAK,IAAI,IACZ,OAAOA,GAAG,KAAK,QAAQ,IACvBC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,GAAG,EAAE,SAAS,CAAC,EACpD;CACD"}

View File

@@ -1,3 +0,0 @@
import type { DragDropManager, DragSource, DropTarget, Identifier, SourceType, TargetType, Unsubscribe } from 'dnd-core';
export declare function registerTarget(type: TargetType, target: DropTarget, manager: DragDropManager): [Identifier, Unsubscribe];
export declare function registerSource(type: SourceType, source: DragSource, manager: DragDropManager): [Identifier, Unsubscribe];

View File

@@ -1,18 +0,0 @@
export function registerTarget(type, target, manager) {
const registry = manager.getRegistry();
const targetId = registry.addTarget(type, target);
return [
targetId,
()=>registry.removeTarget(targetId)
];
}
export function registerSource(type, source, manager) {
const registry = manager.getRegistry();
const sourceId = registry.addSource(type, source);
return [
sourceId,
()=>registry.removeSource(sourceId)
];
}
//# sourceMappingURL=registration.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/internals/registration.ts"],"sourcesContent":["import type {\n\tDragDropManager,\n\tDragSource,\n\tDropTarget,\n\tIdentifier,\n\tSourceType,\n\tTargetType,\n\tUnsubscribe,\n} from 'dnd-core'\n\nexport function registerTarget(\n\ttype: TargetType,\n\ttarget: DropTarget,\n\tmanager: DragDropManager,\n): [Identifier, Unsubscribe] {\n\tconst registry = manager.getRegistry()\n\tconst targetId = registry.addTarget(type, target)\n\n\treturn [targetId, () => registry.removeTarget(targetId)]\n}\n\nexport function registerSource(\n\ttype: SourceType,\n\tsource: DragSource,\n\tmanager: DragDropManager,\n): [Identifier, Unsubscribe] {\n\tconst registry = manager.getRegistry()\n\tconst sourceId = registry.addSource(type, source)\n\n\treturn [sourceId, () => registry.removeSource(sourceId)]\n}\n"],"names":["registerTarget","type","target","manager","registry","getRegistry","targetId","addTarget","removeTarget","registerSource","source","sourceId","addSource","removeSource"],"mappings":"AAUA,OAAO,SAASA,cAAc,CAC7BC,IAAgB,EAChBC,MAAkB,EAClBC,OAAwB,EACI;IAC5B,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,EAAE;IACtC,MAAMC,QAAQ,GAAGF,QAAQ,CAACG,SAAS,CAACN,IAAI,EAAEC,MAAM,CAAC;IAEjD,OAAO;QAACI,QAAQ;QAAE,IAAMF,QAAQ,CAACI,YAAY,CAACF,QAAQ,CAAC;KAAC,CAAA;CACxD;AAED,OAAO,SAASG,cAAc,CAC7BR,IAAgB,EAChBS,MAAkB,EAClBP,OAAwB,EACI;IAC5B,MAAMC,QAAQ,GAAGD,OAAO,CAACE,WAAW,EAAE;IACtC,MAAMM,QAAQ,GAAGP,QAAQ,CAACQ,SAAS,CAACX,IAAI,EAAES,MAAM,CAAC;IAEjD,OAAO;QAACC,QAAQ;QAAE,IAAMP,QAAQ,CAACS,YAAY,CAACF,QAAQ,CAAC;KAAC,CAAA;CACxD"}

View File

@@ -1 +0,0 @@
export declare function wrapConnectorHooks(hooks: any): any;

View File

@@ -1,73 +0,0 @@
import { invariant } from '@react-dnd/invariant';
import { cloneElement, isValidElement } from 'react';
function throwIfCompositeComponentElement(element) {
// Custom components can no longer be wrapped directly in React DnD 2.0
// so that we don't need to depend on findDOMNode() from react-dom.
if (typeof element.type === 'string') {
return;
}
const displayName = element.type.displayName || element.type.name || 'the component';
throw new Error('Only native element nodes can now be passed to React DnD connectors.' + `You can either wrap ${displayName} into a <div>, or turn it into a ` + 'drag source or a drop target itself.');
}
function wrapHookToRecognizeElement(hook) {
return (elementOrNode = null, options = null)=>{
// When passed a node, call the hook straight away.
if (!isValidElement(elementOrNode)) {
const node = elementOrNode;
hook(node, options);
// return the node so it can be chained (e.g. when within callback refs
// <div ref={node => connectDragSource(connectDropTarget(node))}/>
return node;
}
// If passed a ReactElement, clone it and attach this function as a ref.
// This helps us achieve a neat API where user doesn't even know that refs
// are being used under the hood.
const element = elementOrNode;
throwIfCompositeComponentElement(element);
// When no options are passed, use the hook directly
const ref = options ? (node)=>hook(node, options)
: hook;
return cloneWithRef(element, ref);
};
}
export function wrapConnectorHooks(hooks) {
const wrappedHooks = {};
Object.keys(hooks).forEach((key)=>{
const hook = hooks[key];
// ref objects should be passed straight through without wrapping
if (key.endsWith('Ref')) {
wrappedHooks[key] = hooks[key];
} else {
const wrappedHook = wrapHookToRecognizeElement(hook);
wrappedHooks[key] = ()=>wrappedHook
;
}
});
return wrappedHooks;
}
function setRef(ref, node) {
if (typeof ref === 'function') {
ref(node);
} else {
ref.current = node;
}
}
function cloneWithRef(element, newRef) {
const previousRef = element.ref;
invariant(typeof previousRef !== 'string', 'Cannot connect React DnD to an element with an existing string ref. ' + 'Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. ' + 'Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs');
if (!previousRef) {
// When there is no ref on the element, use the new ref directly
return cloneElement(element, {
ref: newRef
});
} else {
return cloneElement(element, {
ref: (node)=>{
setRef(previousRef, node);
setRef(newRef, node);
}
});
}
}
//# sourceMappingURL=wrapConnectorHooks.js.map

File diff suppressed because one or more lines are too long