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,22 +0,0 @@
The MIT License (MIT)
Copyright (c) 2016 Dan Abramov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,17 +0,0 @@
[![npm version](https://img.shields.io/npm/v/react-dnd.svg?style=flat-square)](https://www.npmjs.com/package/react-dnd)
[![npm downloads](https://img.shields.io/npm/dm/react-dnd.svg?style=flat-square)](https://www.npmjs.com/package/react-dnd)
[![Build Status](https://travis-ci.org/react-dnd/react-dnd.svg?branch=main)](https://travis-ci.org/react-dnd/react-dnd)
# React _DnD_
Drag and Drop for React.
See the docs, tutorials and examples on the website:
http://react-dnd.github.io/react-dnd/
See the changelog on the Releases page:
https://github.com/react-dnd/react-dnd/releases
Big thanks to [BrowserStack](https://www.browserstack.com) for letting the maintainers use their service to debug browser issues.

View File

@@ -1,12 +0,0 @@
/// <reference types="react" />
import type { DragDropManager } from 'dnd-core';
/**
* The React context type
*/
export interface DndContextType {
dragDropManager: DragDropManager | undefined;
}
/**
* Create the React Context
*/
export declare const DndContext: import("react").Context<DndContextType>;

View File

@@ -1,8 +0,0 @@
import { createContext } from 'react';
/**
* Create the React Context
*/ export const DndContext = createContext({
dragDropManager: undefined
});
//# sourceMappingURL=DndContext.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/core/DndContext.ts"],"sourcesContent":["import type { DragDropManager } from 'dnd-core'\nimport { createContext } from 'react'\n\n/**\n * The React context type\n */\nexport interface DndContextType {\n\tdragDropManager: DragDropManager | undefined\n}\n\n/**\n * Create the React Context\n */\nexport const DndContext = createContext<DndContextType>({\n\tdragDropManager: undefined,\n})\n"],"names":["createContext","DndContext","dragDropManager","undefined"],"mappings":"AACA,SAASA,aAAa,QAAQ,OAAO,CAAA;AASrC;;GAEG,CACH,OAAO,MAAMC,UAAU,GAAGD,aAAa,CAAiB;IACvDE,eAAe,EAAEC,SAAS;CAC1B,CAAC,CAAA"}

View File

@@ -1,16 +0,0 @@
import type { BackendFactory, DragDropManager } from 'dnd-core';
import type { FC, ReactNode } from 'react';
export declare type DndProviderProps<BackendContext, BackendOptions> = {
children?: ReactNode;
manager: DragDropManager;
} | {
backend: BackendFactory;
children?: ReactNode;
context?: BackendContext;
options?: BackendOptions;
debugMode?: boolean;
};
/**
* A React component that provides the React-DnD context
*/
export declare const DndProvider: FC<DndProviderProps<unknown, unknown>>;

View File

@@ -1,94 +0,0 @@
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for(i = 0; i < sourceSymbolKeys.length; i++){
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
import { jsx as _jsx } from "react/jsx-runtime";
import { createDragDropManager } from 'dnd-core';
import { memo, useEffect } from 'react';
import { DndContext } from './DndContext.js';
let refCount = 0;
const INSTANCE_SYM = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__');
var DndProvider = /*#__PURE__*/ memo(function DndProvider(_param) {
var { children } = _param, props = _objectWithoutProperties(_param, [
"children"
]);
const [manager, isGlobalInstance] = getDndContextValue(props) // memoized from props
;
/**
* If the global context was used to store the DND context
* then where theres no more references to it we should
* clean it up to avoid memory leaks
*/ useEffect(()=>{
if (isGlobalInstance) {
const context = getGlobalContext();
++refCount;
return ()=>{
if (--refCount === 0) {
context[INSTANCE_SYM] = null;
}
};
}
return;
}, []);
return /*#__PURE__*/ _jsx(DndContext.Provider, {
value: manager,
children: children
});
});
/**
* A React component that provides the React-DnD context
*/ export { DndProvider, };
function getDndContextValue(props) {
if ('manager' in props) {
const manager = {
dragDropManager: props.manager
};
return [
manager,
false
];
}
const manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode);
const isGlobalInstance = !props.context;
return [
manager,
isGlobalInstance
];
}
function createSingletonDndContext(backend, context = getGlobalContext(), options, debugMode) {
const ctx = context;
if (!ctx[INSTANCE_SYM]) {
ctx[INSTANCE_SYM] = {
dragDropManager: createDragDropManager(backend, context, options, debugMode)
};
}
return ctx[INSTANCE_SYM];
}
function getGlobalContext() {
return typeof global !== 'undefined' ? global : window;
}
//# sourceMappingURL=DndProvider.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/core/DndProvider.tsx"],"sourcesContent":["import type { BackendFactory, DragDropManager } from 'dnd-core'\nimport { createDragDropManager } from 'dnd-core'\nimport type { FC, ReactNode } from 'react'\nimport { memo, useEffect } from 'react'\n\nimport { DndContext } from './DndContext.js'\n\nexport type DndProviderProps<BackendContext, BackendOptions> =\n\t| {\n\t\t\tchildren?: ReactNode\n\t\t\tmanager: DragDropManager\n\t }\n\t| {\n\t\t\tbackend: BackendFactory\n\t\t\tchildren?: ReactNode\n\t\t\tcontext?: BackendContext\n\t\t\toptions?: BackendOptions\n\t\t\tdebugMode?: boolean\n\t }\n\nlet refCount = 0\nconst INSTANCE_SYM = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__')\n\n/**\n * A React component that provides the React-DnD context\n */\nexport const DndProvider: FC<DndProviderProps<unknown, unknown>> = memo(\n\tfunction DndProvider({ children, ...props }) {\n\t\tconst [manager, isGlobalInstance] = getDndContextValue(props) // memoized from props\n\t\t/**\n\t\t * If the global context was used to store the DND context\n\t\t * then where theres no more references to it we should\n\t\t * clean it up to avoid memory leaks\n\t\t */\n\t\tuseEffect(() => {\n\t\t\tif (isGlobalInstance) {\n\t\t\t\tconst context = getGlobalContext()\n\t\t\t\t++refCount\n\n\t\t\t\treturn () => {\n\t\t\t\t\tif (--refCount === 0) {\n\t\t\t\t\t\tcontext[INSTANCE_SYM] = null\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}, [])\n\n\t\treturn <DndContext.Provider value={manager}>{children}</DndContext.Provider>\n\t},\n)\n\nfunction getDndContextValue(props: DndProviderProps<unknown, unknown>) {\n\tif ('manager' in props) {\n\t\tconst manager = { dragDropManager: props.manager }\n\t\treturn [manager, false]\n\t}\n\n\tconst manager = createSingletonDndContext(\n\t\tprops.backend,\n\t\tprops.context,\n\t\tprops.options,\n\t\tprops.debugMode,\n\t)\n\tconst isGlobalInstance = !props.context\n\n\treturn [manager, isGlobalInstance]\n}\n\nfunction createSingletonDndContext<BackendContext, BackendOptions>(\n\tbackend: BackendFactory,\n\tcontext: BackendContext = getGlobalContext(),\n\toptions: BackendOptions,\n\tdebugMode?: boolean,\n) {\n\tconst ctx = context as any\n\tif (!ctx[INSTANCE_SYM]) {\n\t\tctx[INSTANCE_SYM] = {\n\t\t\tdragDropManager: createDragDropManager(\n\t\t\t\tbackend,\n\t\t\t\tcontext,\n\t\t\t\toptions,\n\t\t\t\tdebugMode,\n\t\t\t),\n\t\t}\n\t}\n\treturn ctx[INSTANCE_SYM]\n}\n\ndeclare const global: any\nfunction getGlobalContext() {\n\treturn typeof global !== 'undefined' ? global : (window as any)\n}\n"],"names":["createDragDropManager","memo","useEffect","DndContext","refCount","INSTANCE_SYM","Symbol","for","DndProvider","children","props","manager","isGlobalInstance","getDndContextValue","context","getGlobalContext","Provider","value","dragDropManager","createSingletonDndContext","backend","options","debugMode","ctx","global","window"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAASA,qBAAqB,QAAQ,UAAU,CAAA;AAEhD,SAASC,IAAI,EAAEC,SAAS,QAAQ,OAAO,CAAA;AAEvC,SAASC,UAAU,QAAQ,iBAAiB,CAAA;AAe5C,IAAIC,QAAQ,GAAG,CAAC;AAChB,MAAMC,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,gCAAgC,CAAC;IAKpDC,WAAW,iBAA2CP,IAAI,CACtE,SAASO,WAAW,CAAC,MAAsB,EAAE;QAAxB,EAAEC,QAAQ,CAAA,EAAY,GAAtB,MAAsB,EAAPC,KAAK,4BAApB,MAAsB;QAApBD,UAAQ;;IAC9B,MAAM,CAACE,OAAO,EAAEC,gBAAgB,CAAC,GAAGC,kBAAkB,CAACH,KAAK,CAAC,CAAC,sBAAsB;IAAvB;IAC7D;;;;KAIG,CACHR,SAAS,CAAC,IAAM;QACf,IAAIU,gBAAgB,EAAE;YACrB,MAAME,OAAO,GAAGC,gBAAgB,EAAE;YAClC,EAAEX,QAAQ;YAEV,OAAO,IAAM;gBACZ,IAAI,EAAEA,QAAQ,KAAK,CAAC,EAAE;oBACrBU,OAAO,CAACT,YAAY,CAAC,GAAG,IAAI;iBAC5B;aACD,CAAA;SACD;QACD,OAAM;KACN,EAAE,EAAE,CAAC;IAEN,qBAAO,KAACF,UAAU,CAACa,QAAQ;QAACC,KAAK,EAAEN,OAAO;kBAAGF,QAAQ;MAAuB,CAAA;CAC5E,CACD;AA3BD;;GAEG,CACH,yBAwBC;AAED,SAASI,kBAAkB,CAACH,KAAyC,EAAE;IACtE,IAAI,SAAS,IAAIA,KAAK,EAAE;QACvB,MAAMC,OAAO,GAAG;YAAEO,eAAe,EAAER,KAAK,CAACC,OAAO;SAAE;QAClD,OAAO;YAACA,OAAO;YAAE,KAAK;SAAC,CAAA;KACvB;IAED,MAAMA,OAAO,GAAGQ,yBAAyB,CACxCT,KAAK,CAACU,OAAO,EACbV,KAAK,CAACI,OAAO,EACbJ,KAAK,CAACW,OAAO,EACbX,KAAK,CAACY,SAAS,CACf;IACD,MAAMV,gBAAgB,GAAG,CAACF,KAAK,CAACI,OAAO;IAEvC,OAAO;QAACH,OAAO;QAAEC,gBAAgB;KAAC,CAAA;CAClC;AAED,SAASO,yBAAyB,CACjCC,OAAuB,EACvBN,OAAuB,GAAGC,gBAAgB,EAAE,EAC5CM,OAAuB,EACvBC,SAAmB,EAClB;IACD,MAAMC,GAAG,GAAGT,OAAO,AAAO;IAC1B,IAAI,CAACS,GAAG,CAAClB,YAAY,CAAC,EAAE;QACvBkB,GAAG,CAAClB,YAAY,CAAC,GAAG;YACnBa,eAAe,EAAElB,qBAAqB,CACrCoB,OAAO,EACPN,OAAO,EACPO,OAAO,EACPC,SAAS,CACT;SACD;KACD;IACD,OAAOC,GAAG,CAAClB,YAAY,CAAC,CAAA;CACxB;AAGD,SAASU,gBAAgB,GAAG;IAC3B,OAAO,OAAOS,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAIC,MAAM,AAAQ,CAAA;CAC/D"}

View File

@@ -1,10 +0,0 @@
import type { FC } from 'react';
import type { ConnectDragPreview } from '../types/index.js';
export interface DragPreviewImageProps {
connect: ConnectDragPreview;
src: string;
}
/**
* A utility for rendering a drag preview image
*/
export declare const DragPreviewImage: FC<DragPreviewImageProps>;

View File

@@ -1,23 +0,0 @@
import { memo, useEffect } from 'react';
/**
* A utility for rendering a drag preview image
*/ export const DragPreviewImage = memo(function DragPreviewImage({ connect , src }) {
useEffect(()=>{
if (typeof Image === 'undefined') return;
let connected = false;
const img = new Image();
img.src = src;
img.onload = ()=>{
connect(img);
connected = true;
};
return ()=>{
if (connected) {
connect(null);
}
};
});
return null;
});
//# sourceMappingURL=DragPreviewImage.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/core/DragPreviewImage.ts"],"sourcesContent":["import type { FC } from 'react'\nimport { memo, useEffect } from 'react'\n\nimport type { ConnectDragPreview } from '../types/index.js'\n\nexport interface DragPreviewImageProps {\n\tconnect: ConnectDragPreview\n\tsrc: string\n}\n/**\n * A utility for rendering a drag preview image\n */\nexport const DragPreviewImage: FC<DragPreviewImageProps> = memo(\n\tfunction DragPreviewImage({ connect, src }) {\n\t\tuseEffect(() => {\n\t\t\tif (typeof Image === 'undefined') return\n\n\t\t\tlet connected = false\n\t\t\tconst img = new Image()\n\t\t\timg.src = src\n\t\t\timg.onload = () => {\n\t\t\t\tconnect(img)\n\t\t\t\tconnected = true\n\t\t\t}\n\t\t\treturn () => {\n\t\t\t\tif (connected) {\n\t\t\t\t\tconnect(null)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\n\t\treturn null\n\t},\n)\n"],"names":["memo","useEffect","DragPreviewImage","connect","src","Image","connected","img","onload"],"mappings":"AACA,SAASA,IAAI,EAAEC,SAAS,QAAQ,OAAO,CAAA;AAQvC;;GAEG,CACH,OAAO,MAAMC,gBAAgB,GAA8BF,IAAI,CAC9D,SAASE,gBAAgB,CAAC,EAAEC,OAAO,CAAA,EAAEC,GAAG,CAAA,EAAE,EAAE;IAC3CH,SAAS,CAAC,IAAM;QACf,IAAI,OAAOI,KAAK,KAAK,WAAW,EAAE,OAAM;QAExC,IAAIC,SAAS,GAAG,KAAK;QACrB,MAAMC,GAAG,GAAG,IAAIF,KAAK,EAAE;QACvBE,GAAG,CAACH,GAAG,GAAGA,GAAG;QACbG,GAAG,CAACC,MAAM,GAAG,IAAM;YAClBL,OAAO,CAACI,GAAG,CAAC;YACZD,SAAS,GAAG,IAAI;SAChB;QACD,OAAO,IAAM;YACZ,IAAIA,SAAS,EAAE;gBACdH,OAAO,CAAC,IAAI,CAAC;aACb;SACD,CAAA;KACD,CAAC;IAEF,OAAO,IAAI,CAAA;CACX,CACD,CAAA"}

View File

@@ -1,3 +0,0 @@
export * from './DndContext.js';
export * from './DndProvider.js';
export * from './DragPreviewImage.js';

View File

@@ -1,5 +0,0 @@
export * from './DndContext.js';
export * from './DndProvider.js';
export * from './DragPreviewImage.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export * from './DndContext.js'\nexport * from './DndProvider.js'\nexport * from './DragPreviewImage.js'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA"}

View File

@@ -1,5 +0,0 @@
export * from './types.js';
export * from './useDrag/index.js';
export * from './useDragDropManager.js';
export * from './useDragLayer.js';
export * from './useDrop/index.js';

View File

@@ -1,7 +0,0 @@
export * from './types.js';
export * from './useDrag/index.js';
export * from './useDragDropManager.js';
export * from './useDragLayer.js';
export * from './useDrop/index.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export * from './types.js'\nexport * from './useDrag/index.js'\nexport * from './useDragDropManager.js'\nexport * from './useDragLayer.js'\nexport * from './useDrop/index.js'\n"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA"}

View File

@@ -1,108 +0,0 @@
import type { SourceType, TargetType } from 'dnd-core';
import type { DragPreviewOptions, DragSourceMonitor, DragSourceOptions, DropTargetMonitor, DropTargetOptions } from '../types/index.js';
export declare type FactoryOrInstance<T> = T | (() => T);
export declare type DragObjectFactory<T> = (monitor: DragSourceMonitor<T>) => T | null;
export interface DragSourceHookSpec<DragObject, DropResult, CollectedProps> {
/**
* The type of item being dragged. This is required when using the function form of spec.item.
* If spec.item is a static object, the type may either be defined on that object as `item.type`, or it may
* be defined here.
*/
type: SourceType;
/**
* This property generates or defines a plain javascript item describing
* the data being dragged. This is the only information available to the
* drop targets about the drag source so it's important to pick the minimal
* data they need to know.
*
* You may be tempted to put a reference to the component or complex object here,
* but you should try very hard to avoid doing this because it couples the
* drag sources and drop targets. It's a good idea to use something like
* { id: props.id }
*
* If a function-form is used, it is invoked when the drag begins and returns a draggable item.
* If the function returns null, the drag is canceled
*
*/
item?: DragObject | DragObjectFactory<DragObject>;
/**
* The drag source options
*/
options?: DragSourceOptions;
/**
* DragPreview options
*/
previewOptions?: DragPreviewOptions;
/**
* Optional.
* When the dragging stops, endDrag is called. For every beginDrag call, a corresponding endDrag call is guaranteed.
* You may call monitor.didDrop() to check whether or not the drop was handled by a compatible drop target. If it was handled,
* and the drop target specified a drop result by returning a plain object from its drop() method, it will be available as
* monitor.getDropResult(). This method is a good place to fire a Flux action. Note: If the component is unmounted while dragging,
* component parameter is set to be null.
*/
end?: (draggedItem: DragObject, monitor: DragSourceMonitor<DragObject, DropResult>) => void;
/**
* Optional.
* Use it to specify whether the dragging is currently allowed. If you want to always allow it, just omit this method.
* Specifying it is handy if you'd like to disable dragging based on some predicate over props. Note: You may not call
* monitor.canDrag() inside this method.
*/
canDrag?: boolean | ((monitor: DragSourceMonitor<DragObject, DropResult>) => boolean);
/**
* Optional.
* By default, only the drag source that initiated the drag operation is considered to be dragging. You can
* override this behavior by defining a custom isDragging method. It might return something like props.id === monitor.getItem().id.
* Do this if the original component may be unmounted during the dragging and later “resurrected” with a different parent.
* For example, when moving a card across the lists in a Kanban board, you want it to retain the dragged appearance—even though
* technically, the component gets unmounted and a different one gets mounted every time you move it to another list.
*
* Note: You may not call monitor.isDragging() inside this method.
*/
isDragging?: (monitor: DragSourceMonitor<DragObject, DropResult>) => boolean;
/**
* A function to collect rendering properties
*/
collect?: (monitor: DragSourceMonitor<DragObject, DropResult>) => CollectedProps;
}
/**
* Interface for the DropTarget specification object
*/
export interface DropTargetHookSpec<DragObject, DropResult, CollectedProps> {
/**
* The kinds of dragItems this dropTarget accepts
*/
accept: TargetType;
/**
* The drop target options
*/
options?: DropTargetOptions;
/**
* Optional.
* Called when a compatible item is dropped on the target. You may either return undefined, or a plain object.
* If you return an object, it is going to become the drop result and will be available to the drag source in its
* endDrag method as monitor.getDropResult(). This is useful in case you want to perform different actions
* depending on which target received the drop. If you have nested drop targets, you can test whether a nested
* target has already handled drop by checking monitor.didDrop() and monitor.getDropResult(). Both this method and
* the source's endDrag method are good places to fire Flux actions. This method will not be called if canDrop()
* is defined and returns false.
*/
drop?: (item: DragObject, monitor: DropTargetMonitor<DragObject, DropResult>) => DropResult | undefined;
/**
* Optional.
* Called when an item is hovered over the component. You can check monitor.isOver({ shallow: true }) to test whether
* the hover happens over just the current target, or over a nested one. Unlike drop(), this method will be called even
* if canDrop() is defined and returns false. You can check monitor.canDrop() to test whether this is the case.
*/
hover?: (item: DragObject, monitor: DropTargetMonitor<DragObject, DropResult>) => void;
/**
* Optional. Use it to specify whether the drop target is able to accept the item. If you want to always allow it, just
* omit this method. Specifying it is handy if you'd like to disable dropping based on some predicate over props or
* monitor.getItem(). Note: You may not call monitor.canDrop() inside this method.
*/
canDrop?: (item: DragObject, monitor: DropTargetMonitor<DragObject, DropResult>) => boolean;
/**
* A function to collect rendering properties
*/
collect?: (monitor: DropTargetMonitor<DragObject, DropResult>) => CollectedProps;
}

View File

@@ -1,3 +0,0 @@
export { };
//# sourceMappingURL=types.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +0,0 @@
import type { Connector } from '../internals/index.js';
import type { HandlerManager, MonitorEventEmitter } from '../types/index.js';
export declare function useCollectedProps<Collected, Monitor extends HandlerManager>(collector: ((monitor: Monitor) => Collected) | undefined, monitor: Monitor & MonitorEventEmitter, connector: Connector): Collected;

View File

@@ -1,8 +0,0 @@
import { useMonitorOutput } from './useMonitorOutput.js';
export function useCollectedProps(collector, monitor, connector) {
return useMonitorOutput(monitor, collector || (()=>({})
), ()=>connector.reconnect()
);
}
//# sourceMappingURL=useCollectedProps.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useCollectedProps.ts"],"sourcesContent":["import type { Connector } from '../internals/index.js'\nimport type { HandlerManager, MonitorEventEmitter } from '../types/index.js'\nimport { useMonitorOutput } from './useMonitorOutput.js'\n\nexport function useCollectedProps<Collected, Monitor extends HandlerManager>(\n\tcollector: ((monitor: Monitor) => Collected) | undefined,\n\tmonitor: Monitor & MonitorEventEmitter,\n\tconnector: Connector,\n) {\n\treturn useMonitorOutput(monitor, collector || (() => ({} as Collected)), () =>\n\t\tconnector.reconnect(),\n\t)\n}\n"],"names":["useMonitorOutput","useCollectedProps","collector","monitor","connector","reconnect"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,uBAAuB,CAAA;AAExD,OAAO,SAASC,iBAAiB,CAChCC,SAAwD,EACxDC,OAAsC,EACtCC,SAAoB,EACnB;IACD,OAAOJ,gBAAgB,CAACG,OAAO,EAAED,SAAS,IAAI,CAAC,IAAM,CAAC,EAAE,CAAc;IAAA,CAAC,EAAE,IACxEE,SAAS,CAACC,SAAS,EAAE;IAAA,CACrB,CAAA;CACD"}

View File

@@ -1,7 +0,0 @@
/**
*
* @param monitor The monitor to collect state from
* @param collect The collecting function
* @param onUpdate A method to invoke when updates occur
*/
export declare function useCollector<T, S>(monitor: T, collect: (monitor: T) => S, onUpdate?: () => void): [S, () => void];

View File

@@ -1,37 +0,0 @@
import equal from 'fast-deep-equal';
import { useCallback, useState } from 'react';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
/**
*
* @param monitor The monitor to collect state from
* @param collect The collecting function
* @param onUpdate A method to invoke when updates occur
*/ export function useCollector(monitor, collect, onUpdate) {
const [collected, setCollected] = useState(()=>collect(monitor)
);
const updateCollected = useCallback(()=>{
const nextValue = collect(monitor);
// This needs to be a deep-equality check because some monitor-collected values
// include XYCoord objects that may be equivalent, but do not have instance equality.
if (!equal(collected, nextValue)) {
setCollected(nextValue);
if (onUpdate) {
onUpdate();
}
}
}, [
collected,
monitor,
onUpdate
]);
// update the collected properties after react renders.
// Note that the "Dustbin Stress Test" fails if this is not
// done when the component updates
useIsomorphicLayoutEffect(updateCollected);
return [
collected,
updateCollected
];
}
//# sourceMappingURL=useCollector.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useCollector.ts"],"sourcesContent":["import equal from 'fast-deep-equal'\nimport { useCallback, useState } from 'react'\n\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js'\n\n/**\n *\n * @param monitor The monitor to collect state from\n * @param collect The collecting function\n * @param onUpdate A method to invoke when updates occur\n */\nexport function useCollector<T, S>(\n\tmonitor: T,\n\tcollect: (monitor: T) => S,\n\tonUpdate?: () => void,\n): [S, () => void] {\n\tconst [collected, setCollected] = useState(() => collect(monitor))\n\n\tconst updateCollected = useCallback(() => {\n\t\tconst nextValue = collect(monitor)\n\t\t// This needs to be a deep-equality check because some monitor-collected values\n\t\t// include XYCoord objects that may be equivalent, but do not have instance equality.\n\t\tif (!equal(collected, nextValue)) {\n\t\t\tsetCollected(nextValue)\n\t\t\tif (onUpdate) {\n\t\t\t\tonUpdate()\n\t\t\t}\n\t\t}\n\t}, [collected, monitor, onUpdate])\n\n\t// update the collected properties after react renders.\n\t// Note that the \"Dustbin Stress Test\" fails if this is not\n\t// done when the component updates\n\tuseIsomorphicLayoutEffect(updateCollected)\n\n\treturn [collected, updateCollected]\n}\n"],"names":["equal","useCallback","useState","useIsomorphicLayoutEffect","useCollector","monitor","collect","onUpdate","collected","setCollected","updateCollected","nextValue"],"mappings":"AAAA,OAAOA,KAAK,MAAM,iBAAiB,CAAA;AACnC,SAASC,WAAW,EAAEC,QAAQ,QAAQ,OAAO,CAAA;AAE7C,SAASC,yBAAyB,QAAQ,gCAAgC,CAAA;AAE1E;;;;;GAKG,CACH,OAAO,SAASC,YAAY,CAC3BC,OAAU,EACVC,OAA0B,EAC1BC,QAAqB,EACH;IAClB,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGP,QAAQ,CAAC,IAAMI,OAAO,CAACD,OAAO,CAAC;IAAA,CAAC;IAElE,MAAMK,eAAe,GAAGT,WAAW,CAAC,IAAM;QACzC,MAAMU,SAAS,GAAGL,OAAO,CAACD,OAAO,CAAC;QAClC,+EAA+E;QAC/E,qFAAqF;QACrF,IAAI,CAACL,KAAK,CAACQ,SAAS,EAAEG,SAAS,CAAC,EAAE;YACjCF,YAAY,CAACE,SAAS,CAAC;YACvB,IAAIJ,QAAQ,EAAE;gBACbA,QAAQ,EAAE;aACV;SACD;KACD,EAAE;QAACC,SAAS;QAAEH,OAAO;QAAEE,QAAQ;KAAC,CAAC;IAElC,uDAAuD;IACvD,2DAA2D;IAC3D,kCAAkC;IAClCJ,yBAAyB,CAACO,eAAe,CAAC;IAE1C,OAAO;QAACF,SAAS;QAAEE,eAAe;KAAC,CAAA;CACnC"}

View File

@@ -1,14 +0,0 @@
import type { DragDropMonitor, DragSource, Identifier } from 'dnd-core';
import type { Connector } from '../../internals/index.js';
import type { DragSourceMonitor } from '../../types/index.js';
import type { DragSourceHookSpec } from '../types.js';
export declare class DragSourceImpl<O, R, P> implements DragSource {
spec: DragSourceHookSpec<O, R, P>;
private monitor;
private connector;
constructor(spec: DragSourceHookSpec<O, R, P>, monitor: DragSourceMonitor<O, R>, connector: Connector);
beginDrag(): NonNullable<O> | null;
canDrag(): boolean;
isDragging(globalMonitor: DragDropMonitor, target: Identifier): boolean;
endDrag(): void;
}

View File

@@ -1,49 +0,0 @@
export class DragSourceImpl {
beginDrag() {
const spec = this.spec;
const monitor = this.monitor;
let result = null;
if (typeof spec.item === 'object') {
result = spec.item;
} else if (typeof spec.item === 'function') {
result = spec.item(monitor);
} else {
result = {};
}
return result !== null && result !== void 0 ? result : null;
}
canDrag() {
const spec = this.spec;
const monitor = this.monitor;
if (typeof spec.canDrag === 'boolean') {
return spec.canDrag;
} else if (typeof spec.canDrag === 'function') {
return spec.canDrag(monitor);
} else {
return true;
}
}
isDragging(globalMonitor, target) {
const spec = this.spec;
const monitor = this.monitor;
const { isDragging } = spec;
return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId();
}
endDrag() {
const spec = this.spec;
const monitor = this.monitor;
const connector = this.connector;
const { end } = spec;
if (end) {
end(monitor.getItem(), monitor);
}
connector.reconnect();
}
constructor(spec, monitor, connector){
this.spec = spec;
this.monitor = monitor;
this.connector = connector;
}
}
//# sourceMappingURL=DragSourceImpl.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/DragSourceImpl.ts"],"sourcesContent":["import type { DragDropMonitor, DragSource, Identifier } from 'dnd-core'\n\nimport type { Connector } from '../../internals/index.js'\nimport type { DragSourceMonitor } from '../../types/index.js'\nimport type { DragObjectFactory, DragSourceHookSpec } from '../types.js'\n\nexport class DragSourceImpl<O, R, P> implements DragSource {\n\tpublic constructor(\n\t\tpublic spec: DragSourceHookSpec<O, R, P>,\n\t\tprivate monitor: DragSourceMonitor<O, R>,\n\t\tprivate connector: Connector,\n\t) {}\n\n\tpublic beginDrag() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\n\t\tlet result: O | null = null\n\t\tif (typeof spec.item === 'object') {\n\t\t\tresult = spec.item as O\n\t\t} else if (typeof spec.item === 'function') {\n\t\t\tresult = (spec.item as DragObjectFactory<O>)(monitor)\n\t\t} else {\n\t\t\tresult = {} as O\n\t\t}\n\t\treturn result ?? null\n\t}\n\n\tpublic canDrag() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\tif (typeof spec.canDrag === 'boolean') {\n\t\t\treturn spec.canDrag\n\t\t} else if (typeof spec.canDrag === 'function') {\n\t\t\treturn spec.canDrag(monitor)\n\t\t} else {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tpublic isDragging(globalMonitor: DragDropMonitor, target: Identifier) {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\tconst { isDragging } = spec\n\t\treturn isDragging\n\t\t\t? isDragging(monitor)\n\t\t\t: target === globalMonitor.getSourceId()\n\t}\n\n\tpublic endDrag() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\tconst connector = this.connector\n\t\tconst { end } = spec\n\t\tif (end) {\n\t\t\tend(monitor.getItem(), monitor)\n\t\t}\n\t\tconnector.reconnect()\n\t}\n}\n"],"names":["DragSourceImpl","beginDrag","spec","monitor","result","item","canDrag","isDragging","globalMonitor","target","getSourceId","endDrag","connector","end","getItem","reconnect"],"mappings":"AAMA,OAAO,MAAMA,cAAc;IAO1B,AAAOC,SAAS,GAAG;QAClB,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAE5B,IAAIC,MAAM,GAAa,IAAI;QAC3B,IAAI,OAAOF,IAAI,CAACG,IAAI,KAAK,QAAQ,EAAE;YAClCD,MAAM,GAAGF,IAAI,CAACG,IAAI,AAAK;SACvB,MAAM,IAAI,OAAOH,IAAI,CAACG,IAAI,KAAK,UAAU,EAAE;YAC3CD,MAAM,GAAG,AAACF,IAAI,CAACG,IAAI,CAA0BF,OAAO,CAAC;SACrD,MAAM;YACNC,MAAM,GAAG,EAAE,AAAK;SAChB;QACD,OAAOA,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,IAAI,CAAA;KACrB;IAED,AAAOE,OAAO,GAAG;QAChB,MAAMJ,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,IAAI,OAAOD,IAAI,CAACI,OAAO,KAAK,SAAS,EAAE;YACtC,OAAOJ,IAAI,CAACI,OAAO,CAAA;SACnB,MAAM,IAAI,OAAOJ,IAAI,CAACI,OAAO,KAAK,UAAU,EAAE;YAC9C,OAAOJ,IAAI,CAACI,OAAO,CAACH,OAAO,CAAC,CAAA;SAC5B,MAAM;YACN,OAAO,IAAI,CAAA;SACX;KACD;IAED,AAAOI,UAAU,CAACC,aAA8B,EAAEC,MAAkB,EAAE;QACrE,MAAMP,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,MAAM,EAAEI,UAAU,CAAA,EAAE,GAAGL,IAAI;QAC3B,OAAOK,UAAU,GACdA,UAAU,CAACJ,OAAO,CAAC,GACnBM,MAAM,KAAKD,aAAa,CAACE,WAAW,EAAE,CAAA;KACzC;IAED,AAAOC,OAAO,GAAG;QAChB,MAAMT,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,MAAMS,SAAS,GAAG,IAAI,CAACA,SAAS;QAChC,MAAM,EAAEC,GAAG,CAAA,EAAE,GAAGX,IAAI;QACpB,IAAIW,GAAG,EAAE;YACRA,GAAG,CAACV,OAAO,CAACW,OAAO,EAAE,EAAEX,OAAO,CAAC;SAC/B;QACDS,SAAS,CAACG,SAAS,EAAE;KACrB;IAnDD,YACQb,IAAiC,EAChCC,OAAgC,EAChCS,SAAoB,CAC3B;aAHMV,IAAiC,GAAjCA,IAAiC;aAChCC,OAAgC,GAAhCA,OAAgC;aAChCS,SAAoB,GAApBA,SAAoB;KACzB;CAgDJ"}

View File

@@ -1,3 +0,0 @@
import type { SourceConnector } from '../../internals/index.js';
export declare function useConnectDragSource(connector: SourceConnector): any;
export declare function useConnectDragPreview(connector: SourceConnector): any;

View File

@@ -1,15 +0,0 @@
import { useMemo } from 'react';
export function useConnectDragSource(connector) {
return useMemo(()=>connector.hooks.dragSource()
, [
connector
]);
}
export function useConnectDragPreview(connector) {
return useMemo(()=>connector.hooks.dragPreview()
, [
connector
]);
}
//# sourceMappingURL=connectors.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/connectors.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport type { SourceConnector } from '../../internals/index.js'\n\nexport function useConnectDragSource(connector: SourceConnector) {\n\treturn useMemo(() => connector.hooks.dragSource(), [connector])\n}\n\nexport function useConnectDragPreview(connector: SourceConnector) {\n\treturn useMemo(() => connector.hooks.dragPreview(), [connector])\n}\n"],"names":["useMemo","useConnectDragSource","connector","hooks","dragSource","useConnectDragPreview","dragPreview"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAI/B,OAAO,SAASC,oBAAoB,CAACC,SAA0B,EAAE;IAChE,OAAOF,OAAO,CAAC,IAAME,SAAS,CAACC,KAAK,CAACC,UAAU,EAAE;IAAA,EAAE;QAACF,SAAS;KAAC,CAAC,CAAA;CAC/D;AAED,OAAO,SAASG,qBAAqB,CAACH,SAA0B,EAAE;IACjE,OAAOF,OAAO,CAAC,IAAME,SAAS,CAACC,KAAK,CAACG,WAAW,EAAE;IAAA,EAAE;QAACJ,SAAS;KAAC,CAAC,CAAA;CAChE"}

View File

@@ -1 +0,0 @@
export * from './useDrag.js';

View File

@@ -1,3 +0,0 @@
export * from './useDrag.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/index.ts"],"sourcesContent":["export * from './useDrag.js'\n"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}

View File

@@ -1,8 +0,0 @@
import type { ConnectDragPreview, ConnectDragSource } from '../../types/index.js';
import type { DragSourceHookSpec, FactoryOrInstance } from '../types.js';
/**
* useDragSource hook
* @param sourceSpec The drag source specification (object or function, function preferred)
* @param deps The memoization deps array to use when evaluating spec changes
*/
export declare function useDrag<DragObject = unknown, DropResult = unknown, CollectedProps = unknown>(specArg: FactoryOrInstance<DragSourceHookSpec<DragObject, DropResult, CollectedProps>>, deps?: unknown[]): [CollectedProps, ConnectDragSource, ConnectDragPreview];

View File

@@ -1,25 +0,0 @@
import { invariant } from '@react-dnd/invariant';
import { useCollectedProps } from '../useCollectedProps.js';
import { useOptionalFactory } from '../useOptionalFactory.js';
import { useConnectDragPreview, useConnectDragSource } from './connectors.js';
import { useDragSourceConnector } from './useDragSourceConnector.js';
import { useDragSourceMonitor } from './useDragSourceMonitor.js';
import { useRegisteredDragSource } from './useRegisteredDragSource.js';
/**
* useDragSource hook
* @param sourceSpec The drag source specification (object or function, function preferred)
* @param deps The memoization deps array to use when evaluating spec changes
*/ export function useDrag(specArg, deps) {
const spec = useOptionalFactory(specArg, deps);
invariant(!spec.begin, `useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`);
const monitor = useDragSourceMonitor();
const connector = useDragSourceConnector(spec.options, spec.previewOptions);
useRegisteredDragSource(spec, monitor, connector);
return [
useCollectedProps(spec.collect, monitor, connector),
useConnectDragSource(connector),
useConnectDragPreview(connector),
];
}
//# sourceMappingURL=useDrag.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useDrag.ts"],"sourcesContent":["import { invariant } from '@react-dnd/invariant'\n\nimport type {\n\tConnectDragPreview,\n\tConnectDragSource,\n} from '../../types/index.js'\nimport type { DragSourceHookSpec, FactoryOrInstance } from '../types.js'\nimport { useCollectedProps } from '../useCollectedProps.js'\nimport { useOptionalFactory } from '../useOptionalFactory.js'\nimport { useConnectDragPreview, useConnectDragSource } from './connectors.js'\nimport { useDragSourceConnector } from './useDragSourceConnector.js'\nimport { useDragSourceMonitor } from './useDragSourceMonitor.js'\nimport { useRegisteredDragSource } from './useRegisteredDragSource.js'\n\n/**\n * useDragSource hook\n * @param sourceSpec The drag source specification (object or function, function preferred)\n * @param deps The memoization deps array to use when evaluating spec changes\n */\nexport function useDrag<\n\tDragObject = unknown,\n\tDropResult = unknown,\n\tCollectedProps = unknown,\n>(\n\tspecArg: FactoryOrInstance<\n\t\tDragSourceHookSpec<DragObject, DropResult, CollectedProps>\n\t>,\n\tdeps?: unknown[],\n): [CollectedProps, ConnectDragSource, ConnectDragPreview] {\n\tconst spec = useOptionalFactory(specArg, deps)\n\tinvariant(\n\t\t!(spec as any).begin,\n\t\t`useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)`,\n\t)\n\n\tconst monitor = useDragSourceMonitor<DragObject, DropResult>()\n\tconst connector = useDragSourceConnector(spec.options, spec.previewOptions)\n\tuseRegisteredDragSource(spec, monitor, connector)\n\n\treturn [\n\t\tuseCollectedProps(spec.collect, monitor, connector),\n\t\tuseConnectDragSource(connector),\n\t\tuseConnectDragPreview(connector),\n\t]\n}\n"],"names":["invariant","useCollectedProps","useOptionalFactory","useConnectDragPreview","useConnectDragSource","useDragSourceConnector","useDragSourceMonitor","useRegisteredDragSource","useDrag","specArg","deps","spec","begin","monitor","connector","options","previewOptions","collect"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sBAAsB,CAAA;AAOhD,SAASC,iBAAiB,QAAQ,yBAAyB,CAAA;AAC3D,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,qBAAqB,EAAEC,oBAAoB,QAAQ,iBAAiB,CAAA;AAC7E,SAASC,sBAAsB,QAAQ,6BAA6B,CAAA;AACpE,SAASC,oBAAoB,QAAQ,2BAA2B,CAAA;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B,CAAA;AAEtE;;;;GAIG,CACH,OAAO,SAASC,OAAO,CAKtBC,OAEC,EACDC,IAAgB,EAC0C;IAC1D,MAAMC,IAAI,GAAGT,kBAAkB,CAACO,OAAO,EAAEC,IAAI,CAAC;IAC9CV,SAAS,CACR,CAAC,AAACW,IAAI,CAASC,KAAK,EACpB,CAAC,2JAA2J,CAAC,CAC7J;IAED,MAAMC,OAAO,GAAGP,oBAAoB,EAA0B;IAC9D,MAAMQ,SAAS,GAAGT,sBAAsB,CAACM,IAAI,CAACI,OAAO,EAAEJ,IAAI,CAACK,cAAc,CAAC;IAC3ET,uBAAuB,CAACI,IAAI,EAAEE,OAAO,EAAEC,SAAS,CAAC;IAEjD,OAAO;QACNb,iBAAiB,CAACU,IAAI,CAACM,OAAO,EAAEJ,OAAO,EAAEC,SAAS,CAAC;QACnDV,oBAAoB,CAACU,SAAS,CAAC;QAC/BX,qBAAqB,CAACW,SAAS,CAAC;KAChC,CAAA;CACD"}

View File

@@ -1,5 +0,0 @@
import type { Connector } from '../../internals/index.js';
import type { DragSourceMonitor } from '../../types/index.js';
import type { DragSourceHookSpec } from '../types.js';
import { DragSourceImpl } from './DragSourceImpl.js';
export declare function useDragSource<O, R, P>(spec: DragSourceHookSpec<O, R, P>, monitor: DragSourceMonitor<O, R>, connector: Connector): DragSourceImpl<O, R, P>;

View File

@@ -1,17 +0,0 @@
import { useEffect, useMemo } from 'react';
import { DragSourceImpl } from './DragSourceImpl.js';
export function useDragSource(spec, monitor, connector) {
const handler = useMemo(()=>new DragSourceImpl(spec, monitor, connector)
, [
monitor,
connector
]);
useEffect(()=>{
handler.spec = spec;
}, [
spec
]);
return handler;
}
//# sourceMappingURL=useDragSource.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useDragSource.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react'\n\nimport type { Connector } from '../../internals/index.js'\nimport type { DragSourceMonitor } from '../../types/index.js'\nimport type { DragSourceHookSpec } from '../types.js'\nimport { DragSourceImpl } from './DragSourceImpl.js'\n\nexport function useDragSource<O, R, P>(\n\tspec: DragSourceHookSpec<O, R, P>,\n\tmonitor: DragSourceMonitor<O, R>,\n\tconnector: Connector,\n) {\n\tconst handler = useMemo(\n\t\t() => new DragSourceImpl(spec, monitor, connector),\n\t\t[monitor, connector],\n\t)\n\tuseEffect(() => {\n\t\thandler.spec = spec\n\t}, [spec])\n\treturn handler\n}\n"],"names":["useEffect","useMemo","DragSourceImpl","useDragSource","spec","monitor","connector","handler"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO,CAAA;AAK1C,SAASC,cAAc,QAAQ,qBAAqB,CAAA;AAEpD,OAAO,SAASC,aAAa,CAC5BC,IAAiC,EACjCC,OAAgC,EAChCC,SAAoB,EACnB;IACD,MAAMC,OAAO,GAAGN,OAAO,CACtB,IAAM,IAAIC,cAAc,CAACE,IAAI,EAAEC,OAAO,EAAEC,SAAS,CAAC;IAAA,EAClD;QAACD,OAAO;QAAEC,SAAS;KAAC,CACpB;IACDN,SAAS,CAAC,IAAM;QACfO,OAAO,CAACH,IAAI,GAAGA,IAAI;KACnB,EAAE;QAACA,IAAI;KAAC,CAAC;IACV,OAAOG,OAAO,CAAA;CACd"}

View File

@@ -1,3 +0,0 @@
import { SourceConnector } from '../../internals/index.js';
import type { DragPreviewOptions, DragSourceOptions } from '../../types/index.js';
export declare function useDragSourceConnector(dragSourceOptions: DragSourceOptions | undefined, dragPreviewOptions: DragPreviewOptions | undefined): SourceConnector;

View File

@@ -1,32 +0,0 @@
import { useMemo } from 'react';
import { SourceConnector } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js';
export function useDragSourceConnector(dragSourceOptions, dragPreviewOptions) {
const manager = useDragDropManager();
const connector = useMemo(()=>new SourceConnector(manager.getBackend())
, [
manager
]);
useIsomorphicLayoutEffect(()=>{
connector.dragSourceOptions = dragSourceOptions || null;
connector.reconnect();
return ()=>connector.disconnectDragSource()
;
}, [
connector,
dragSourceOptions
]);
useIsomorphicLayoutEffect(()=>{
connector.dragPreviewOptions = dragPreviewOptions || null;
connector.reconnect();
return ()=>connector.disconnectDragPreview()
;
}, [
connector,
dragPreviewOptions
]);
return connector;
}
//# sourceMappingURL=useDragSourceConnector.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useDragSourceConnector.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { SourceConnector } from '../../internals/index.js'\nimport type {\n\tDragPreviewOptions,\n\tDragSourceOptions,\n} from '../../types/index.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js'\n\nexport function useDragSourceConnector(\n\tdragSourceOptions: DragSourceOptions | undefined,\n\tdragPreviewOptions: DragPreviewOptions | undefined,\n): SourceConnector {\n\tconst manager = useDragDropManager()\n\tconst connector = useMemo(\n\t\t() => new SourceConnector(manager.getBackend()),\n\t\t[manager],\n\t)\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconnector.dragSourceOptions = dragSourceOptions || null\n\t\tconnector.reconnect()\n\t\treturn () => connector.disconnectDragSource()\n\t}, [connector, dragSourceOptions])\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconnector.dragPreviewOptions = dragPreviewOptions || null\n\t\tconnector.reconnect()\n\t\treturn () => connector.disconnectDragPreview()\n\t}, [connector, dragPreviewOptions])\n\treturn connector\n}\n"],"names":["useMemo","SourceConnector","useDragDropManager","useIsomorphicLayoutEffect","useDragSourceConnector","dragSourceOptions","dragPreviewOptions","manager","connector","getBackend","reconnect","disconnectDragSource","disconnectDragPreview"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAE/B,SAASC,eAAe,QAAQ,0BAA0B,CAAA;AAK1D,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,yBAAyB,QAAQ,iCAAiC,CAAA;AAE3E,OAAO,SAASC,sBAAsB,CACrCC,iBAAgD,EAChDC,kBAAkD,EAChC;IAClB,MAAMC,OAAO,GAAGL,kBAAkB,EAAE;IACpC,MAAMM,SAAS,GAAGR,OAAO,CACxB,IAAM,IAAIC,eAAe,CAACM,OAAO,CAACE,UAAU,EAAE,CAAC;IAAA,EAC/C;QAACF,OAAO;KAAC,CACT;IACDJ,yBAAyB,CAAC,IAAM;QAC/BK,SAAS,CAACH,iBAAiB,GAAGA,iBAAiB,IAAI,IAAI;QACvDG,SAAS,CAACE,SAAS,EAAE;QACrB,OAAO,IAAMF,SAAS,CAACG,oBAAoB,EAAE;QAAA,CAAA;KAC7C,EAAE;QAACH,SAAS;QAAEH,iBAAiB;KAAC,CAAC;IAClCF,yBAAyB,CAAC,IAAM;QAC/BK,SAAS,CAACF,kBAAkB,GAAGA,kBAAkB,IAAI,IAAI;QACzDE,SAAS,CAACE,SAAS,EAAE;QACrB,OAAO,IAAMF,SAAS,CAACI,qBAAqB,EAAE;QAAA,CAAA;KAC9C,EAAE;QAACJ,SAAS;QAAEF,kBAAkB;KAAC,CAAC;IACnC,OAAOE,SAAS,CAAA;CAChB"}

View File

@@ -1,2 +0,0 @@
import type { DragSourceMonitor } from '../../types/index.js';
export declare function useDragSourceMonitor<O, R>(): DragSourceMonitor<O, R>;

View File

@@ -1,12 +0,0 @@
import { useMemo } from 'react';
import { DragSourceMonitorImpl } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
export function useDragSourceMonitor() {
const manager = useDragDropManager();
return useMemo(()=>new DragSourceMonitorImpl(manager)
, [
manager
]);
}
//# sourceMappingURL=useDragSourceMonitor.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useDragSourceMonitor.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { DragSourceMonitorImpl } from '../../internals/index.js'\nimport type { DragSourceMonitor } from '../../types/index.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\n\nexport function useDragSourceMonitor<O, R>(): DragSourceMonitor<O, R> {\n\tconst manager = useDragDropManager()\n\treturn useMemo<DragSourceMonitor<O, R>>(\n\t\t() => new DragSourceMonitorImpl(manager),\n\t\t[manager],\n\t)\n}\n"],"names":["useMemo","DragSourceMonitorImpl","useDragDropManager","useDragSourceMonitor","manager"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAE/B,SAASC,qBAAqB,QAAQ,0BAA0B,CAAA;AAEhE,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAE7D,OAAO,SAASC,oBAAoB,GAAkC;IACrE,MAAMC,OAAO,GAAGF,kBAAkB,EAAE;IACpC,OAAOF,OAAO,CACb,IAAM,IAAIC,qBAAqB,CAACG,OAAO,CAAC;IAAA,EACxC;QAACA,OAAO;KAAC,CACT,CAAA;CACD"}

View File

@@ -1,3 +0,0 @@
import type { Identifier } from 'dnd-core';
import type { DragSourceHookSpec } from '../types.js';
export declare function useDragType(spec: DragSourceHookSpec<any, any, any>): Identifier;

View File

@@ -1,13 +0,0 @@
import { invariant } from '@react-dnd/invariant';
import { useMemo } from 'react';
export function useDragType(spec) {
return useMemo(()=>{
const result = spec.type;
invariant(result != null, 'spec.type must be defined');
return result;
}, [
spec
]);
}
//# sourceMappingURL=useDragType.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useDragType.ts"],"sourcesContent":["import { invariant } from '@react-dnd/invariant'\nimport type { Identifier } from 'dnd-core'\nimport { useMemo } from 'react'\n\nimport type { DragSourceHookSpec } from '../types.js'\n\nexport function useDragType(\n\tspec: DragSourceHookSpec<any, any, any>,\n): Identifier {\n\treturn useMemo(() => {\n\t\tconst result: Identifier = spec.type\n\t\tinvariant(result != null, 'spec.type must be defined')\n\t\treturn result\n\t}, [spec])\n}\n"],"names":["invariant","useMemo","useDragType","spec","result","type"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sBAAsB,CAAA;AAEhD,SAASC,OAAO,QAAQ,OAAO,CAAA;AAI/B,OAAO,SAASC,WAAW,CAC1BC,IAAuC,EAC1B;IACb,OAAOF,OAAO,CAAC,IAAM;QACpB,MAAMG,MAAM,GAAeD,IAAI,CAACE,IAAI;QACpCL,SAAS,CAACI,MAAM,IAAI,IAAI,EAAE,2BAA2B,CAAC;QACtD,OAAOA,MAAM,CAAA;KACb,EAAE;QAACD,IAAI;KAAC,CAAC,CAAA;CACV"}

View File

@@ -1,4 +0,0 @@
import type { SourceConnector } from '../../internals/index.js';
import type { DragSourceMonitor } from '../../types/index.js';
import type { DragSourceHookSpec } from '../types.js';
export declare function useRegisteredDragSource<O, R, P>(spec: DragSourceHookSpec<O, R, P>, monitor: DragSourceMonitor<O, R>, connector: SourceConnector): void;

View File

@@ -1,27 +0,0 @@
import { registerSource } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js';
import { useDragSource } from './useDragSource.js';
import { useDragType } from './useDragType.js';
export function useRegisteredDragSource(spec, monitor, connector) {
const manager = useDragDropManager();
const handler = useDragSource(spec, monitor, connector);
const itemType = useDragType(spec);
useIsomorphicLayoutEffect(function registerDragSource() {
if (itemType != null) {
const [handlerId, unregister] = registerSource(itemType, handler, manager);
monitor.receiveHandlerId(handlerId);
connector.receiveHandlerId(handlerId);
return unregister;
}
return;
}, [
manager,
monitor,
connector,
handler,
itemType
]);
}
//# sourceMappingURL=useRegisteredDragSource.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrag/useRegisteredDragSource.ts"],"sourcesContent":["import type { SourceConnector } from '../../internals/index.js'\nimport { registerSource } from '../../internals/index.js'\nimport type { DragSourceMonitor } from '../../types/index.js'\nimport type { DragSourceHookSpec } from '../types.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js'\nimport { useDragSource } from './useDragSource.js'\nimport { useDragType } from './useDragType.js'\n\nexport function useRegisteredDragSource<O, R, P>(\n\tspec: DragSourceHookSpec<O, R, P>,\n\tmonitor: DragSourceMonitor<O, R>,\n\tconnector: SourceConnector,\n): void {\n\tconst manager = useDragDropManager()\n\tconst handler = useDragSource(spec, monitor, connector)\n\tconst itemType = useDragType(spec)\n\n\tuseIsomorphicLayoutEffect(\n\t\tfunction registerDragSource() {\n\t\t\tif (itemType != null) {\n\t\t\t\tconst [handlerId, unregister] = registerSource(\n\t\t\t\t\titemType,\n\t\t\t\t\thandler,\n\t\t\t\t\tmanager,\n\t\t\t\t)\n\t\t\t\tmonitor.receiveHandlerId(handlerId)\n\t\t\t\tconnector.receiveHandlerId(handlerId)\n\t\t\t\treturn unregister\n\t\t\t}\n\t\t\treturn\n\t\t},\n\t\t[manager, monitor, connector, handler, itemType],\n\t)\n}\n"],"names":["registerSource","useDragDropManager","useIsomorphicLayoutEffect","useDragSource","useDragType","useRegisteredDragSource","spec","monitor","connector","manager","handler","itemType","registerDragSource","handlerId","unregister","receiveHandlerId"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B,CAAA;AAGzD,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,yBAAyB,QAAQ,iCAAiC,CAAA;AAC3E,SAASC,aAAa,QAAQ,oBAAoB,CAAA;AAClD,SAASC,WAAW,QAAQ,kBAAkB,CAAA;AAE9C,OAAO,SAASC,uBAAuB,CACtCC,IAAiC,EACjCC,OAAgC,EAChCC,SAA0B,EACnB;IACP,MAAMC,OAAO,GAAGR,kBAAkB,EAAE;IACpC,MAAMS,OAAO,GAAGP,aAAa,CAACG,IAAI,EAAEC,OAAO,EAAEC,SAAS,CAAC;IACvD,MAAMG,QAAQ,GAAGP,WAAW,CAACE,IAAI,CAAC;IAElCJ,yBAAyB,CACxB,SAASU,kBAAkB,GAAG;QAC7B,IAAID,QAAQ,IAAI,IAAI,EAAE;YACrB,MAAM,CAACE,SAAS,EAAEC,UAAU,CAAC,GAAGd,cAAc,CAC7CW,QAAQ,EACRD,OAAO,EACPD,OAAO,CACP;YACDF,OAAO,CAACQ,gBAAgB,CAACF,SAAS,CAAC;YACnCL,SAAS,CAACO,gBAAgB,CAACF,SAAS,CAAC;YACrC,OAAOC,UAAU,CAAA;SACjB;QACD,OAAM;KACN,EACD;QAACL,OAAO;QAAEF,OAAO;QAAEC,SAAS;QAAEE,OAAO;QAAEC,QAAQ;KAAC,CAChD;CACD"}

View File

@@ -1,5 +0,0 @@
import type { DragDropManager } from 'dnd-core';
/**
* A hook to retrieve the DragDropManager from Context
*/
export declare function useDragDropManager(): DragDropManager;

View File

@@ -1,12 +0,0 @@
import { invariant } from '@react-dnd/invariant';
import { useContext } from 'react';
import { DndContext } from '../core/index.js';
/**
* A hook to retrieve the DragDropManager from Context
*/ export function useDragDropManager() {
const { dragDropManager } = useContext(DndContext);
invariant(dragDropManager != null, 'Expected drag drop context');
return dragDropManager;
}
//# sourceMappingURL=useDragDropManager.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useDragDropManager.ts"],"sourcesContent":["import { invariant } from '@react-dnd/invariant'\nimport type { DragDropManager } from 'dnd-core'\nimport { useContext } from 'react'\n\nimport { DndContext } from '../core/index.js'\n\n/**\n * A hook to retrieve the DragDropManager from Context\n */\nexport function useDragDropManager(): DragDropManager {\n\tconst { dragDropManager } = useContext(DndContext)\n\tinvariant(dragDropManager != null, 'Expected drag drop context')\n\treturn dragDropManager as DragDropManager\n}\n"],"names":["invariant","useContext","DndContext","useDragDropManager","dragDropManager"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sBAAsB,CAAA;AAEhD,SAASC,UAAU,QAAQ,OAAO,CAAA;AAElC,SAASC,UAAU,QAAQ,kBAAkB,CAAA;AAE7C;;GAEG,CACH,OAAO,SAASC,kBAAkB,GAAoB;IACrD,MAAM,EAAEC,eAAe,CAAA,EAAE,GAAGH,UAAU,CAACC,UAAU,CAAC;IAClDF,SAAS,CAACI,eAAe,IAAI,IAAI,EAAE,4BAA4B,CAAC;IAChE,OAAOA,eAAe,CAAmB;CACzC"}

View File

@@ -1,6 +0,0 @@
import type { DragLayerMonitor } from '../types/index.js';
/**
* useDragLayer Hook
* @param collector The property collector
*/
export declare function useDragLayer<CollectedProps, DragObject = any>(collect: (monitor: DragLayerMonitor<DragObject>) => CollectedProps): CollectedProps;

View File

@@ -1,18 +0,0 @@
import { useEffect } from 'react';
import { useCollector } from './useCollector.js';
import { useDragDropManager } from './useDragDropManager.js';
/**
* useDragLayer Hook
* @param collector The property collector
*/ export function useDragLayer(collect) {
const dragDropManager = useDragDropManager();
const monitor = dragDropManager.getMonitor();
const [collected, updateCollected] = useCollector(monitor, collect);
useEffect(()=>monitor.subscribeToOffsetChange(updateCollected)
);
useEffect(()=>monitor.subscribeToStateChange(updateCollected)
);
return collected;
}
//# sourceMappingURL=useDragLayer.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useDragLayer.ts"],"sourcesContent":["import { useEffect } from 'react'\n\nimport type { DragLayerMonitor } from '../types/index.js'\nimport { useCollector } from './useCollector.js'\nimport { useDragDropManager } from './useDragDropManager.js'\n\n/**\n * useDragLayer Hook\n * @param collector The property collector\n */\nexport function useDragLayer<CollectedProps, DragObject = any>(\n\tcollect: (monitor: DragLayerMonitor<DragObject>) => CollectedProps,\n): CollectedProps {\n\tconst dragDropManager = useDragDropManager()\n\tconst monitor = dragDropManager.getMonitor()\n\tconst [collected, updateCollected] = useCollector(monitor, collect)\n\n\tuseEffect(() => monitor.subscribeToOffsetChange(updateCollected))\n\tuseEffect(() => monitor.subscribeToStateChange(updateCollected))\n\treturn collected\n}\n"],"names":["useEffect","useCollector","useDragDropManager","useDragLayer","collect","dragDropManager","monitor","getMonitor","collected","updateCollected","subscribeToOffsetChange","subscribeToStateChange"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAO,CAAA;AAGjC,SAASC,YAAY,QAAQ,mBAAmB,CAAA;AAChD,SAASC,kBAAkB,QAAQ,yBAAyB,CAAA;AAE5D;;;GAGG,CACH,OAAO,SAASC,YAAY,CAC3BC,OAAkE,EACjD;IACjB,MAAMC,eAAe,GAAGH,kBAAkB,EAAE;IAC5C,MAAMI,OAAO,GAAGD,eAAe,CAACE,UAAU,EAAE;IAC5C,MAAM,CAACC,SAAS,EAAEC,eAAe,CAAC,GAAGR,YAAY,CAACK,OAAO,EAAEF,OAAO,CAAC;IAEnEJ,SAAS,CAAC,IAAMM,OAAO,CAACI,uBAAuB,CAACD,eAAe,CAAC;IAAA,CAAC;IACjET,SAAS,CAAC,IAAMM,OAAO,CAACK,sBAAsB,CAACF,eAAe,CAAC;IAAA,CAAC;IAChE,OAAOD,SAAS,CAAA;CAChB"}

View File

@@ -1,11 +0,0 @@
import type { DropTarget } from 'dnd-core';
import type { DropTargetMonitor } from '../../types/index.js';
import type { DropTargetHookSpec } from '../types.js';
export declare class DropTargetImpl<O, R, P> implements DropTarget {
spec: DropTargetHookSpec<O, R, P>;
private monitor;
constructor(spec: DropTargetHookSpec<O, R, P>, monitor: DropTargetMonitor<O, R>);
canDrop(): boolean;
hover(): void;
drop(): R | undefined;
}

View File

@@ -1,28 +0,0 @@
export class DropTargetImpl {
canDrop() {
const spec = this.spec;
const monitor = this.monitor;
return spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true;
}
hover() {
const spec = this.spec;
const monitor = this.monitor;
if (spec.hover) {
spec.hover(monitor.getItem(), monitor);
}
}
drop() {
const spec = this.spec;
const monitor = this.monitor;
if (spec.drop) {
return spec.drop(monitor.getItem(), monitor);
}
return;
}
constructor(spec, monitor){
this.spec = spec;
this.monitor = monitor;
}
}
//# sourceMappingURL=DropTargetImpl.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/DropTargetImpl.ts"],"sourcesContent":["import type { DropTarget } from 'dnd-core'\n\nimport type { DropTargetMonitor } from '../../types/index.js'\nimport type { DropTargetHookSpec } from '../types.js'\n\nexport class DropTargetImpl<O, R, P> implements DropTarget {\n\tpublic constructor(\n\t\tpublic spec: DropTargetHookSpec<O, R, P>,\n\t\tprivate monitor: DropTargetMonitor<O, R>,\n\t) {}\n\n\tpublic canDrop() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\treturn spec.canDrop ? spec.canDrop(monitor.getItem(), monitor) : true\n\t}\n\n\tpublic hover() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\tif (spec.hover) {\n\t\t\tspec.hover(monitor.getItem(), monitor)\n\t\t}\n\t}\n\n\tpublic drop() {\n\t\tconst spec = this.spec\n\t\tconst monitor = this.monitor\n\t\tif (spec.drop) {\n\t\t\treturn spec.drop(monitor.getItem(), monitor)\n\t\t}\n\t\treturn\n\t}\n}\n"],"names":["DropTargetImpl","canDrop","spec","monitor","getItem","hover","drop"],"mappings":"AAKA,OAAO,MAAMA,cAAc;IAM1B,AAAOC,OAAO,GAAG;QAChB,MAAMC,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,OAAOD,IAAI,CAACD,OAAO,GAAGC,IAAI,CAACD,OAAO,CAACE,OAAO,CAACC,OAAO,EAAE,EAAED,OAAO,CAAC,GAAG,IAAI,CAAA;KACrE;IAED,AAAOE,KAAK,GAAG;QACd,MAAMH,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,IAAID,IAAI,CAACG,KAAK,EAAE;YACfH,IAAI,CAACG,KAAK,CAACF,OAAO,CAACC,OAAO,EAAE,EAAED,OAAO,CAAC;SACtC;KACD;IAED,AAAOG,IAAI,GAAG;QACb,MAAMJ,IAAI,GAAG,IAAI,CAACA,IAAI;QACtB,MAAMC,OAAO,GAAG,IAAI,CAACA,OAAO;QAC5B,IAAID,IAAI,CAACI,IAAI,EAAE;YACd,OAAOJ,IAAI,CAACI,IAAI,CAACH,OAAO,CAACC,OAAO,EAAE,EAAED,OAAO,CAAC,CAAA;SAC5C;QACD,OAAM;KACN;IA1BD,YACQD,IAAiC,EAChCC,OAAgC,CACvC;aAFMD,IAAiC,GAAjCA,IAAiC;aAChCC,OAAgC,GAAhCA,OAAgC;KACrC;CAwBJ"}

View File

@@ -1,2 +0,0 @@
import type { TargetConnector } from '../../internals/index.js';
export declare function useConnectDropTarget(connector: TargetConnector): any;

View File

@@ -1,9 +0,0 @@
import { useMemo } from 'react';
export function useConnectDropTarget(connector) {
return useMemo(()=>connector.hooks.dropTarget()
, [
connector
]);
}
//# sourceMappingURL=connectors.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/connectors.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport type { TargetConnector } from '../../internals/index.js'\n\nexport function useConnectDropTarget(connector: TargetConnector) {\n\treturn useMemo(() => connector.hooks.dropTarget(), [connector])\n}\n"],"names":["useMemo","useConnectDropTarget","connector","hooks","dropTarget"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAI/B,OAAO,SAASC,oBAAoB,CAACC,SAA0B,EAAE;IAChE,OAAOF,OAAO,CAAC,IAAME,SAAS,CAACC,KAAK,CAACC,UAAU,EAAE;IAAA,EAAE;QAACF,SAAS;KAAC,CAAC,CAAA;CAC/D"}

View File

@@ -1 +0,0 @@
export * from './useDrop.js';

View File

@@ -1,3 +0,0 @@
export * from './useDrop.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/index.ts"],"sourcesContent":["export * from './useDrop.js'\n"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}

View File

@@ -1,8 +0,0 @@
import type { Identifier } from 'dnd-core';
import type { DropTargetHookSpec } from '../types.js';
/**
* Internal utility hook to get an array-version of spec.accept.
* The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.
* @param spec
*/
export declare function useAccept<O, R, P>(spec: DropTargetHookSpec<O, R, P>): Identifier[];

View File

@@ -1,19 +0,0 @@
import { invariant } from '@react-dnd/invariant';
import { useMemo } from 'react';
/**
* Internal utility hook to get an array-version of spec.accept.
* The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.
* @param spec
*/ export function useAccept(spec) {
const { accept } = spec;
return useMemo(()=>{
invariant(spec.accept != null, 'accept must be defined');
return Array.isArray(accept) ? accept : [
accept
];
}, [
accept
]);
}
//# sourceMappingURL=useAccept.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useAccept.ts"],"sourcesContent":["import { invariant } from '@react-dnd/invariant'\nimport type { Identifier } from 'dnd-core'\nimport { useMemo } from 'react'\n\nimport type { DropTargetHookSpec } from '../types.js'\n\n/**\n * Internal utility hook to get an array-version of spec.accept.\n * The main utility here is that we aren't creating a new array on every render if a non-array spec.accept is passed in.\n * @param spec\n */\nexport function useAccept<O, R, P>(\n\tspec: DropTargetHookSpec<O, R, P>,\n): Identifier[] {\n\tconst { accept } = spec\n\treturn useMemo(() => {\n\t\tinvariant(spec.accept != null, 'accept must be defined')\n\t\treturn Array.isArray(accept) ? accept : [accept]\n\t}, [accept])\n}\n"],"names":["invariant","useMemo","useAccept","spec","accept","Array","isArray"],"mappings":"AAAA,SAASA,SAAS,QAAQ,sBAAsB,CAAA;AAEhD,SAASC,OAAO,QAAQ,OAAO,CAAA;AAI/B;;;;GAIG,CACH,OAAO,SAASC,SAAS,CACxBC,IAAiC,EAClB;IACf,MAAM,EAAEC,MAAM,CAAA,EAAE,GAAGD,IAAI;IACvB,OAAOF,OAAO,CAAC,IAAM;QACpBD,SAAS,CAACG,IAAI,CAACC,MAAM,IAAI,IAAI,EAAE,wBAAwB,CAAC;QACxD,OAAOC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,GAAGA,MAAM,GAAG;YAACA,MAAM;SAAC,CAAA;KAChD,EAAE;QAACA,MAAM;KAAC,CAAC,CAAA;CACZ"}

View File

@@ -1,8 +0,0 @@
import type { ConnectDropTarget } from '../../types/index.js';
import type { DropTargetHookSpec, FactoryOrInstance } from '../types.js';
/**
* useDropTarget Hook
* @param spec The drop target specification (object or function, function preferred)
* @param deps The memoization deps array to use when evaluating spec changes
*/
export declare function useDrop<DragObject = unknown, DropResult = unknown, CollectedProps = unknown>(specArg: FactoryOrInstance<DropTargetHookSpec<DragObject, DropResult, CollectedProps>>, deps?: unknown[]): [CollectedProps, ConnectDropTarget];

View File

@@ -1,22 +0,0 @@
import { useCollectedProps } from '../useCollectedProps.js';
import { useOptionalFactory } from '../useOptionalFactory.js';
import { useConnectDropTarget } from './connectors.js';
import { useDropTargetConnector } from './useDropTargetConnector.js';
import { useDropTargetMonitor } from './useDropTargetMonitor.js';
import { useRegisteredDropTarget } from './useRegisteredDropTarget.js';
/**
* useDropTarget Hook
* @param spec The drop target specification (object or function, function preferred)
* @param deps The memoization deps array to use when evaluating spec changes
*/ export function useDrop(specArg, deps) {
const spec = useOptionalFactory(specArg, deps);
const monitor = useDropTargetMonitor();
const connector = useDropTargetConnector(spec.options);
useRegisteredDropTarget(spec, monitor, connector);
return [
useCollectedProps(spec.collect, monitor, connector),
useConnectDropTarget(connector),
];
}
//# sourceMappingURL=useDrop.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useDrop.ts"],"sourcesContent":["import type { ConnectDropTarget } from '../../types/index.js'\nimport type { DropTargetHookSpec, FactoryOrInstance } from '../types.js'\nimport { useCollectedProps } from '../useCollectedProps.js'\nimport { useOptionalFactory } from '../useOptionalFactory.js'\nimport { useConnectDropTarget } from './connectors.js'\nimport { useDropTargetConnector } from './useDropTargetConnector.js'\nimport { useDropTargetMonitor } from './useDropTargetMonitor.js'\nimport { useRegisteredDropTarget } from './useRegisteredDropTarget.js'\n\n/**\n * useDropTarget Hook\n * @param spec The drop target specification (object or function, function preferred)\n * @param deps The memoization deps array to use when evaluating spec changes\n */\nexport function useDrop<\n\tDragObject = unknown,\n\tDropResult = unknown,\n\tCollectedProps = unknown,\n>(\n\tspecArg: FactoryOrInstance<\n\t\tDropTargetHookSpec<DragObject, DropResult, CollectedProps>\n\t>,\n\tdeps?: unknown[],\n): [CollectedProps, ConnectDropTarget] {\n\tconst spec = useOptionalFactory(specArg, deps)\n\tconst monitor = useDropTargetMonitor<DragObject, DropResult>()\n\tconst connector = useDropTargetConnector(spec.options)\n\tuseRegisteredDropTarget(spec, monitor, connector)\n\n\treturn [\n\t\tuseCollectedProps(spec.collect, monitor, connector),\n\t\tuseConnectDropTarget(connector),\n\t]\n}\n"],"names":["useCollectedProps","useOptionalFactory","useConnectDropTarget","useDropTargetConnector","useDropTargetMonitor","useRegisteredDropTarget","useDrop","specArg","deps","spec","monitor","connector","options","collect"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,yBAAyB,CAAA;AAC3D,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,oBAAoB,QAAQ,iBAAiB,CAAA;AACtD,SAASC,sBAAsB,QAAQ,6BAA6B,CAAA;AACpE,SAASC,oBAAoB,QAAQ,2BAA2B,CAAA;AAChE,SAASC,uBAAuB,QAAQ,8BAA8B,CAAA;AAEtE;;;;GAIG,CACH,OAAO,SAASC,OAAO,CAKtBC,OAEC,EACDC,IAAgB,EACsB;IACtC,MAAMC,IAAI,GAAGR,kBAAkB,CAACM,OAAO,EAAEC,IAAI,CAAC;IAC9C,MAAME,OAAO,GAAGN,oBAAoB,EAA0B;IAC9D,MAAMO,SAAS,GAAGR,sBAAsB,CAACM,IAAI,CAACG,OAAO,CAAC;IACtDP,uBAAuB,CAACI,IAAI,EAAEC,OAAO,EAAEC,SAAS,CAAC;IAEjD,OAAO;QACNX,iBAAiB,CAACS,IAAI,CAACI,OAAO,EAAEH,OAAO,EAAEC,SAAS,CAAC;QACnDT,oBAAoB,CAACS,SAAS,CAAC;KAC/B,CAAA;CACD"}

View File

@@ -1,4 +0,0 @@
import type { DropTargetMonitor } from '../../types/index.js';
import type { DropTargetHookSpec } from '../types.js';
import { DropTargetImpl } from './DropTargetImpl.js';
export declare function useDropTarget<O, R, P>(spec: DropTargetHookSpec<O, R, P>, monitor: DropTargetMonitor<O, R>): DropTargetImpl<O, R, P>;

View File

@@ -1,16 +0,0 @@
import { useEffect, useMemo } from 'react';
import { DropTargetImpl } from './DropTargetImpl.js';
export function useDropTarget(spec, monitor) {
const dropTarget = useMemo(()=>new DropTargetImpl(spec, monitor)
, [
monitor
]);
useEffect(()=>{
dropTarget.spec = spec;
}, [
spec
]);
return dropTarget;
}
//# sourceMappingURL=useDropTarget.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useDropTarget.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react'\n\nimport type { DropTargetMonitor } from '../../types/index.js'\nimport type { DropTargetHookSpec } from '../types.js'\nimport { DropTargetImpl } from './DropTargetImpl.js'\n\nexport function useDropTarget<O, R, P>(\n\tspec: DropTargetHookSpec<O, R, P>,\n\tmonitor: DropTargetMonitor<O, R>,\n) {\n\tconst dropTarget = useMemo(() => new DropTargetImpl(spec, monitor), [monitor])\n\tuseEffect(() => {\n\t\tdropTarget.spec = spec\n\t}, [spec])\n\treturn dropTarget\n}\n"],"names":["useEffect","useMemo","DropTargetImpl","useDropTarget","spec","monitor","dropTarget"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO,CAAA;AAI1C,SAASC,cAAc,QAAQ,qBAAqB,CAAA;AAEpD,OAAO,SAASC,aAAa,CAC5BC,IAAiC,EACjCC,OAAgC,EAC/B;IACD,MAAMC,UAAU,GAAGL,OAAO,CAAC,IAAM,IAAIC,cAAc,CAACE,IAAI,EAAEC,OAAO,CAAC;IAAA,EAAE;QAACA,OAAO;KAAC,CAAC;IAC9EL,SAAS,CAAC,IAAM;QACfM,UAAU,CAACF,IAAI,GAAGA,IAAI;KACtB,EAAE;QAACA,IAAI;KAAC,CAAC;IACV,OAAOE,UAAU,CAAA;CACjB"}

View File

@@ -1,3 +0,0 @@
import { TargetConnector } from '../../internals/index.js';
import type { DropTargetOptions } from '../../types/index.js';
export declare function useDropTargetConnector(options: DropTargetOptions): TargetConnector;

View File

@@ -1,22 +0,0 @@
import { useMemo } from 'react';
import { TargetConnector } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js';
export function useDropTargetConnector(options) {
const manager = useDragDropManager();
const connector = useMemo(()=>new TargetConnector(manager.getBackend())
, [
manager
]);
useIsomorphicLayoutEffect(()=>{
connector.dropTargetOptions = options || null;
connector.reconnect();
return ()=>connector.disconnectDropTarget()
;
}, [
options
]);
return connector;
}
//# sourceMappingURL=useDropTargetConnector.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useDropTargetConnector.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { TargetConnector } from '../../internals/index.js'\nimport type { DropTargetOptions } from '../../types/index.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js'\n\nexport function useDropTargetConnector(\n\toptions: DropTargetOptions,\n): TargetConnector {\n\tconst manager = useDragDropManager()\n\tconst connector = useMemo(\n\t\t() => new TargetConnector(manager.getBackend()),\n\t\t[manager],\n\t)\n\tuseIsomorphicLayoutEffect(() => {\n\t\tconnector.dropTargetOptions = options || null\n\t\tconnector.reconnect()\n\t\treturn () => connector.disconnectDropTarget()\n\t}, [options])\n\treturn connector\n}\n"],"names":["useMemo","TargetConnector","useDragDropManager","useIsomorphicLayoutEffect","useDropTargetConnector","options","manager","connector","getBackend","dropTargetOptions","reconnect","disconnectDropTarget"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAE/B,SAASC,eAAe,QAAQ,0BAA0B,CAAA;AAE1D,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,yBAAyB,QAAQ,iCAAiC,CAAA;AAE3E,OAAO,SAASC,sBAAsB,CACrCC,OAA0B,EACR;IAClB,MAAMC,OAAO,GAAGJ,kBAAkB,EAAE;IACpC,MAAMK,SAAS,GAAGP,OAAO,CACxB,IAAM,IAAIC,eAAe,CAACK,OAAO,CAACE,UAAU,EAAE,CAAC;IAAA,EAC/C;QAACF,OAAO;KAAC,CACT;IACDH,yBAAyB,CAAC,IAAM;QAC/BI,SAAS,CAACE,iBAAiB,GAAGJ,OAAO,IAAI,IAAI;QAC7CE,SAAS,CAACG,SAAS,EAAE;QACrB,OAAO,IAAMH,SAAS,CAACI,oBAAoB,EAAE;QAAA,CAAA;KAC7C,EAAE;QAACN,OAAO;KAAC,CAAC;IACb,OAAOE,SAAS,CAAA;CAChB"}

View File

@@ -1,2 +0,0 @@
import type { DropTargetMonitor } from '../../types/index.js';
export declare function useDropTargetMonitor<O, R>(): DropTargetMonitor<O, R>;

View File

@@ -1,12 +0,0 @@
import { useMemo } from 'react';
import { DropTargetMonitorImpl } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
export function useDropTargetMonitor() {
const manager = useDragDropManager();
return useMemo(()=>new DropTargetMonitorImpl(manager)
, [
manager
]);
}
//# sourceMappingURL=useDropTargetMonitor.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useDropTargetMonitor.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport { DropTargetMonitorImpl } from '../../internals/index.js'\nimport type { DropTargetMonitor } from '../../types/index.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\n\nexport function useDropTargetMonitor<O, R>(): DropTargetMonitor<O, R> {\n\tconst manager = useDragDropManager()\n\treturn useMemo(() => new DropTargetMonitorImpl(manager), [manager])\n}\n"],"names":["useMemo","DropTargetMonitorImpl","useDragDropManager","useDropTargetMonitor","manager"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAE/B,SAASC,qBAAqB,QAAQ,0BAA0B,CAAA;AAEhE,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAE7D,OAAO,SAASC,oBAAoB,GAAkC;IACrE,MAAMC,OAAO,GAAGF,kBAAkB,EAAE;IACpC,OAAOF,OAAO,CAAC,IAAM,IAAIC,qBAAqB,CAACG,OAAO,CAAC;IAAA,EAAE;QAACA,OAAO;KAAC,CAAC,CAAA;CACnE"}

View File

@@ -1,4 +0,0 @@
import type { TargetConnector } from '../../internals/index.js';
import type { DropTargetMonitor } from '../../types/index.js';
import type { DropTargetHookSpec } from '../types.js';
export declare function useRegisteredDropTarget<O, R, P>(spec: DropTargetHookSpec<O, R, P>, monitor: DropTargetMonitor<O, R>, connector: TargetConnector): void;

View File

@@ -1,25 +0,0 @@
import { registerTarget } from '../../internals/index.js';
import { useDragDropManager } from '../useDragDropManager.js';
import { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js';
import { useAccept } from './useAccept.js';
import { useDropTarget } from './useDropTarget.js';
export function useRegisteredDropTarget(spec, monitor, connector) {
const manager = useDragDropManager();
const dropTarget = useDropTarget(spec, monitor);
const accept = useAccept(spec);
useIsomorphicLayoutEffect(function registerDropTarget() {
const [handlerId, unregister] = registerTarget(accept, dropTarget, manager);
monitor.receiveHandlerId(handlerId);
connector.receiveHandlerId(handlerId);
return unregister;
}, [
manager,
monitor,
dropTarget,
connector,
accept.map((a)=>a.toString()
).join('|'),
]);
}
//# sourceMappingURL=useRegisteredDropTarget.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../../src/hooks/useDrop/useRegisteredDropTarget.ts"],"sourcesContent":["import type { TargetConnector } from '../../internals/index.js'\nimport { registerTarget } from '../../internals/index.js'\nimport type { DropTargetMonitor } from '../../types/index.js'\nimport type { DropTargetHookSpec } from '../types.js'\nimport { useDragDropManager } from '../useDragDropManager.js'\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect.js'\nimport { useAccept } from './useAccept.js'\nimport { useDropTarget } from './useDropTarget.js'\n\nexport function useRegisteredDropTarget<O, R, P>(\n\tspec: DropTargetHookSpec<O, R, P>,\n\tmonitor: DropTargetMonitor<O, R>,\n\tconnector: TargetConnector,\n): void {\n\tconst manager = useDragDropManager()\n\tconst dropTarget = useDropTarget(spec, monitor)\n\tconst accept = useAccept(spec)\n\n\tuseIsomorphicLayoutEffect(\n\t\tfunction registerDropTarget() {\n\t\t\tconst [handlerId, unregister] = registerTarget(\n\t\t\t\taccept,\n\t\t\t\tdropTarget,\n\t\t\t\tmanager,\n\t\t\t)\n\t\t\tmonitor.receiveHandlerId(handlerId)\n\t\t\tconnector.receiveHandlerId(handlerId)\n\t\t\treturn unregister\n\t\t},\n\t\t[\n\t\t\tmanager,\n\t\t\tmonitor,\n\t\t\tdropTarget,\n\t\t\tconnector,\n\t\t\taccept.map((a) => a.toString()).join('|'),\n\t\t],\n\t)\n}\n"],"names":["registerTarget","useDragDropManager","useIsomorphicLayoutEffect","useAccept","useDropTarget","useRegisteredDropTarget","spec","monitor","connector","manager","dropTarget","accept","registerDropTarget","handlerId","unregister","receiveHandlerId","map","a","toString","join"],"mappings":"AACA,SAASA,cAAc,QAAQ,0BAA0B,CAAA;AAGzD,SAASC,kBAAkB,QAAQ,0BAA0B,CAAA;AAC7D,SAASC,yBAAyB,QAAQ,iCAAiC,CAAA;AAC3E,SAASC,SAAS,QAAQ,gBAAgB,CAAA;AAC1C,SAASC,aAAa,QAAQ,oBAAoB,CAAA;AAElD,OAAO,SAASC,uBAAuB,CACtCC,IAAiC,EACjCC,OAAgC,EAChCC,SAA0B,EACnB;IACP,MAAMC,OAAO,GAAGR,kBAAkB,EAAE;IACpC,MAAMS,UAAU,GAAGN,aAAa,CAACE,IAAI,EAAEC,OAAO,CAAC;IAC/C,MAAMI,MAAM,GAAGR,SAAS,CAACG,IAAI,CAAC;IAE9BJ,yBAAyB,CACxB,SAASU,kBAAkB,GAAG;QAC7B,MAAM,CAACC,SAAS,EAAEC,UAAU,CAAC,GAAGd,cAAc,CAC7CW,MAAM,EACND,UAAU,EACVD,OAAO,CACP;QACDF,OAAO,CAACQ,gBAAgB,CAACF,SAAS,CAAC;QACnCL,SAAS,CAACO,gBAAgB,CAACF,SAAS,CAAC;QACrC,OAAOC,UAAU,CAAA;KACjB,EACD;QACCL,OAAO;QACPF,OAAO;QACPG,UAAU;QACVF,SAAS;QACTG,MAAM,CAACK,GAAG,CAAC,CAACC,CAAC,GAAKA,CAAC,CAACC,QAAQ,EAAE;QAAA,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;KACzC,CACD;CACD"}

View File

@@ -1,2 +0,0 @@
import { useEffect } from 'react';
export declare const useIsomorphicLayoutEffect: typeof useEffect;

View File

@@ -1,5 +0,0 @@
import { useEffect, useLayoutEffect } from 'react';
// suppress the useLayoutEffect warning on server side.
export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react'\n\n// suppress the useLayoutEffect warning on server side.\nexport const useIsomorphicLayoutEffect =\n\ttypeof window !== 'undefined' ? useLayoutEffect : useEffect\n"],"names":["useEffect","useLayoutEffect","useIsomorphicLayoutEffect","window"],"mappings":"AAAA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO,CAAA;AAElD,uDAAuD;AACvD,OAAO,MAAMC,yBAAyB,GACrC,OAAOC,MAAM,KAAK,WAAW,GAAGF,eAAe,GAAGD,SAAS,CAAA"}

View File

@@ -1,2 +0,0 @@
import type { HandlerManager, MonitorEventEmitter } from '../types/index.js';
export declare function useMonitorOutput<Monitor extends HandlerManager, Collected>(monitor: Monitor & MonitorEventEmitter, collect: (monitor: Monitor) => Collected, onCollect?: () => void): Collected;

View File

@@ -1,22 +0,0 @@
import { useCollector } from './useCollector.js';
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
export function useMonitorOutput(monitor, collect, onCollect) {
const [collected, updateCollected] = useCollector(monitor, collect, onCollect);
useIsomorphicLayoutEffect(function subscribeToMonitorStateChange() {
const handlerId = monitor.getHandlerId();
if (handlerId == null) {
return;
}
return monitor.subscribeToStateChange(updateCollected, {
handlerIds: [
handlerId
]
});
}, [
monitor,
updateCollected
]);
return collected;
}
//# sourceMappingURL=useMonitorOutput.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useMonitorOutput.ts"],"sourcesContent":["import type { HandlerManager, MonitorEventEmitter } from '../types/index.js'\nimport { useCollector } from './useCollector.js'\nimport { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js'\n\nexport function useMonitorOutput<Monitor extends HandlerManager, Collected>(\n\tmonitor: Monitor & MonitorEventEmitter,\n\tcollect: (monitor: Monitor) => Collected,\n\tonCollect?: () => void,\n): Collected {\n\tconst [collected, updateCollected] = useCollector(monitor, collect, onCollect)\n\n\tuseIsomorphicLayoutEffect(\n\t\tfunction subscribeToMonitorStateChange() {\n\t\t\tconst handlerId = monitor.getHandlerId()\n\t\t\tif (handlerId == null) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\treturn monitor.subscribeToStateChange(updateCollected, {\n\t\t\t\thandlerIds: [handlerId],\n\t\t\t})\n\t\t},\n\t\t[monitor, updateCollected],\n\t)\n\n\treturn collected\n}\n"],"names":["useCollector","useIsomorphicLayoutEffect","useMonitorOutput","monitor","collect","onCollect","collected","updateCollected","subscribeToMonitorStateChange","handlerId","getHandlerId","subscribeToStateChange","handlerIds"],"mappings":"AACA,SAASA,YAAY,QAAQ,mBAAmB,CAAA;AAChD,SAASC,yBAAyB,QAAQ,gCAAgC,CAAA;AAE1E,OAAO,SAASC,gBAAgB,CAC/BC,OAAsC,EACtCC,OAAwC,EACxCC,SAAsB,EACV;IACZ,MAAM,CAACC,SAAS,EAAEC,eAAe,CAAC,GAAGP,YAAY,CAACG,OAAO,EAAEC,OAAO,EAAEC,SAAS,CAAC;IAE9EJ,yBAAyB,CACxB,SAASO,6BAA6B,GAAG;QACxC,MAAMC,SAAS,GAAGN,OAAO,CAACO,YAAY,EAAE;QACxC,IAAID,SAAS,IAAI,IAAI,EAAE;YACtB,OAAM;SACN;QACD,OAAON,OAAO,CAACQ,sBAAsB,CAACJ,eAAe,EAAE;YACtDK,UAAU,EAAE;gBAACH,SAAS;aAAC;SACvB,CAAC,CAAA;KACF,EACD;QAACN,OAAO;QAAEI,eAAe;KAAC,CAC1B;IAED,OAAOD,SAAS,CAAA;CAChB"}

View File

@@ -1,2 +0,0 @@
import type { FactoryOrInstance } from './types.js';
export declare function useOptionalFactory<T>(arg: FactoryOrInstance<T>, deps?: unknown[]): T;

View File

@@ -1,14 +0,0 @@
import { useMemo } from 'react';
export function useOptionalFactory(arg, deps) {
const memoDeps = [
...deps || []
];
if (deps == null && typeof arg !== 'function') {
memoDeps.push(arg);
}
return useMemo(()=>{
return typeof arg === 'function' ? arg() : arg;
}, memoDeps);
}
//# sourceMappingURL=useOptionalFactory.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../src/hooks/useOptionalFactory.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nimport type { FactoryOrInstance } from './types.js'\n\nexport function useOptionalFactory<T>(\n\targ: FactoryOrInstance<T>,\n\tdeps?: unknown[],\n): T {\n\tconst memoDeps = [...(deps || [])]\n\tif (deps == null && typeof arg !== 'function') {\n\t\tmemoDeps.push(arg)\n\t}\n\treturn useMemo<T>(() => {\n\t\treturn typeof arg === 'function' ? (arg as () => T)() : (arg as T)\n\t}, memoDeps)\n}\n"],"names":["useMemo","useOptionalFactory","arg","deps","memoDeps","push"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO,CAAA;AAI/B,OAAO,SAASC,kBAAkB,CACjCC,GAAyB,EACzBC,IAAgB,EACZ;IACJ,MAAMC,QAAQ,GAAG;WAAKD,IAAI,IAAI,EAAE;KAAE;IAClC,IAAIA,IAAI,IAAI,IAAI,IAAI,OAAOD,GAAG,KAAK,UAAU,EAAE;QAC9CE,QAAQ,CAACC,IAAI,CAACH,GAAG,CAAC;KAClB;IACD,OAAOF,OAAO,CAAI,IAAM;QACvB,OAAO,OAAOE,GAAG,KAAK,UAAU,GAAG,AAACA,GAAG,EAAc,GAAIA,GAAG,AAAM,CAAA;KAClE,EAAEE,QAAQ,CAAC,CAAA;CACZ"}

View File

@@ -1,3 +0,0 @@
export * from './core/index.js';
export * from './hooks/index.js';
export * from './types/index.js';

View File

@@ -1,5 +0,0 @@
export * from './core/index.js';
export * from './hooks/index.js';
export * from './types/index.js';
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './core/index.js'\nexport * from './hooks/index.js'\nexport * from './types/index.js'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA"}

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

Some files were not shown because too many files have changed in this diff Show More