uawdijnntqw1x1x1
IP : 216.73.216.110
Hostname : 6.87.74.97.host.secureserver.net
Kernel : Linux 6.87.74.97.host.secureserver.net 4.18.0-553.83.1.el8_10.x86_64 #1 SMP Mon Nov 10 04:22:44 EST 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
emeraadmin
/
.htpasswds
/
..
/
www
/
8aabc
/
..
/
src
/
..
/
4d695
/
react-dnd.tar
/
/
package.json000064400000003674151676724530007064 0ustar00{ "_from": "react-dnd@^11.1.3", "_id": "react-dnd@11.1.3", "_inBundle": false, "_integrity": "sha512-8rtzzT8iwHgdSC89VktwhqdKKtfXaAyC4wiqp0SywpHG12TTLvfOoL6xNEIUWXwIEWu+CFfDn4GZJyynCEuHIQ==", "_location": "/react-dnd", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, "raw": "react-dnd@^11.1.3", "name": "react-dnd", "escapedName": "react-dnd", "rawSpec": "^11.1.3", "saveSpec": null, "fetchSpec": "^11.1.3" }, "_requiredBy": [ "/mui-datatables", "/react-sortable-tree-patch-react-17" ], "_resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-11.1.3.tgz", "_shasum": "f9844f5699ccc55dfc81462c2c19f726e670c1af", "_spec": "react-dnd@^11.1.3", "_where": "C:\\xampp\\htdocs\\emeraltd\\node_modules\\mui-datatables", "bugs": { "url": "https://github.com/react-dnd/react-dnd/issues" }, "bundleDependencies": false, "dependencies": { "@react-dnd/shallowequal": "^2.0.0", "@types/hoist-non-react-statics": "^3.3.1", "dnd-core": "^11.1.3", "hoist-non-react-statics": "^3.3.0" }, "deprecated": false, "description": "Drag and Drop for React", "devDependencies": { "@types/react": "^16.9.35", "@types/react-dom": "^16.9.8", "react": "^16.12.0", "react-dom": "^16.12.0" }, "gitHead": "32f16c09f0e8560c2a439f3a7fc2e0e8aec3b973", "homepage": "https://github.com/react-dnd/react-dnd#readme", "license": "MIT", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.js", "name": "react-dnd", "peerDependencies": { "react": ">= 16.9.0", "react-dom": ">= 16.9.0" }, "repository": { "type": "git", "url": "git+https://github.com/react-dnd/react-dnd.git" }, "scripts": { "build": "../../../scripts/build_package.sh", "clean": "../../../scripts/clean_package.sh", "start": "../../../scripts/watch_package.sh" }, "sideEffects": false, "types": "lib/index.d.ts", "version": "11.1.3" } lib/decorators/utils.d.ts000064400000000655151676724530011437 0ustar00/// <reference types="react" /> export declare function getDecoratedComponent(instanceRef: React.RefObject<any>): any; export declare function isClassComponent(Component: unknown): boolean; export declare function isRefForwardingComponent(C: unknown): boolean; export declare function isRefable(C: unknown): boolean; export declare function checkDecoratorArguments(functionName: string, signature: string, ...args: any[]): void; lib/decorators/DragLayer.d.ts000064400000000504151676724530012142 0ustar00import { DndOptions } from '../interfaces'; import { DragLayerCollector, DndComponentEnhancer } from './interfaces'; export declare function DragLayer<RequiredProps, CollectedProps = any>(collect: DragLayerCollector<RequiredProps, CollectedProps>, options?: DndOptions<RequiredProps>): DndComponentEnhancer<CollectedProps>; lib/decorators/DropTarget.d.ts000064400000000736151676724530012352 0ustar00import { TargetType } from 'dnd-core'; import { DndOptions } from '../interfaces'; import { DropTargetSpec, DropTargetCollector, DndComponentEnhancer } from './interfaces'; export declare function DropTarget<RequiredProps, CollectedProps = any>(type: TargetType | ((props: RequiredProps) => TargetType), spec: DropTargetSpec<RequiredProps>, collect: DropTargetCollector<CollectedProps, RequiredProps>, options?: DndOptions<RequiredProps>): DndComponentEnhancer<CollectedProps>; lib/decorators/utils.js000064400000002744151676724530011204 0ustar00export function getDecoratedComponent(instanceRef) { const currentRef = instanceRef.current; if (currentRef == null) { return null; } else if (currentRef.decoratedRef) { // go through the private field in decorateHandler to avoid the invariant hit return currentRef.decoratedRef.current; } else { return currentRef; } } export function isClassComponent(Component) { return (Component && Component.prototype && typeof Component.prototype.render === 'function'); } export function isRefForwardingComponent(C) { const item = C; return item?.$$typeof?.toString() === 'Symbol(react.forward_ref)'; } export function isRefable(C) { return isClassComponent(C) || isRefForwardingComponent(C); } export function checkDecoratorArguments(functionName, signature, ...args) { if (process.env.NODE_ENV !== 'production') { for (let i = 0; i < args.length; i++) { const arg = args[i]; if (arg && arg.prototype && arg.prototype.render) { // eslint-disable-next-line no-console console.error('You seem to be applying the arguments in the wrong order. ' + `It should be ${functionName}(${signature})(Component), not the other way around. ` + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order'); return; } } } } lib/decorators/DragLayer.js000064400000012420151676724530011706 0ustar00import * as React from 'react'; import { shallowEqual } from '@react-dnd/shallowequal'; import hoistStatics from 'hoist-non-react-statics'; import { invariant } from '@react-dnd/invariant'; import { DndContext } from '../common/DndContext'; import { isPlainObject } from '../utils/js_utils'; import { isRefable, checkDecoratorArguments } from './utils'; export function DragLayer(collect, options = {}) { checkDecoratorArguments('DragLayer', 'collect[, options]', collect, options); invariant(typeof collect === 'function', 'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ', 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', collect); invariant(isPlainObject(options), 'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. ' + 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', options); return function decorateLayer(DecoratedComponent) { const Decorated = DecoratedComponent; const { arePropsEqual = shallowEqual } = options; const displayName = Decorated.displayName || Decorated.name || 'Component'; let DragLayerContainer = /** @class */ (() => { class DragLayerContainer extends React.Component { constructor() { super(...arguments); this.isCurrentlyMounted = false; this.ref = React.createRef(); this.handleChange = () => { if (!this.isCurrentlyMounted) { return; } const nextState = this.getCurrentState(); if (!shallowEqual(nextState, this.state)) { this.setState(nextState); } }; } getDecoratedComponentInstance() { invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.ref.current; } shouldComponentUpdate(nextProps, nextState) { return (!arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state)); } componentDidMount() { this.isCurrentlyMounted = true; this.handleChange(); } componentWillUnmount() { this.isCurrentlyMounted = false; if (this.unsubscribeFromOffsetChange) { this.unsubscribeFromOffsetChange(); this.unsubscribeFromOffsetChange = undefined; } if (this.unsubscribeFromStateChange) { this.unsubscribeFromStateChange(); this.unsubscribeFromStateChange = undefined; } } render() { return (React.createElement(DndContext.Consumer, null, ({ dragDropManager }) => { if (dragDropManager === undefined) { return null; } this.receiveDragDropManager(dragDropManager); // Let componentDidMount fire to initialize the collected state if (!this.isCurrentlyMounted) { return null; } return (React.createElement(Decorated, Object.assign({}, this.props, this.state, { ref: isRefable(Decorated) ? this.ref : null }))); })); } receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } this.manager = dragDropManager; invariant(typeof dragDropManager === 'object', 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); const monitor = this.manager.getMonitor(); this.unsubscribeFromOffsetChange = monitor.subscribeToOffsetChange(this.handleChange); this.unsubscribeFromStateChange = monitor.subscribeToStateChange(this.handleChange); } getCurrentState() { if (!this.manager) { return {}; } const monitor = this.manager.getMonitor(); return collect(monitor, this.props); } } DragLayerContainer.displayName = `DragLayer(${displayName})`; DragLayerContainer.DecoratedComponent = DecoratedComponent; return DragLayerContainer; })(); return hoistStatics(DragLayerContainer, DecoratedComponent); }; } lib/decorators/disposables.d.ts000064400000005331151676724530012603 0ustar00import { noop } from '../utils/js_utils'; /** * Provides a set of static methods for creating Disposables. * @param {Function} action Action to run during the first call to dispose. * The action is guaranteed to be run at most once. */ export declare class Disposable { /** * Gets the disposable that does nothing when disposed. */ static empty: { dispose: typeof noop; }; /** * Validates whether the given object is a disposable * @param {Object} Object to test whether it has a dispose method * @returns {Boolean} true if a disposable object, else false. */ static isDisposable(d: any): boolean; static _fixup(result: any): any; /** * Creates a disposable object that invokes the specified action when disposed. * @param {Function} dispose Action to run during the first call to dispose. * The action is guaranteed to be run at most once. * @return {Disposable} The disposable object that runs the given action upon disposal. */ static create(action: any): Disposable; private isDisposed; private action; constructor(action: any); /** Performs the task of cleaning up resources. */ dispose(): void; } /** * Represents a group of disposable resources that are disposed together. * @constructor */ export declare class CompositeDisposable { private isDisposed; private disposables; constructor(...disposables: Disposable[]); /** * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. * @param {Any} item Disposable to add. */ add(item: Disposable): void; /** * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. * @param {Any} item Disposable to remove. * @returns {Boolean} true if found; false otherwise. */ remove(item: Disposable): boolean; /** * Disposes all disposables in the group and removes them from the group but * does not dispose the CompositeDisposable. */ clear(): void; /** * Disposes all disposables in the group and removes them from the group. */ dispose(): void; } /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ export declare class SerialDisposable { private isDisposed; private current; /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ getDisposable(): Disposable | undefined; setDisposable(value: Disposable): void; /** Performs the task of cleaning up resources. */ dispose(): void; } lib/decorators/DragSource.d.ts000064400000001312151676724530012324 0ustar00import { SourceType } from 'dnd-core'; import { DndOptions } from '../interfaces'; import { DndComponentEnhancer, DragSourceSpec, DragSourceCollector } from './interfaces'; /** * Decorates a component as a dragsource * @param type The dragsource type * @param spec The drag source specification * @param collect The props collector function * @param options DnD options */ export declare function DragSource<RequiredProps, CollectedProps = any, DragObject = any>(type: SourceType | ((props: RequiredProps) => SourceType), spec: DragSourceSpec<RequiredProps, DragObject>, collect: DragSourceCollector<CollectedProps, RequiredProps>, options?: DndOptions<RequiredProps>): DndComponentEnhancer<CollectedProps>; lib/decorators/DropTarget.js000064400000004724151676724530012117 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { registerTarget } from '../common/registration'; import { isValidType } from '../utils/isValidType'; import { TargetConnector } from '../common/TargetConnector'; import { DropTargetMonitorImpl } from '../common/DropTargetMonitorImpl'; import { checkDecoratorArguments } from './utils'; import { decorateHandler } from './decorateHandler'; import { createTargetFactory } from './createTargetFactory'; export function DropTarget(type, spec, collect, options = {}) { checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options); let getType = type; if (typeof type !== 'function') { invariant(isValidType(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type); getType = () => type; } invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec); const createTarget = createTargetFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); return function decorateTarget(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DropTarget', createHandler: createTarget, registerHandler: registerTarget, createMonitor: (manager) => new DropTargetMonitorImpl(manager), createConnector: (backend) => new TargetConnector(backend), DecoratedComponent, getType, collect, options, }); }; } lib/decorators/decorateHandler.d.ts000064400000001775151676724530013367 0ustar00import * as React from 'react'; import { DragDropManager, Identifier } from 'dnd-core'; import { DndComponent } from './interfaces'; export interface DecorateHandlerArgs<Props, ItemIdType> { DecoratedComponent: any; createMonitor: (manager: DragDropManager) => HandlerReceiver; createHandler: (monitor: HandlerReceiver, ref: React.RefObject<any>) => Handler<Props>; createConnector: any; registerHandler: any; containerDisplayName: string; getType: (props: Props) => ItemIdType; collect: any; options: any; } interface HandlerReceiver { receiveHandlerId: (handlerId: Identifier | null) => void; } interface Handler<Props> { ref: React.RefObject<any>; receiveProps(props: Props): void; } export declare function decorateHandler<Props, CollectedProps, ItemIdType>({ DecoratedComponent, createHandler, createMonitor, createConnector, registerHandler, containerDisplayName, getType, collect, options, }: DecorateHandlerArgs<Props, ItemIdType>): DndComponent<Props>; export {}; lib/decorators/decorateHandler.js000064400000014544151676724530013131 0ustar00import * as React from 'react'; import { shallowEqual } from '@react-dnd/shallowequal'; import { invariant } from '@react-dnd/invariant'; import hoistStatics from 'hoist-non-react-statics'; import { DndContext } from '../common/DndContext'; import { isPlainObject } from '../utils/js_utils'; import { Disposable, CompositeDisposable, SerialDisposable, } from './disposables'; import { isRefable } from './utils'; export function decorateHandler({ DecoratedComponent, createHandler, createMonitor, createConnector, registerHandler, containerDisplayName, getType, collect, options, }) { const { arePropsEqual = shallowEqual } = options; const Decorated = DecoratedComponent; const displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component'; let DragDropContainer = /** @class */ (() => { class DragDropContainer extends React.Component { constructor(props) { super(props); this.decoratedRef = React.createRef(); this.handleChange = () => { const nextState = this.getCurrentState(); if (!shallowEqual(nextState, this.state)) { this.setState(nextState); } }; this.disposable = new SerialDisposable(); this.receiveProps(props); this.dispose(); } getHandlerId() { return this.handlerId; } getDecoratedComponentInstance() { invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.decoratedRef.current; } shouldComponentUpdate(nextProps, nextState) { return (!arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state)); } componentDidMount() { this.disposable = new SerialDisposable(); this.currentType = undefined; this.receiveProps(this.props); this.handleChange(); } componentDidUpdate(prevProps) { if (!arePropsEqual(this.props, prevProps)) { this.receiveProps(this.props); this.handleChange(); } } componentWillUnmount() { this.dispose(); } receiveProps(props) { if (!this.handler) { return; } this.handler.receiveProps(props); this.receiveType(getType(props)); } receiveType(type) { if (!this.handlerMonitor || !this.manager || !this.handlerConnector) { return; } if (type === this.currentType) { return; } this.currentType = type; const [handlerId, unregister] = registerHandler(type, this.handler, this.manager); this.handlerId = handlerId; this.handlerMonitor.receiveHandlerId(handlerId); this.handlerConnector.receiveHandlerId(handlerId); const globalMonitor = this.manager.getMonitor(); const unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, { handlerIds: [handlerId] }); this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister))); } dispose() { this.disposable.dispose(); if (this.handlerConnector) { this.handlerConnector.receiveHandlerId(null); } } getCurrentState() { if (!this.handlerConnector) { return {}; } const nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props); if (process.env.NODE_ENV !== 'production') { invariant(isPlainObject(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState); } return nextState; } render() { return (React.createElement(DndContext.Consumer, null, ({ dragDropManager }) => { this.receiveDragDropManager(dragDropManager); if (typeof requestAnimationFrame !== 'undefined') { requestAnimationFrame(() => this.handlerConnector?.reconnect()); } return (React.createElement(Decorated, Object.assign({}, this.props, this.getCurrentState(), { // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. ref: isRefable(Decorated) ? this.decoratedRef : null }))); })); } receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } invariant(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); if (dragDropManager === undefined) { return; } this.manager = dragDropManager; this.handlerMonitor = createMonitor(dragDropManager); this.handlerConnector = createConnector(dragDropManager.getBackend()); this.handler = createHandler(this.handlerMonitor, this.decoratedRef); } } DragDropContainer.DecoratedComponent = DecoratedComponent; DragDropContainer.displayName = `${containerDisplayName}(${displayName})`; return DragDropContainer; })(); return hoistStatics(DragDropContainer, DecoratedComponent); } lib/decorators/createSourceFactory.d.ts000064400000000656151676724530014254 0ustar00import * as React from 'react'; import { DragSource } from 'dnd-core'; import { DragSourceMonitor } from '../interfaces'; import { DragSourceSpec } from './interfaces'; export interface Source extends DragSource { receiveProps(props: any): void; } export declare function createSourceFactory<Props, DragObject = any>(spec: DragSourceSpec<Props, DragObject>): (monitor: DragSourceMonitor, ref: React.RefObject<any>) => Source; lib/decorators/index.js000064400000000167151676724530011150 0ustar00export * from './DragSource'; export * from './DropTarget'; export * from './DragLayer'; export * from './interfaces'; lib/decorators/interfaces.d.ts000064400000023671151676724530012425 0ustar00import * as React from 'react'; import { Identifier } from 'dnd-core'; import { DropTargetMonitor, DragSourceMonitor, DragLayerMonitor, ConnectDragPreview, ConnectDropTarget, ConnectDragSource } from '../interfaces'; import { NonReactStatics } from 'hoist-non-react-statics'; /** * A DnD interactive component */ export interface DndComponent<Props> extends React.Component<Props> { getDecoratedComponentInstance(): React.Component<Props> | null; getHandlerId(): Identifier; } /** * Interface for the DropTarget specification object */ export interface DropTargetSpec<Props> { /** * 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?: (props: Props, monitor: DropTargetMonitor, component: any) => any; /** * 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?: (props: Props, monitor: DropTargetMonitor, component: any) => 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?: (props: Props, monitor: DropTargetMonitor) => boolean; } export interface DragSourceSpec<Props, DragObject> { /** * Required. * When the dragging starts, beginDrag is called. You must return a plain JavaScript object describing the * data being dragged. What you return 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 into it, 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 return something like { id: props.id } from this method. */ beginDrag: (props: Props, monitor: DragSourceMonitor, component: any) => DragObject; /** * 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. */ endDrag?: (props: Props, monitor: DragSourceMonitor, component: any) => 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?: (props: Props, monitor: DragSourceMonitor) => 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?: (props: Props, monitor: DragSourceMonitor) => boolean; } /** * DragSourceConnector is an object passed to a collecting function of the DragSource. * Its methods return functions that let you assign the roles to your component's DOM nodes. */ export interface DragSourceConnector { /** * Returns a function that must be used inside the component to assign the drag source role to a node. By * returning { connectDragSource: connect.dragSource() } from your collecting function, you can mark any React * element as the draggable node. To do that, replace any element with this.props.connectDragSource(element) inside * the render function. */ dragSource(): ConnectDragSource; /** * Optional. Returns a function that may be used inside the component to assign the drag preview role to a node. By * returning { connectDragPreview: connect.dragPreview() } from your collecting function, you can mark any React element * as the drag preview node. To do that, replace any element with this.props.connectDragPreview(element) inside the render * function. The drag preview is the node that will be screenshotted by the HTML5 backend when the drag begins. For example, * if you want to make something draggable by a small custom handle, you can mark this handle as the dragSource(), but also * mark an outer, larger component node as the dragPreview(). Thus the larger drag preview appears on the screenshot, but * only the smaller drag source is actually draggable. Another possible customization is passing an Image instance to dragPreview * from a lifecycle method like componentDidMount. This lets you use the actual images for drag previews. (Note that IE does not * support this customization). See the example code below for the different usage examples. */ dragPreview(): ConnectDragPreview; } /** * DropTargetConnector is an object passed to a collecting function of the DropTarget. Its only method dropTarget() returns a function * that lets you assign the drop target role to one of your component's DOM nodes. */ export interface DropTargetConnector { /** * Returns a function that must be used inside the component to assign the drop target role to a node. * By returning { connectDropTarget: connect.dropTarget() } from your collecting function, you can mark any React element * as the droppable node. To do that, replace any element with this.props.connectDropTarget(element) inside the render function. */ dropTarget(): ConnectDropTarget; } export declare type DragSourceCollector<CollectedProps, TargetProps> = (connect: DragSourceConnector, monitor: DragSourceMonitor, props: TargetProps) => CollectedProps; export declare type DropTargetCollector<CollectedProps, TargetProps> = (connect: DropTargetConnector, monitor: DropTargetMonitor, props: TargetProps) => CollectedProps; export declare type DragLayerCollector<TargetProps, CollectedProps> = (monitor: DragLayerMonitor, props: TargetProps) => CollectedProps; export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; /** * A property P will be present if: * - it is present in DecorationTargetProps * * Its value will be dependent on the following conditions * - if property P is present in InjectedProps and its definition extends the definition * in DecorationTargetProps, then its definition will be that of DecorationTargetProps[P] * - if property P is not present in InjectedProps then its definition will be that of * DecorationTargetProps[P] * - if property P is present in InjectedProps but does not extend the * DecorationTargetProps[P] definition, its definition will be that of InjectedProps[P] */ export declare type Matching<InjectedProps, DecorationTargetProps> = { [P in keyof DecorationTargetProps]: P extends keyof InjectedProps ? InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : InjectedProps[P] : DecorationTargetProps[P]; }; /** * a property P will be present if : * - it is present in both DecorationTargetProps and InjectedProps * - InjectedProps[P] can satisfy DecorationTargetProps[P] * ie: decorated component can accept more types than decorator is injecting * * For decoration, inject props or ownProps are all optionally * required by the decorated (right hand side) component. * But any property required by the decorated component must be satisfied by the injected property. */ export declare type Shared<InjectedProps, DecorationTargetProps> = { [P in Extract<keyof InjectedProps, keyof DecorationTargetProps>]?: InjectedProps[P] extends DecorationTargetProps[P] ? DecorationTargetProps[P] : never; }; /** * Gets the props interface of a component using inference */ export declare type GetProps<C> = C extends React.ComponentType<infer P> ? P : never; export declare type DndComponentEnhancer<CollectedProps> = <C extends React.ComponentType<Matching<CollectedProps, GetProps<C>>>>(component: C) => DndComponentClass<C, Omit<GetProps<C>, keyof Shared<CollectedProps, GetProps<C>>>>; export declare type DndComponentClass<C extends React.ComponentType<any>, P> = React.ComponentClass<JSX.LibraryManagedAttributes<C, P>> & NonReactStatics<C> & { DecoratedComponent: C; }; lib/decorators/DragSource.js000064400000005211151676724530012072 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { checkDecoratorArguments } from './utils'; import { decorateHandler } from './decorateHandler'; import { registerSource } from '../common/registration'; import { DragSourceMonitorImpl } from '../common/DragSourceMonitorImpl'; import { SourceConnector } from '../common/SourceConnector'; import { isValidType } from '../utils/isValidType'; import { createSourceFactory } from './createSourceFactory'; /** * Decorates a component as a dragsource * @param type The dragsource type * @param spec The drag source specification * @param collect The props collector function * @param options DnD options */ export function DragSource(type, spec, collect, options = {}) { checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options); let getType = type; if (typeof type !== 'function') { invariant(isValidType(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type); getType = () => type; } invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec); const createSource = createSourceFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); return function decorateSource(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DragSource', createHandler: createSource, registerHandler: registerSource, createConnector: (backend) => new SourceConnector(backend), createMonitor: (manager) => new DragSourceMonitorImpl(manager), DecoratedComponent, getType, collect, options, }); }; } lib/decorators/createSourceFactory.js000064400000005670151676724530014021 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { getDecoratedComponent } from './utils'; const ALLOWED_SPEC_METHODS = ['canDrag', 'beginDrag', 'isDragging', 'endDrag']; const REQUIRED_SPEC_METHODS = ['beginDrag']; class SourceImpl { constructor(spec, monitor, ref) { this.props = null; this.beginDrag = () => { if (!this.props) { return; } const item = this.spec.beginDrag(this.props, this.monitor, this.ref.current); if (process.env.NODE_ENV !== 'production') { invariant(isPlainObject(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item); } return item; }; this.spec = spec; this.monitor = monitor; this.ref = ref; } receiveProps(props) { this.props = props; } canDrag() { if (!this.props) { return false; } if (!this.spec.canDrag) { return true; } return this.spec.canDrag(this.props, this.monitor); } isDragging(globalMonitor, sourceId) { if (!this.props) { return false; } if (!this.spec.isDragging) { return sourceId === globalMonitor.getSourceId(); } return this.spec.isDragging(this.props, this.monitor); } endDrag() { if (!this.props) { return; } if (!this.spec.endDrag) { return; } this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref)); } } export function createSourceFactory(spec) { Object.keys(spec).forEach((key) => { invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); REQUIRED_SPEC_METHODS.forEach((key) => { invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); return function createSource(monitor, ref) { return new SourceImpl(spec, monitor, ref); }; } lib/decorators/createTargetFactory.js000064400000004353151676724530014004 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { getDecoratedComponent } from './utils'; const ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop']; class TargetImpl { constructor(spec, monitor, ref) { this.props = null; this.spec = spec; this.monitor = monitor; this.ref = ref; } receiveProps(props) { this.props = props; } receiveMonitor(monitor) { this.monitor = monitor; } canDrop() { if (!this.spec.canDrop) { return true; } return this.spec.canDrop(this.props, this.monitor); } hover() { if (!this.spec.hover || !this.props) { return; } this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref)); } drop() { if (!this.spec.drop) { return undefined; } const dropResult = this.spec.drop(this.props, this.monitor, this.ref.current); if (process.env.NODE_ENV !== 'production') { invariant(typeof dropResult === 'undefined' || isPlainObject(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult); } return dropResult; } } export function createTargetFactory(spec) { Object.keys(spec).forEach((key) => { invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]); }); return function createTarget(monitor, ref) { return new TargetImpl(spec, monitor, ref); }; } lib/decorators/index.d.ts000064400000000167151676724530011404 0ustar00export * from './DragSource'; export * from './DropTarget'; export * from './DragLayer'; export * from './interfaces'; lib/decorators/disposables.js000064400000011774151676724530012357 0ustar00import { isFunction, noop } from '../utils/js_utils'; /** * Provides a set of static methods for creating Disposables. * @param {Function} action Action to run during the first call to dispose. * The action is guaranteed to be run at most once. */ let Disposable = /** @class */ (() => { class Disposable { constructor(action) { this.isDisposed = false; this.action = isFunction(action) ? action : noop; } /** * Validates whether the given object is a disposable * @param {Object} Object to test whether it has a dispose method * @returns {Boolean} true if a disposable object, else false. */ static isDisposable(d) { return Boolean(d && isFunction(d.dispose)); } static _fixup(result) { return Disposable.isDisposable(result) ? result : Disposable.empty; } /** * Creates a disposable object that invokes the specified action when disposed. * @param {Function} dispose Action to run during the first call to dispose. * The action is guaranteed to be run at most once. * @return {Disposable} The disposable object that runs the given action upon disposal. */ static create(action) { return new Disposable(action); } /** Performs the task of cleaning up resources. */ dispose() { if (!this.isDisposed) { this.action(); this.isDisposed = true; } } } /** * Gets the disposable that does nothing when disposed. */ Disposable.empty = { dispose: noop }; return Disposable; })(); export { Disposable }; /** * Represents a group of disposable resources that are disposed together. * @constructor */ export class CompositeDisposable { constructor(...disposables) { this.isDisposed = false; this.disposables = disposables; } /** * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. * @param {Any} item Disposable to add. */ add(item) { if (this.isDisposed) { item.dispose(); } else { this.disposables.push(item); } } /** * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. * @param {Any} item Disposable to remove. * @returns {Boolean} true if found; false otherwise. */ remove(item) { let shouldDispose = false; if (!this.isDisposed) { const idx = this.disposables.indexOf(item); if (idx !== -1) { shouldDispose = true; this.disposables.splice(idx, 1); item.dispose(); } } return shouldDispose; } /** * Disposes all disposables in the group and removes them from the group but * does not dispose the CompositeDisposable. */ clear() { if (!this.isDisposed) { const len = this.disposables.length; const currentDisposables = new Array(len); for (let i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (let i = 0; i < len; i++) { currentDisposables[i].dispose(); } } } /** * Disposes all disposables in the group and removes them from the group. */ dispose() { if (!this.isDisposed) { this.isDisposed = true; const len = this.disposables.length; const currentDisposables = new Array(len); for (let i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (let i = 0; i < len; i++) { currentDisposables[i].dispose(); } } } } /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ export class SerialDisposable { constructor() { this.isDisposed = false; } /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ getDisposable() { return this.current; } setDisposable(value) { const shouldDispose = this.isDisposed; if (!shouldDispose) { const old = this.current; this.current = value; if (old) { old.dispose(); } } if (shouldDispose && value) { value.dispose(); } } /** Performs the task of cleaning up resources. */ dispose() { if (!this.isDisposed) { this.isDisposed = true; const old = this.current; this.current = undefined; if (old) { old.dispose(); } } } } lib/decorators/interfaces.js000064400000000000151676724530012146 0ustar00lib/decorators/createTargetFactory.d.ts000064400000000670151676724530014236 0ustar00import * as React from 'react'; import { DropTarget } from 'dnd-core'; import { DropTargetMonitor } from '../interfaces'; import { DropTargetSpec } from './interfaces'; export interface Target extends DropTarget { receiveProps(props: any): void; receiveMonitor(monitor: any): void; } export declare function createTargetFactory<Props>(spec: DropTargetSpec<Props>): (monitor: DropTargetMonitor, ref: React.RefObject<any>) => Target; lib/utils/isValidType.d.ts000064400000000123151676724530011515 0ustar00export declare function isValidType(type: unknown, allowArray?: boolean): boolean; lib/utils/cloneWithRef.d.ts000064400000000172151676724530011655 0ustar00/// <reference types="react" /> export declare function cloneWithRef(element: any, newRef: any): React.ReactElement<any>; lib/utils/js_utils.d.ts000064400000000243151676724530011117 0ustar00export declare function isFunction(input: unknown): boolean; export declare function noop(): void; export declare function isPlainObject(input: unknown): boolean; lib/utils/isRef.d.ts000064400000000142151676724530010331 0ustar00export interface Ref<T> { current: T; } export declare function isRef(obj: unknown): boolean; lib/utils/isRef.js000064400000000330151676724530010074 0ustar00export function isRef(obj) { return ( // eslint-disable-next-line no-prototype-builtins obj !== null && typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')); } lib/utils/cloneWithRef.js000064400000001763151676724530011430 0ustar00import { cloneElement } from 'react'; import { invariant } from '@react-dnd/invariant'; function setRef(ref, node) { if (typeof ref === 'function') { ref(node); } else { ref.current = node; } } export 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://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute'); 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); }, }); } } lib/utils/js_utils.js000064400000001116151676724530010663 0ustar00// cheap lodash replacements export function isFunction(input) { return typeof input === 'function'; } export function noop() { // noop } function isObjectLike(input) { return typeof input === 'object' && input !== null; } export function isPlainObject(input) { if (!isObjectLike(input)) { return false; } if (Object.getPrototypeOf(input) === null) { return true; } let proto = input; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(input) === proto; } lib/utils/isValidType.js000064400000000362151676724530011266 0ustar00export function isValidType(type, allowArray) { return (typeof type === 'string' || typeof type === 'symbol' || (!!allowArray && Array.isArray(type) && type.every((t) => isValidType(t, false)))); } lib/index.js000064400000000157151676724530007002 0ustar00export * from './common'; export * from './interfaces'; export * from './hooks'; export * from './decorators'; lib/interfaces/hooksApi.js000064400000000000151676724530011556 0ustar00lib/interfaces/monitors.js000064400000000000151676724530011653 0ustar00lib/interfaces/monitors.d.ts000064400000020366151676724530012130 0ustar00import { Identifier, Unsubscribe } from 'dnd-core'; export interface XYCoord { x: number; y: number; } export interface HandlerManager { receiveHandlerId: (handlerId: Identifier | null) => void; getHandlerId: () => Identifier | null; } export interface DragSourceMonitor extends HandlerManager, MonitorEventEmitter { /** * Returns true if no drag operation is in progress, and the owner's canDrag() returns true or is not defined. */ canDrag(): boolean; /** * Returns true if a drag operation is in progress, and either the owner initiated the drag, or its isDragging() is defined and returns true. */ isDragging(): boolean; /** * Returns a string or an ES6 symbol identifying the type of the current dragged item. Returns null if no item is being dragged. */ getItemType(): Identifier | null; /** * Returns a plain object representing the currently dragged item. Every drag source must specify it by returning an object from its beginDrag() method. * Returns null if no item is being dragged. */ getItem(): any; /** * Returns a plain object representing the last recorded drop result. The drop targets may optionally specify it by returning an object from their * drop() methods. When a chain of drop() is dispatched for the nested targets, bottom up, any parent that explicitly returns its own result from drop() * overrides the child drop result previously set by the child. Returns null if called outside endDrag(). */ getDropResult(): any; /** * Returns true if some drop target has handled the drop event, false otherwise. Even if a target did not return a drop result, didDrop() returns true. * Use it inside endDrag() to test whether any drop target has handled the drop. Returns false if called outside endDrag(). */ didDrop(): boolean; /** * Returns the { x, y } client offset of the pointer at the time when the current drag operation has started. Returns null if no item is being dragged. */ getInitialClientOffset(): XYCoord | null; /** * Returns the { x, y } client offset of the drag source component's root DOM node at the time when the current drag operation has started. * Returns null if no item is being dragged. */ getInitialSourceClientOffset(): XYCoord | null; /** * Returns the last recorded { x, y } client offset of the pointer while a drag operation is in progress. Returns null if no item is being dragged. */ getClientOffset(): XYCoord | null; /** * Returns the { x, y } difference between the last recorded client offset of the pointer and the client offset when the current drag operation has started. * Returns null if no item is being dragged. */ getDifferenceFromInitialOffset(): XYCoord | null; /** * Returns the projected { x, y } client offset of the drag source component's root DOM node, based on its position at the time when the current drag operation has * started, and the movement difference. Returns null if no item is being dragged. */ getSourceClientOffset(): XYCoord | null; /** * Returns the ids of the potential drop targets. */ getTargetIds(): Identifier[]; } export interface MonitorEventEmitter { subscribeToStateChange(fn: () => void, options?: { handlerIds?: Identifier[]; }): Unsubscribe; } export interface DropTargetMonitor extends HandlerManager, MonitorEventEmitter { /** * Returns true if there is a drag operation in progress, and the owner's canDrop() returns true or is not defined. */ canDrop(): boolean; /** * Returns true if there is a drag operation in progress, and the pointer is currently hovering over the owner. * You may optionally pass { shallow: true } to strictly check whether only the owner is being hovered, as opposed * to a nested target. */ isOver(options?: { shallow?: boolean; }): boolean; /** * Returns a string or an ES6 symbol identifying the type of the current dragged item. Returns null if no item is being dragged. */ getItemType(): Identifier | null; /** * Returns a plain object representing the currently dragged item. Every drag source must specify it by returning an object from * its beginDrag() method. Returns null if no item is being dragged. */ getItem(): any; /** * Returns a plain object representing the last recorded drop result. The drop targets may optionally specify it by returning an * object from their drop() methods. When a chain of drop() is dispatched for the nested targets, bottom up, any parent that explicitly * returns its own result from drop() overrides the drop result previously set by the child. Returns null if called outside drop(). */ getDropResult(): any; /** * Returns true if some drop target has handled the drop event, false otherwise. Even if a target did not return a drop result, * didDrop() returns true. Use it inside drop() to test whether any nested drop target has already handled the drop. Returns false * if called outside drop(). */ didDrop(): boolean; /** * Returns the { x, y } client offset of the pointer at the time when the current drag operation has started. Returns null if no item * is being dragged. */ getInitialClientOffset(): XYCoord | null; /** * Returns the { x, y } client offset of the drag source component's root DOM node at the time when the current drag operation has started. * Returns null if no item is being dragged. */ getInitialSourceClientOffset(): XYCoord | null; /** * Returns the last recorded { x, y } client offset of the pointer while a drag operation is in progress. Returns null if no item is being dragged. */ getClientOffset(): XYCoord | null; /** * Returns the { x, y } difference between the last recorded client offset of the pointer and the client offset when current the drag operation has * started. Returns null if no item is being dragged. */ getDifferenceFromInitialOffset(): XYCoord | null; /** * Returns the projected { x, y } client offset of the drag source component's root DOM node, based on its position at the time when the current * drag operation has started, and the movement difference. Returns null if no item is being dragged. */ getSourceClientOffset(): XYCoord | null; } export interface DragLayerMonitor { /** * Returns true if a drag operation is in progress. Returns false otherwise. */ isDragging(): boolean; /** * Returns a string or an ES6 symbol identifying the type of the current dragged item. * Returns null if no item is being dragged. */ getItemType(): Identifier | null; /** * Returns a plain object representing the currently dragged item. * Every drag source must specify it by returning an object from its beginDrag() method. * Returns null if no item is being dragged. */ getItem(): any; /** * Returns the { x, y } client offset of the pointer at the time when the current drag operation has started. * Returns null if no item is being dragged. */ getInitialClientOffset(): XYCoord | null; /** * Returns the { x, y } client offset of the drag source component's root DOM node at the time when the current * drag operation has started. Returns null if no item is being dragged. */ getInitialSourceClientOffset(): XYCoord | null; /** * Returns the last recorded { x, y } client offset of the pointer while a drag operation is in progress. * Returns null if no item is being dragged. */ getClientOffset(): XYCoord | null; /** * Returns the { x, y } difference between the last recorded client offset of the pointer and the client * offset when current the drag operation has started. Returns null if no item is being dragged. */ getDifferenceFromInitialOffset(): XYCoord | null; /** * Returns the projected { x, y } client offset of the drag source component's root DOM node, based on its * position at the time when the current drag operation has started, and the movement difference. * Returns null if no item is being dragged. */ getSourceClientOffset(): XYCoord | null; } lib/interfaces/index.js000064400000000161151676724530011120 0ustar00export * from './monitors'; export * from './hooksApi'; export * from './options'; export * from './connectors'; lib/interfaces/hooksApi.d.ts000064400000012511151676724530012024 0ustar00import { TargetType, SourceType } from 'dnd-core'; import { DropTargetMonitor, DragSourceMonitor } from './monitors'; import { DragSourceOptions, DragPreviewOptions } from './options'; export interface DragSourceHookSpec<DragObject extends DragObjectWithType, DropResult, CollectedProps> { /** * 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 shouldx 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 } * */ item: DragObject; /** * The drag source options */ options?: DragSourceOptions; /** * DragPreview options */ previewOptions?: DragPreviewOptions; /** * When the dragging starts, beginDrag is called. If an object is returned from this function it will overide the default dragItem */ begin?: (monitor: DragSourceMonitor) => DragObject | undefined | void; /** * 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 | undefined, monitor: DragSourceMonitor) => 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) => 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) => boolean; /** * A function to collect rendering properties */ collect?: (monitor: DragSourceMonitor) => 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 optinos */ options?: any; /** * 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) => 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) => 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) => boolean; /** * A function to collect rendering properties */ collect?: (monitor: DropTargetMonitor) => CollectedProps; } export interface DragObjectWithType { type: SourceType; } lib/interfaces/options.d.ts000064400000005112151676724530011741 0ustar00/** * Options for the Drag Sources, Drop Tragets, and Drag Layers annotation */ export interface DndOptions<Props> { arePropsEqual?: (first: Props, second: Props) => boolean; } export interface DragSourceOptions { /** * Optional. A string. By default, 'move'. In the browsers that support this feature, specifying 'copy' * shows a special “copying” cursor, while 'move' corresponds to the “move” cursor. You might want to use * this option to provide a hint to the user about whether an action is destructive. */ dropEffect?: string; } export interface DragPreviewOptions { /** * Optional. A boolean. By default, false. If true, the component will learn that it is being dragged immediately as the drag * starts instead of the next tick. This means that the screenshotting would occur with monitor.isDragging() already being true, * and if you apply any styling like a decreased opacity to the dragged element, this styling will also be reflected on the * screenshot. This is rarely desirable, so false is a sensible default. However, you might want to set it to true in rare cases, * such as if you want to make the custom drag layers work in IE and you need to hide the original element without resorting to * an empty drag preview which IE doesn't support. */ captureDraggingState?: boolean; /** * Optional. A number between 0 and 1. By default, 0.5. Specifies how the offset relative to the drag source node is translated * into the horizontal offset of the drag preview when their sizes don't match. 0 means “dock the preview to the left”, 0.5 means * “interpolate linearly” and 1 means “dock the preview to the right”. */ anchorX?: number; /** * Optional. A number between 0 and 1. By default, 0.5. Specifies how the offset relative to the drag source node is translated into * the vertical offset of the drag preview when their sizes don't match. 0 means “dock the preview to the top, 0.5 means “interpolate * linearly” and 1 means “dock the preview to the bottom. */ anchorY?: number; /** * Optional. A number or null if not needed. By default, null. Specifies the vertical offset between the cursor and the drag preview * element. If offsetX has a value, anchorX won't be used. */ offsetX?: number; /** * Optional. A number or null if not needed. By default, null. Specifies the vertical offset between the cursor and the drag * preview element. If offsetY has a value, anchorY won't be used. */ offsetY?: number; } lib/interfaces/connectors.js000064400000000000151676724530012156 0ustar00lib/interfaces/connectors.d.ts000064400000001064151676724530012425 0ustar00/// <reference types="react" /> import { DragSourceOptions, DragPreviewOptions } from '../interfaces'; export declare type ConnectableElement = React.RefObject<any> | React.ReactElement | Element | null; export declare type DragElementWrapper<Options> = (elementOrNode: ConnectableElement, options?: Options) => React.ReactElement | null; export declare type ConnectDragSource = DragElementWrapper<DragSourceOptions>; export declare type ConnectDragPreview = DragElementWrapper<DragPreviewOptions>; export declare type ConnectDropTarget = DragElementWrapper<any>; lib/interfaces/index.d.ts000064400000000161151676724530011354 0ustar00export * from './monitors'; export * from './hooksApi'; export * from './options'; export * from './connectors'; lib/interfaces/options.js000064400000000000151676724530011474 0ustar00lib/hooks/useDragLayer.d.ts000064400000000370151676724530011636 0ustar00import { DragLayerMonitor } from '../interfaces'; /** * useDragLayer Hook * @param collector The property collector */ export declare function useDragLayer<CollectedProps>(collect: (monitor: DragLayerMonitor) => CollectedProps): CollectedProps; lib/hooks/useDragDropManager.d.ts000064400000000252151676724530012760 0ustar00import { DragDropManager } from 'dnd-core'; /** * A hook to retrieve the DragDropManager from Context */ export declare function useDragDropManager(): DragDropManager; lib/hooks/useDrag.d.ts000064400000000641151676724530010642 0ustar00import { DragSourceHookSpec, DragObjectWithType, ConnectDragSource, ConnectDragPreview } from '../interfaces'; /** * useDragSource hook * @param sourceSpec The drag source specification * */ export declare function useDrag<DragObject extends DragObjectWithType, DropResult, CollectedProps>(spec: DragSourceHookSpec<DragObject, DropResult, CollectedProps>): [CollectedProps, ConnectDragSource, ConnectDragPreview]; lib/hooks/useDrop.js000064400000002044151676724530010434 0ustar00import { useRef, useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { useMonitorOutput } from './internal/useMonitorOutput'; import { useIsomorphicLayoutEffect } from './internal/useIsomorphicLayoutEffect'; import { useDropHandler, useDropTargetMonitor } from './internal/drop'; /** * useDropTarget Hook * @param spec The drop target specification */ export function useDrop(spec) { const specRef = useRef(spec); specRef.current = spec; invariant(spec.accept != null, 'accept must be defined'); const [monitor, connector] = useDropTargetMonitor(); useDropHandler(specRef, monitor, connector); const result = useMonitorOutput(monitor, specRef.current.collect || (() => ({})), () => connector.reconnect()); const connectDropTarget = useMemo(() => connector.hooks.dropTarget(), [ connector, ]); useIsomorphicLayoutEffect(() => { connector.dropTargetOptions = spec.options || null; connector.reconnect(); }, [spec.options]); return [result, connectDropTarget]; } lib/hooks/useDrop.d.ts000064400000000561151676724530010672 0ustar00import { DropTargetHookSpec, ConnectDropTarget, DragObjectWithType } from '../interfaces'; /** * useDropTarget Hook * @param spec The drop target specification */ export declare function useDrop<DragObject extends DragObjectWithType, DropResult, CollectedProps>(spec: DropTargetHookSpec<DragObject, DropResult, CollectedProps>): [CollectedProps, ConnectDropTarget]; lib/hooks/internal/drag.js000064400000004704151676724530011551 0ustar00import { useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { registerSource } from '../../common/registration'; import { useDragDropManager } from '../useDragDropManager'; import { DragSourceMonitorImpl } from '../../common/DragSourceMonitorImpl'; import { SourceConnector } from '../../common/SourceConnector'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; export function useDragSourceMonitor() { const manager = useDragDropManager(); const monitor = useMemo(() => new DragSourceMonitorImpl(manager), [manager]); const connector = useMemo(() => new SourceConnector(manager.getBackend()), [ manager, ]); return [monitor, connector]; } export function useDragHandler(spec, monitor, connector) { const manager = useDragDropManager(); const handler = useMemo(() => { return { beginDrag() { const { begin, item } = spec.current; if (begin) { const beginResult = begin(monitor); invariant(beginResult == null || typeof beginResult === 'object', 'dragSpec.begin() must either return an object, undefined, or null'); return beginResult || item || {}; } return item || {}; }, canDrag() { if (typeof spec.current.canDrag === 'boolean') { return spec.current.canDrag; } else if (typeof spec.current.canDrag === 'function') { return spec.current.canDrag(monitor); } else { return true; } }, isDragging(globalMonitor, target) { const { isDragging } = spec.current; return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId(); }, endDrag() { const { end } = spec.current; if (end) { end(monitor.getItem(), monitor); } connector.reconnect(); }, }; }, []); useIsomorphicLayoutEffect(function registerHandler() { const [handlerId, unregister] = registerSource(spec.current.item.type, handler, manager); monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, []); } lib/hooks/internal/drag.d.ts000064400000001011151676724530011771 0ustar00import { MutableRefObject } from 'react'; import { DragSourceHookSpec, DragObjectWithType, DragSourceMonitor } from '../../interfaces'; import { SourceConnector } from '../../common/SourceConnector'; export declare function useDragSourceMonitor(): [DragSourceMonitor, SourceConnector]; export declare function useDragHandler<DragObject extends DragObjectWithType, DropResult, CustomProps>(spec: MutableRefObject<DragSourceHookSpec<DragObject, DropResult, CustomProps>>, monitor: DragSourceMonitor, connector: any): void; lib/hooks/internal/useIsomorphicLayoutEffect.d.ts000064400000000145151676724530016227 0ustar00import { useEffect } from 'react'; export declare const useIsomorphicLayoutEffect: typeof useEffect; lib/hooks/internal/useCollector.d.ts000064400000000436151676724530013531 0ustar00/** * * @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]; lib/hooks/internal/useMonitorOutput.d.ts000064400000000422151676724530014446 0ustar00import { HandlerManager, MonitorEventEmitter } from '../../interfaces'; export declare function useMonitorOutput<Monitor extends HandlerManager, Collected>(monitor: Monitor & MonitorEventEmitter, collect: (monitor: Monitor) => Collected, onCollect?: () => void): Collected; lib/hooks/internal/useIsomorphicLayoutEffect.js000064400000000322151676724530015770 0ustar00import { useLayoutEffect, useEffect } from 'react'; // suppress the useLayoutEffect warning on server side. export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; lib/hooks/internal/useMonitorOutput.js000064400000001176151676724530014221 0ustar00import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; import { useCollector } from './useCollector'; export function useMonitorOutput(monitor, collect, onCollect) { const [collected, updateCollected] = useCollector(monitor, collect, onCollect); useIsomorphicLayoutEffect(function subscribeToMonitorStateChange() { const handlerId = monitor.getHandlerId(); if (handlerId == null) { return undefined; } return monitor.subscribeToStateChange(updateCollected, { handlerIds: [handlerId], }); }, [monitor, updateCollected]); return collected; } lib/hooks/internal/drop.d.ts000064400000001011151676724530012020 0ustar00import { DragObjectWithType, DropTargetMonitor, DropTargetHookSpec } from '../../interfaces'; import { MutableRefObject } from 'react'; import { TargetConnector } from '../../common/TargetConnector'; export declare function useDropTargetMonitor(): [DropTargetMonitor, TargetConnector]; export declare function useDropHandler<DragObject extends DragObjectWithType, DropResult, CustomProps>(spec: MutableRefObject<DropTargetHookSpec<DragObject, DropResult, CustomProps>>, monitor: DropTargetMonitor, connector: any): void; lib/hooks/internal/drop.js000064400000003250151676724530011573 0ustar00import { useMemo } from 'react'; import { registerTarget } from '../../common/registration'; import { useDragDropManager } from '../useDragDropManager'; import { TargetConnector } from '../../common/TargetConnector'; import { DropTargetMonitorImpl } from '../../common/DropTargetMonitorImpl'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; export function useDropTargetMonitor() { const manager = useDragDropManager(); const monitor = useMemo(() => new DropTargetMonitorImpl(manager), [manager]); const connector = useMemo(() => new TargetConnector(manager.getBackend()), [ manager, ]); return [monitor, connector]; } export function useDropHandler(spec, monitor, connector) { const manager = useDragDropManager(); const handler = useMemo(() => { return { canDrop() { const { canDrop } = spec.current; return canDrop ? canDrop(monitor.getItem(), monitor) : true; }, hover() { const { hover } = spec.current; if (hover) { hover(monitor.getItem(), monitor); } }, drop() { const { drop } = spec.current; if (drop) { return drop(monitor.getItem(), monitor); } }, }; }, [monitor]); useIsomorphicLayoutEffect(function registerHandler() { const [handlerId, unregister] = registerTarget(spec.current.accept, handler, manager); monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, [monitor, connector]); } lib/hooks/internal/useCollector.js000064400000001721151676724530013273 0ustar00import { shallowEqual } from '@react-dnd/shallowequal'; import { useState, useCallback } from 'react'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; /** * * @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); if (!shallowEqual(collected, nextValue)) { setCollected(nextValue); if (onUpdate) { onUpdate(); } } }, [collected, monitor, onUpdate]); // update the collected properties after the first render // and the components are attached to dnd-core useIsomorphicLayoutEffect(updateCollected, []); return [collected, updateCollected]; } lib/hooks/index.js000064400000000174151676724530010124 0ustar00export * from './useDrag'; export * from './useDrop'; export * from './useDragLayer'; export * from './useDragDropManager'; lib/hooks/useDrag.js000064400000002717151676724530010414 0ustar00import { useRef, useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { useMonitorOutput } from './internal/useMonitorOutput'; import { useIsomorphicLayoutEffect } from './internal/useIsomorphicLayoutEffect'; import { useDragSourceMonitor, useDragHandler } from './internal/drag'; /** * useDragSource hook * @param sourceSpec The drag source specification * */ export function useDrag(spec) { const specRef = useRef(spec); specRef.current = spec; // TODO: wire options into createSourceConnector invariant(spec.item != null, 'item must be defined'); invariant(spec.item.type != null, 'item type must be defined'); const [monitor, connector] = useDragSourceMonitor(); useDragHandler(specRef, monitor, connector); const result = useMonitorOutput(monitor, specRef.current.collect || (() => ({})), () => connector.reconnect()); const connectDragSource = useMemo(() => connector.hooks.dragSource(), [ connector, ]); const connectDragPreview = useMemo(() => connector.hooks.dragPreview(), [ connector, ]); useIsomorphicLayoutEffect(() => { connector.dragSourceOptions = specRef.current.options || null; connector.reconnect(); }, [connector]); useIsomorphicLayoutEffect(() => { connector.dragPreviewOptions = specRef.current.previewOptions || null; connector.reconnect(); }, [connector]); return [result, connectDragSource, connectDragPreview]; } lib/hooks/index.d.ts000064400000000174151676724530010360 0ustar00export * from './useDrag'; export * from './useDrop'; export * from './useDragLayer'; export * from './useDragDropManager'; lib/hooks/useDragLayer.js000064400000001130151676724530011375 0ustar00import { useEffect } from 'react'; import { useDragDropManager } from './useDragDropManager'; import { useCollector } from './internal/useCollector'; /** * 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; } lib/hooks/useDragDropManager.js000064400000000613151676724530012525 0ustar00import { useContext } from 'react'; import { invariant } from '@react-dnd/invariant'; import { DndContext } from '../common/DndContext'; /** * A hook to retrieve the DragDropManager from Context */ export function useDragDropManager() { const { dragDropManager } = useContext(DndContext); invariant(dragDropManager != null, 'Expected drag drop context'); return dragDropManager; } lib/index.d.ts000064400000000157151676724530007236 0ustar00export * from './common'; export * from './interfaces'; export * from './hooks'; export * from './decorators'; lib/common/SourceConnector.js000064400000013044151676724530012275 0ustar00import { wrapConnectorHooks } from './wrapConnectorHooks'; import { isRef } from '../utils/isRef'; import { shallowEqual } from '@react-dnd/shallowequal'; export class SourceConnector { 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; } 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() { this.reconnectDragSource(); this.reconnectDragPreview(); } 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; } if (!dragSource) { this.lastConnectedDragSource = dragSource; return; } if (didChange) { this.lastConnectedHandlerId = this.handlerId; this.lastConnectedDragSource = dragSource; this.lastConnectedDragSourceOptions = this.dragSourceOptions; this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions); } } reconnectDragPreview() { const dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe const didChange = 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; } } lib/common/DragPreviewImage.d.ts000064400000000371151676724530012577 0ustar00import * as React from 'react'; import { ConnectDragPreview } from '../interfaces'; export interface DragPreviewImageProps { connect: ConnectDragPreview; src: string; } export declare const DragPreviewImage: React.FC<DragPreviewImageProps>; lib/common/registration.d.ts000064400000000573151676724530012133 0ustar00import { DragDropManager, DropTarget, Unsubscribe, Identifier, TargetType, SourceType, DragSource } 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]; lib/common/DropTargetMonitorImpl.js000064400000004204151676724530013425 0ustar00import { invariant } from '@react-dnd/invariant'; let isCallingCanDrop = false; export class DropTargetMonitorImpl { constructor(manager) { this.targetId = null; this.internalMonitor = manager.getMonitor(); } 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(); } } lib/common/wrapConnectorHooks.d.ts000064400000000075151676724530013246 0ustar00export declare function wrapConnectorHooks(hooks: any): any; lib/common/DndProvider.js000064400000003472151676724530011406 0ustar00import * as React from 'react'; import { memo } from 'react'; import { DndContext, createDndContext } from './DndContext'; let refCount = 0; /** * A React component that provides the React-DnD context */ export const DndProvider = memo(({ children, ...props }) => { 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 */ React.useEffect(() => { if (isGlobalInstance) { refCount++; } return () => { if (isGlobalInstance) { refCount--; if (refCount === 0) { const context = getGlobalContext(); context[instanceSymbol] = null; } } }; }, []); return React.createElement(DndContext.Provider, { value: manager }, children); }); DndProvider.displayName = '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]; } const instanceSymbol = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__'); function createSingletonDndContext(backend, context = getGlobalContext(), options, debugMode) { const ctx = context; if (!ctx[instanceSymbol]) { ctx[instanceSymbol] = createDndContext(backend, context, options, debugMode); } return ctx[instanceSymbol]; } function getGlobalContext() { return typeof global !== 'undefined' ? global : window; } lib/common/wrapConnectorHooks.js000064400000004104151676724530013007 0ustar00import { isValidElement } from 'react'; import { cloneWithRef } from '../utils/cloneWithRef'; 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; } lib/common/DragSourceMonitorImpl.d.ts000064400000002503151676724530013644 0ustar00import { DragDropManager, Unsubscribe, Listener, Identifier, XYCoord } from 'dnd-core'; import { DragSourceMonitor } from '../interfaces'; 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[] | undefined; }): 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; } lib/common/DndProvider.d.ts000064400000000707151676724530011640 0ustar00import * as React from 'react'; import { BackendFactory, DragDropManager } from 'dnd-core'; export declare type DndProviderProps<BackendContext, BackendOptions> = { manager: DragDropManager; } | { backend: BackendFactory; context?: BackendContext; options?: BackendOptions; debugMode?: boolean; }; /** * A React component that provides the React-DnD context */ export declare const DndProvider: React.FC<DndProviderProps<any, any>>; lib/common/DropTargetMonitorImpl.d.ts000064400000001705151676724530013664 0ustar00import { DragDropManager, Unsubscribe, Listener, Identifier, XYCoord } from 'dnd-core'; import { DropTargetMonitor } from '../interfaces'; 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[] | undefined; }): 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; } lib/common/index.js000064400000000141151676724530010263 0ustar00export * from './DndContext'; export * from './DndProvider'; export * from './DragPreviewImage'; lib/common/TargetConnector.js000064400000005704151676724530012267 0ustar00import { shallowEqual } from '@react-dnd/shallowequal'; import { wrapConnectorHooks } from './wrapConnectorHooks'; import { isRef } from '../utils/isRef'; export class TargetConnector { 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; } 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; } } lib/common/DndContext.js000064400000000732151676724530011234 0ustar00import * as React from 'react'; import { createDragDropManager, } from 'dnd-core'; /** * Create the React Context */ export const DndContext = React.createContext({ dragDropManager: undefined, }); /** * Creates the context object we're providing * @param backend * @param context */ export function createDndContext(backend, context, options, debugMode) { return { dragDropManager: createDragDropManager(backend, context, options, debugMode), }; } lib/common/DragPreviewImage.js000064400000001147151676724530012345 0ustar00import * as React from 'react'; /* * A utility for rendering a drag preview image */ export const DragPreviewImage = React.memo(({ connect, src }) => { React.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; }); DragPreviewImage.displayName = 'DragPreviewImage'; lib/common/DragSourceMonitorImpl.js000064400000005745151676724530013423 0ustar00import { invariant } from '@react-dnd/invariant'; let isCallingCanDrag = false; let isCallingIsDragging = false; export class DragSourceMonitorImpl { constructor(manager) { this.sourceId = null; this.internalMonitor = manager.getMonitor(); } 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(); } } lib/common/index.d.ts000064400000000141151676724530010517 0ustar00export * from './DndContext'; export * from './DndProvider'; export * from './DragPreviewImage'; lib/common/registration.js000064400000000666151676724530011702 0ustar00export 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)]; } lib/common/DndContext.d.ts000064400000001116151676724530011465 0ustar00import * as React from 'react'; import { DragDropManager, BackendFactory } from 'dnd-core'; /** * The React context type */ export interface DndContextType { dragDropManager: DragDropManager | undefined; } /** * Create the React Context */ export declare const DndContext: React.Context<DndContextType>; /** * Creates the context object we're providing * @param backend * @param context */ export declare function createDndContext<BackendContext, BackendOptions>(backend: BackendFactory, context?: BackendContext, options?: BackendOptions, debugMode?: boolean): DndContextType; lib/common/TargetConnector.d.ts000064400000001564151676724530012523 0ustar00import { Backend, Identifier } from 'dnd-core'; import { Connector } from './SourceConnector'; 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(): any; set dropTargetOptions(options: any); private didHandlerIdChange; private didDropTargetChange; private didOptionsChange; private disconnectDropTarget; private get dropTarget(); private clearDropTarget; } lib/common/SourceConnector.d.ts000064400000003251151676724530012530 0ustar00import { Backend, Identifier } from 'dnd-core'; import { DragSourceOptions, DragPreviewOptions } from '../interfaces'; 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; private disconnectDragSource; private disconnectDragPreview; private get dragSource(); private get dragPreview(); private clearDragSource; private clearDragPreview; } LICENSE000064400000002067151676724530005576 0ustar00The 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. dist/umd/ReactDnD.js000064400000532472151676724530010313 0ustar00(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : (global = global || self, factory(global.ReactDnD = {}, global.React)); }(this, (function (exports, React) { 'use strict'; var HandlerRole; (function (HandlerRole) { HandlerRole["SOURCE"] = "SOURCE"; HandlerRole["TARGET"] = "TARGET"; })(HandlerRole || (HandlerRole = {})); function symbolObservablePonyfill(root) { var result; var Symbol = root.Symbol; if (typeof Symbol === 'function') { if (Symbol.observable) { result = Symbol.observable; } else { result = Symbol('observable'); Symbol.observable = result; } } else { result = '@@observable'; } return result; } /* global window */ var root; if (typeof self !== 'undefined') { root = self; } else if (typeof window !== 'undefined') { root = window; } else if (typeof global !== 'undefined') { root = global; } else if (typeof module !== 'undefined') { root = module; } else { root = Function('return this')(); } var result = symbolObservablePonyfill(root); /** * These are private action types reserved by Redux. * For any unknown actions, you must return the current state. * If the current state is undefined, you must return the initial state. * Do not reference these action types directly in your code. */ var randomString = function randomString() { return Math.random().toString(36).substring(7).split('').join('.'); }; var ActionTypes = { INIT: "@@redux/INIT" + randomString(), REPLACE: "@@redux/REPLACE" + randomString(), PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() { return "@@redux/PROBE_UNKNOWN_ACTION" + randomString(); } }; /** * @param {any} obj The object to inspect. * @returns {boolean} True if the argument appears to be a plain object. */ function isPlainObject(obj) { if (typeof obj !== 'object' || obj === null) return false; var proto = obj; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(obj) === proto; } /** * Creates a Redux store that holds the state tree. * The only way to change the data in the store is to call `dispatch()` on it. * * There should only be a single store in your app. To specify how different * parts of the state tree respond to actions, you may combine several reducers * into a single reducer function by using `combineReducers`. * * @param {Function} reducer A function that returns the next state tree, given * the current state tree and the action to handle. * * @param {any} [preloadedState] The initial state. You may optionally specify it * to hydrate the state from the server in universal apps, or to restore a * previously serialized user session. * If you use `combineReducers` to produce the root reducer function, this must be * an object with the same shape as `combineReducers` keys. * * @param {Function} [enhancer] The store enhancer. You may optionally specify it * to enhance the store with third-party capabilities such as middleware, * time travel, persistence, etc. The only store enhancer that ships with Redux * is `applyMiddleware()`. * * @returns {Store} A Redux store that lets you read the state, dispatch actions * and subscribe to changes. */ function createStore(reducer, preloadedState, enhancer) { var _ref2; if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') { throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.'); } if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') { enhancer = preloadedState; preloadedState = undefined; } if (typeof enhancer !== 'undefined') { if (typeof enhancer !== 'function') { throw new Error('Expected the enhancer to be a function.'); } return enhancer(createStore)(reducer, preloadedState); } if (typeof reducer !== 'function') { throw new Error('Expected the reducer to be a function.'); } var currentReducer = reducer; var currentState = preloadedState; var currentListeners = []; var nextListeners = currentListeners; var isDispatching = false; /** * This makes a shallow copy of currentListeners so we can use * nextListeners as a temporary list while dispatching. * * This prevents any bugs around consumers calling * subscribe/unsubscribe in the middle of a dispatch. */ function ensureCanMutateNextListeners() { if (nextListeners === currentListeners) { nextListeners = currentListeners.slice(); } } /** * Reads the state tree managed by the store. * * @returns {any} The current state tree of your application. */ function getState() { if (isDispatching) { throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.'); } return currentState; } /** * Adds a change listener. It will be called any time an action is dispatched, * and some part of the state tree may potentially have changed. You may then * call `getState()` to read the current state tree inside the callback. * * You may call `dispatch()` from a change listener, with the following * caveats: * * 1. The subscriptions are snapshotted just before every `dispatch()` call. * If you subscribe or unsubscribe while the listeners are being invoked, this * will not have any effect on the `dispatch()` that is currently in progress. * However, the next `dispatch()` call, whether nested or not, will use a more * recent snapshot of the subscription list. * * 2. The listener should not expect to see all state changes, as the state * might have been updated multiple times during a nested `dispatch()` before * the listener is called. It is, however, guaranteed that all subscribers * registered before the `dispatch()` started will be called with the latest * state by the time it exits. * * @param {Function} listener A callback to be invoked on every dispatch. * @returns {Function} A function to remove this change listener. */ function subscribe(listener) { if (typeof listener !== 'function') { throw new Error('Expected the listener to be a function.'); } if (isDispatching) { throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.'); } var isSubscribed = true; ensureCanMutateNextListeners(); nextListeners.push(listener); return function unsubscribe() { if (!isSubscribed) { return; } if (isDispatching) { throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.'); } isSubscribed = false; ensureCanMutateNextListeners(); var index = nextListeners.indexOf(listener); nextListeners.splice(index, 1); currentListeners = null; }; } /** * Dispatches an action. It is the only way to trigger a state change. * * The `reducer` function, used to create the store, will be called with the * current state tree and the given `action`. Its return value will * be considered the **next** state of the tree, and the change listeners * will be notified. * * The base implementation only supports plain object actions. If you want to * dispatch a Promise, an Observable, a thunk, or something else, you need to * wrap your store creating function into the corresponding middleware. For * example, see the documentation for the `redux-thunk` package. Even the * middleware will eventually dispatch plain object actions using this method. * * @param {Object} action A plain object representing “what changed”. It is * a good idea to keep actions serializable so you can record and replay user * sessions, or use the time travelling `redux-devtools`. An action must have * a `type` property which may not be `undefined`. It is a good idea to use * string constants for action types. * * @returns {Object} For convenience, the same action object you dispatched. * * Note that, if you use a custom middleware, it may wrap `dispatch()` to * return something else (for example, a Promise you can await). */ function dispatch(action) { if (!isPlainObject(action)) { throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); } if (typeof action.type === 'undefined') { throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); } if (isDispatching) { throw new Error('Reducers may not dispatch actions.'); } try { isDispatching = true; currentState = currentReducer(currentState, action); } finally { isDispatching = false; } var listeners = currentListeners = nextListeners; for (var i = 0; i < listeners.length; i++) { var listener = listeners[i]; listener(); } return action; } /** * Replaces the reducer currently used by the store to calculate the state. * * You might need this if your app implements code splitting and you want to * load some of the reducers dynamically. You might also need this if you * implement a hot reloading mechanism for Redux. * * @param {Function} nextReducer The reducer for the store to use instead. * @returns {void} */ function replaceReducer(nextReducer) { if (typeof nextReducer !== 'function') { throw new Error('Expected the nextReducer to be a function.'); } currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT. // Any reducers that existed in both the new and old rootReducer // will receive the previous state. This effectively populates // the new state tree with any relevant data from the old one. dispatch({ type: ActionTypes.REPLACE }); } /** * Interoperability point for observable/reactive libraries. * @returns {observable} A minimal observable of state changes. * For more information, see the observable proposal: * https://github.com/tc39/proposal-observable */ function observable() { var _ref; var outerSubscribe = subscribe; return _ref = { /** * The minimal observable subscription method. * @param {Object} observer Any object that can be used as an observer. * The observer object should have a `next` method. * @returns {subscription} An object with an `unsubscribe` method that can * be used to unsubscribe the observable from the store, and prevent further * emission of values from the observable. */ subscribe: function subscribe(observer) { if (typeof observer !== 'object' || observer === null) { throw new TypeError('Expected the observer to be an object.'); } function observeState() { if (observer.next) { observer.next(getState()); } } observeState(); var unsubscribe = outerSubscribe(observeState); return { unsubscribe: unsubscribe }; } }, _ref[result] = function () { return this; }, _ref; } // When a store is created, an "INIT" action is dispatched so that every // reducer returns their initial state. This effectively populates // the initial state tree. dispatch({ type: ActionTypes.INIT }); return _ref2 = { dispatch: dispatch, subscribe: subscribe, getState: getState, replaceReducer: replaceReducer }, _ref2[result] = observable, _ref2; } /** * Prints a warning in the console if it exists. * * @param {String} message The warning message. * @returns {void} */ function warning(message) { /* eslint-disable no-console */ if (typeof console !== 'undefined' && typeof console.error === 'function') { console.error(message); } /* eslint-enable no-console */ try { // This error was thrown as a convenience so that if you enable // "break on all exceptions" in your console, // it would pause the execution at this line. throw new Error(message); } catch (e) {} // eslint-disable-line no-empty } /* * This is a dummy function to check if the function name has been altered by minification. * If the function has been minified and NODE_ENV !== 'production', warn the user. */ function isCrushed() {} if ( typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') { warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.'); } /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ function invariant(condition, format) { for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } { if (format === undefined) { throw new Error('invariant requires an error message argument'); } } if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } var INIT_COORDS = 'dnd-core/INIT_COORDS'; var BEGIN_DRAG = 'dnd-core/BEGIN_DRAG'; var PUBLISH_DRAG_SOURCE = 'dnd-core/PUBLISH_DRAG_SOURCE'; var HOVER = 'dnd-core/HOVER'; var DROP = 'dnd-core/DROP'; var END_DRAG = 'dnd-core/END_DRAG'; function setClientOffset(clientOffset, sourceClientOffset) { return { type: INIT_COORDS, payload: { sourceClientOffset: sourceClientOffset || null, clientOffset: clientOffset || null } }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } // cheap lodash replacements /** * drop-in replacement for _.get * @param obj * @param path * @param defaultValue */ function get(obj, path, defaultValue) { return path.split('.').reduce(function (a, c) { return a && a[c] ? a[c] : defaultValue || null; }, obj); } /** * drop-in replacement for _.without */ function without(items, item) { return items.filter(function (i) { return i !== item; }); } /** * drop-in replacement for _.isString * @param input */ function isObject(input) { return _typeof(input) === 'object'; } /** * repalcement for _.xor * @param itemsA * @param itemsB */ function xor(itemsA, itemsB) { var map = new Map(); var insertItem = function insertItem(item) { map.set(item, map.has(item) ? map.get(item) + 1 : 1); }; itemsA.forEach(insertItem); itemsB.forEach(insertItem); var result = []; map.forEach(function (count, key) { if (count === 1) { result.push(key); } }); return result; } /** * replacement for _.intersection * @param itemsA * @param itemsB */ function intersection(itemsA, itemsB) { return itemsA.filter(function (t) { return itemsB.indexOf(t) > -1; }); } var ResetCoordinatesAction = { type: INIT_COORDS, payload: { clientOffset: null, sourceClientOffset: null } }; function createBeginDrag(manager) { return function beginDrag() { var sourceIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { publishSource: true }; var _options$publishSourc = options.publishSource, publishSource = _options$publishSourc === void 0 ? true : _options$publishSourc, clientOffset = options.clientOffset, getSourceClientOffset = options.getSourceClientOffset; var monitor = manager.getMonitor(); var registry = manager.getRegistry(); // Initialize the coordinates using the client offset manager.dispatch(setClientOffset(clientOffset)); verifyInvariants(sourceIds, monitor, registry); // Get the draggable source var sourceId = getDraggableSource(sourceIds, monitor); if (sourceId === null) { manager.dispatch(ResetCoordinatesAction); return; } // Get the source client offset var sourceClientOffset = null; if (clientOffset) { if (!getSourceClientOffset) { throw new Error('getSourceClientOffset must be defined'); } verifyGetSourceClientOffsetIsFunction(getSourceClientOffset); sourceClientOffset = getSourceClientOffset(sourceId); } // Initialize the full coordinates manager.dispatch(setClientOffset(clientOffset, sourceClientOffset)); var source = registry.getSource(sourceId); var item = source.beginDrag(monitor, sourceId); verifyItemIsObject(item); registry.pinSource(sourceId); var itemType = registry.getSourceType(sourceId); return { type: BEGIN_DRAG, payload: { itemType: itemType, item: item, sourceId: sourceId, clientOffset: clientOffset || null, sourceClientOffset: sourceClientOffset || null, isSourcePublic: !!publishSource } }; }; } function verifyInvariants(sourceIds, monitor, registry) { invariant(!monitor.isDragging(), 'Cannot call beginDrag while dragging.'); sourceIds.forEach(function (sourceId) { invariant(registry.getSource(sourceId), 'Expected sourceIds to be registered.'); }); } function verifyGetSourceClientOffsetIsFunction(getSourceClientOffset) { invariant(typeof getSourceClientOffset === 'function', 'When clientOffset is provided, getSourceClientOffset must be a function.'); } function verifyItemIsObject(item) { invariant(isObject(item), 'Item must be an object.'); } function getDraggableSource(sourceIds, monitor) { var sourceId = null; for (var i = sourceIds.length - 1; i >= 0; i--) { if (monitor.canDragSource(sourceIds[i])) { sourceId = sourceIds[i]; break; } } return sourceId; } function createPublishDragSource(manager) { return function publishDragSource() { var monitor = manager.getMonitor(); if (monitor.isDragging()) { return { type: PUBLISH_DRAG_SOURCE }; } }; } function matchesType(targetType, draggedItemType) { if (draggedItemType === null) { return targetType === null; } return Array.isArray(targetType) ? targetType.some(function (t) { return t === draggedItemType; }) : targetType === draggedItemType; } function createHover(manager) { return function hover(targetIdsArg) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, clientOffset = _ref.clientOffset; verifyTargetIdsIsArray(targetIdsArg); var targetIds = targetIdsArg.slice(0); var monitor = manager.getMonitor(); var registry = manager.getRegistry(); checkInvariants(targetIds, monitor, registry); var draggedItemType = monitor.getItemType(); removeNonMatchingTargetIds(targetIds, registry, draggedItemType); hoverAllTargets(targetIds, monitor, registry); return { type: HOVER, payload: { targetIds: targetIds, clientOffset: clientOffset || null } }; }; } function verifyTargetIdsIsArray(targetIdsArg) { invariant(Array.isArray(targetIdsArg), 'Expected targetIds to be an array.'); } function checkInvariants(targetIds, monitor, registry) { invariant(monitor.isDragging(), 'Cannot call hover while not dragging.'); invariant(!monitor.didDrop(), 'Cannot call hover after drop.'); for (var i = 0; i < targetIds.length; i++) { var targetId = targetIds[i]; invariant(targetIds.lastIndexOf(targetId) === i, 'Expected targetIds to be unique in the passed array.'); var target = registry.getTarget(targetId); invariant(target, 'Expected targetIds to be registered.'); } } function removeNonMatchingTargetIds(targetIds, registry, draggedItemType) { // Remove those targetIds that don't match the targetType. This // fixes shallow isOver which would only be non-shallow because of // non-matching targets. for (var i = targetIds.length - 1; i >= 0; i--) { var targetId = targetIds[i]; var targetType = registry.getTargetType(targetId); if (!matchesType(targetType, draggedItemType)) { targetIds.splice(i, 1); } } } function hoverAllTargets(targetIds, monitor, registry) { // Finally call hover on all matching targets. targetIds.forEach(function (targetId) { var target = registry.getTarget(targetId); target.hover(monitor, targetId); }); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function createDrop(manager) { return function drop() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var monitor = manager.getMonitor(); var registry = manager.getRegistry(); verifyInvariants$1(monitor); var targetIds = getDroppableTargets(monitor); // Multiple actions are dispatched here, which is why this doesn't return an action targetIds.forEach(function (targetId, index) { var dropResult = determineDropResult(targetId, index, registry, monitor); var action = { type: DROP, payload: { dropResult: _objectSpread(_objectSpread({}, options), dropResult) } }; manager.dispatch(action); }); }; } function verifyInvariants$1(monitor) { invariant(monitor.isDragging(), 'Cannot call drop while not dragging.'); invariant(!monitor.didDrop(), 'Cannot call drop twice during one drag operation.'); } function determineDropResult(targetId, index, registry, monitor) { var target = registry.getTarget(targetId); var dropResult = target ? target.drop(monitor, targetId) : undefined; verifyDropResultType(dropResult); if (typeof dropResult === 'undefined') { dropResult = index === 0 ? {} : monitor.getDropResult(); } return dropResult; } function verifyDropResultType(dropResult) { invariant(typeof dropResult === 'undefined' || isObject(dropResult), 'Drop result must either be an object or undefined.'); } function getDroppableTargets(monitor) { var targetIds = monitor.getTargetIds().filter(monitor.canDropOnTarget, monitor); targetIds.reverse(); return targetIds; } function createEndDrag(manager) { return function endDrag() { var monitor = manager.getMonitor(); var registry = manager.getRegistry(); verifyIsDragging(monitor); var sourceId = monitor.getSourceId(); if (sourceId != null) { var source = registry.getSource(sourceId, true); source.endDrag(monitor, sourceId); registry.unpinSource(); } return { type: END_DRAG }; }; } function verifyIsDragging(monitor) { invariant(monitor.isDragging(), 'Cannot call endDrag while not dragging.'); } function createDragDropActions(manager) { return { beginDrag: createBeginDrag(manager), publishDragSource: createPublishDragSource(manager), hover: createHover(manager), drop: createDrop(manager), endDrag: createEndDrag(manager) }; } var strictEquality = function strictEquality(a, b) { return a === b; }; /** * Determine if two cartesian coordinate offsets are equal * @param offsetA * @param offsetB */ function areCoordsEqual(offsetA, offsetB) { if (!offsetA && !offsetB) { return true; } else if (!offsetA || !offsetB) { return false; } else { return offsetA.x === offsetB.x && offsetA.y === offsetB.y; } } /** * Determines if two arrays of items are equal * @param a The first array of items * @param b The second array of items */ function areArraysEqual(a, b) { var isEqual = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : strictEquality; if (a.length !== b.length) { return false; } for (var i = 0; i < a.length; ++i) { if (!isEqual(a[i], b[i])) { return false; } } return true; } function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var initialState = { initialSourceClientOffset: null, initialClientOffset: null, clientOffset: null }; function reduce() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments.length > 1 ? arguments[1] : undefined; var payload = action.payload; switch (action.type) { case INIT_COORDS: case BEGIN_DRAG: return { initialSourceClientOffset: payload.sourceClientOffset, initialClientOffset: payload.clientOffset, clientOffset: payload.clientOffset }; case HOVER: if (areCoordsEqual(state.clientOffset, payload.clientOffset)) { return state; } return _objectSpread$1(_objectSpread$1({}, state), {}, { clientOffset: payload.clientOffset }); case END_DRAG: case DROP: return initialState; default: return state; } } var ADD_SOURCE = 'dnd-core/ADD_SOURCE'; var ADD_TARGET = 'dnd-core/ADD_TARGET'; var REMOVE_SOURCE = 'dnd-core/REMOVE_SOURCE'; var REMOVE_TARGET = 'dnd-core/REMOVE_TARGET'; function addSource(sourceId) { return { type: ADD_SOURCE, payload: { sourceId: sourceId } }; } function addTarget(targetId) { return { type: ADD_TARGET, payload: { targetId: targetId } }; } function removeSource(sourceId) { return { type: REMOVE_SOURCE, payload: { sourceId: sourceId } }; } function removeTarget(targetId) { return { type: REMOVE_TARGET, payload: { targetId: targetId } }; } function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var initialState$1 = { itemType: null, item: null, sourceId: null, targetIds: [], dropResult: null, didDrop: false, isSourcePublic: null }; function reduce$1() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState$1; var action = arguments.length > 1 ? arguments[1] : undefined; var payload = action.payload; switch (action.type) { case BEGIN_DRAG: return _objectSpread$2(_objectSpread$2({}, state), {}, { itemType: payload.itemType, item: payload.item, sourceId: payload.sourceId, isSourcePublic: payload.isSourcePublic, dropResult: null, didDrop: false }); case PUBLISH_DRAG_SOURCE: return _objectSpread$2(_objectSpread$2({}, state), {}, { isSourcePublic: true }); case HOVER: return _objectSpread$2(_objectSpread$2({}, state), {}, { targetIds: payload.targetIds }); case REMOVE_TARGET: if (state.targetIds.indexOf(payload.targetId) === -1) { return state; } return _objectSpread$2(_objectSpread$2({}, state), {}, { targetIds: without(state.targetIds, payload.targetId) }); case DROP: return _objectSpread$2(_objectSpread$2({}, state), {}, { dropResult: payload.dropResult, didDrop: true, targetIds: [] }); case END_DRAG: return _objectSpread$2(_objectSpread$2({}, state), {}, { itemType: null, item: null, sourceId: null, dropResult: null, didDrop: false, isSourcePublic: null, targetIds: [] }); default: return state; } } function reduce$2() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case ADD_SOURCE: case ADD_TARGET: return state + 1; case REMOVE_SOURCE: case REMOVE_TARGET: return state - 1; default: return state; } } var NONE = []; var ALL = []; NONE.__IS_NONE__ = true; ALL.__IS_ALL__ = true; /** * Determines if the given handler IDs are dirty or not. * * @param dirtyIds The set of dirty handler ids * @param handlerIds The set of handler ids to check */ function areDirty(dirtyIds, handlerIds) { if (dirtyIds === NONE) { return false; } if (dirtyIds === ALL || typeof handlerIds === 'undefined') { return true; } var commonIds = intersection(handlerIds, dirtyIds); return commonIds.length > 0; } function reduce$3() { var action = arguments.length > 1 ? arguments[1] : undefined; switch (action.type) { case HOVER: break; case ADD_SOURCE: case ADD_TARGET: case REMOVE_TARGET: case REMOVE_SOURCE: return NONE; case BEGIN_DRAG: case PUBLISH_DRAG_SOURCE: case END_DRAG: case DROP: default: return ALL; } var _action$payload = action.payload, _action$payload$targe = _action$payload.targetIds, targetIds = _action$payload$targe === void 0 ? [] : _action$payload$targe, _action$payload$prevT = _action$payload.prevTargetIds, prevTargetIds = _action$payload$prevT === void 0 ? [] : _action$payload$prevT; var result = xor(targetIds, prevTargetIds); var didChange = result.length > 0 || !areArraysEqual(targetIds, prevTargetIds); if (!didChange) { return NONE; } // Check the target ids at the innermost position. If they are valid, add them // to the result var prevInnermostTargetId = prevTargetIds[prevTargetIds.length - 1]; var innermostTargetId = targetIds[targetIds.length - 1]; if (prevInnermostTargetId !== innermostTargetId) { if (prevInnermostTargetId) { result.push(prevInnermostTargetId); } if (innermostTargetId) { result.push(innermostTargetId); } } return result; } function reduce$4() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; return state + 1; } function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function reduce$5() { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var action = arguments.length > 1 ? arguments[1] : undefined; return { dirtyHandlerIds: reduce$3(state.dirtyHandlerIds, { type: action.type, payload: _objectSpread$3(_objectSpread$3({}, action.payload), {}, { prevTargetIds: get(state, 'dragOperation.targetIds', []) }) }), dragOffset: reduce(state.dragOffset, action), refCount: reduce$2(state.refCount, action), dragOperation: reduce$1(state.dragOperation, action), stateId: reduce$4(state.stateId) }; } /** * Coordinate addition * @param a The first coordinate * @param b The second coordinate */ function add(a, b) { return { x: a.x + b.x, y: a.y + b.y }; } /** * Coordinate subtraction * @param a The first coordinate * @param b The second coordinate */ function subtract(a, b) { return { x: a.x - b.x, y: a.y - b.y }; } /** * Returns the cartesian distance of the drag source component's position, based on its position * at the time when the current drag operation has started, and the movement difference. * * Returns null if no item is being dragged. * * @param state The offset state to compute from */ function getSourceClientOffset(state) { var clientOffset = state.clientOffset, initialClientOffset = state.initialClientOffset, initialSourceClientOffset = state.initialSourceClientOffset; if (!clientOffset || !initialClientOffset || !initialSourceClientOffset) { return null; } return subtract(add(clientOffset, initialSourceClientOffset), initialClientOffset); } /** * Determines the x,y offset between the client offset and the initial client offset * * @param state The offset state to compute from */ function getDifferenceFromInitialOffset(state) { var clientOffset = state.clientOffset, initialClientOffset = state.initialClientOffset; if (!clientOffset || !initialClientOffset) { return null; } return subtract(clientOffset, initialClientOffset); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var DragDropMonitorImpl = /*#__PURE__*/function () { function DragDropMonitorImpl(store, registry) { _classCallCheck(this, DragDropMonitorImpl); this.store = store; this.registry = registry; } _createClass(DragDropMonitorImpl, [{ key: "subscribeToStateChange", value: function subscribeToStateChange(listener) { var _this = this; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { handlerIds: undefined }; var handlerIds = options.handlerIds; invariant(typeof listener === 'function', 'listener must be a function.'); invariant(typeof handlerIds === 'undefined' || Array.isArray(handlerIds), 'handlerIds, when specified, must be an array of strings.'); var prevStateId = this.store.getState().stateId; var handleChange = function handleChange() { var state = _this.store.getState(); var currentStateId = state.stateId; try { var canSkipListener = currentStateId === prevStateId || currentStateId === prevStateId + 1 && !areDirty(state.dirtyHandlerIds, handlerIds); if (!canSkipListener) { listener(); } } finally { prevStateId = currentStateId; } }; return this.store.subscribe(handleChange); } }, { key: "subscribeToOffsetChange", value: function subscribeToOffsetChange(listener) { var _this2 = this; invariant(typeof listener === 'function', 'listener must be a function.'); var previousState = this.store.getState().dragOffset; var handleChange = function handleChange() { var nextState = _this2.store.getState().dragOffset; if (nextState === previousState) { return; } previousState = nextState; listener(); }; return this.store.subscribe(handleChange); } }, { key: "canDragSource", value: function canDragSource(sourceId) { if (!sourceId) { return false; } var source = this.registry.getSource(sourceId); invariant(source, 'Expected to find a valid source.'); if (this.isDragging()) { return false; } return source.canDrag(this, sourceId); } }, { key: "canDropOnTarget", value: function canDropOnTarget(targetId) { // undefined on initial render if (!targetId) { return false; } var target = this.registry.getTarget(targetId); invariant(target, 'Expected to find a valid target.'); if (!this.isDragging() || this.didDrop()) { return false; } var targetType = this.registry.getTargetType(targetId); var draggedItemType = this.getItemType(); return matchesType(targetType, draggedItemType) && target.canDrop(this, targetId); } }, { key: "isDragging", value: function isDragging() { return Boolean(this.getItemType()); } }, { key: "isDraggingSource", value: function isDraggingSource(sourceId) { // undefined on initial render if (!sourceId) { return false; } var source = this.registry.getSource(sourceId, true); invariant(source, 'Expected to find a valid source.'); if (!this.isDragging() || !this.isSourcePublic()) { return false; } var sourceType = this.registry.getSourceType(sourceId); var draggedItemType = this.getItemType(); if (sourceType !== draggedItemType) { return false; } return source.isDragging(this, sourceId); } }, { key: "isOverTarget", value: function isOverTarget(targetId) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { shallow: false }; // undefined on initial render if (!targetId) { return false; } var shallow = options.shallow; if (!this.isDragging()) { return false; } var targetType = this.registry.getTargetType(targetId); var draggedItemType = this.getItemType(); if (draggedItemType && !matchesType(targetType, draggedItemType)) { return false; } var targetIds = this.getTargetIds(); if (!targetIds.length) { return false; } var index = targetIds.indexOf(targetId); if (shallow) { return index === targetIds.length - 1; } else { return index > -1; } } }, { key: "getItemType", value: function getItemType() { return this.store.getState().dragOperation.itemType; } }, { key: "getItem", value: function getItem() { return this.store.getState().dragOperation.item; } }, { key: "getSourceId", value: function getSourceId() { return this.store.getState().dragOperation.sourceId; } }, { key: "getTargetIds", value: function getTargetIds() { return this.store.getState().dragOperation.targetIds; } }, { key: "getDropResult", value: function getDropResult() { return this.store.getState().dragOperation.dropResult; } }, { key: "didDrop", value: function didDrop() { return this.store.getState().dragOperation.didDrop; } }, { key: "isSourcePublic", value: function isSourcePublic() { return Boolean(this.store.getState().dragOperation.isSourcePublic); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.store.getState().dragOffset.initialClientOffset; } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.store.getState().dragOffset.initialSourceClientOffset; } }, { key: "getClientOffset", value: function getClientOffset() { return this.store.getState().dragOffset.clientOffset; } }, { key: "getSourceClientOffset", value: function getSourceClientOffset$1() { return getSourceClientOffset(this.store.getState().dragOffset); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset$1() { return getDifferenceFromInitialOffset(this.store.getState().dragOffset); } }]); return DragDropMonitorImpl; }(); var nextUniqueId = 0; function getNextUniqueId() { return nextUniqueId++; } function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); } function validateSourceContract(source) { invariant(typeof source.canDrag === 'function', 'Expected canDrag to be a function.'); invariant(typeof source.beginDrag === 'function', 'Expected beginDrag to be a function.'); invariant(typeof source.endDrag === 'function', 'Expected endDrag to be a function.'); } function validateTargetContract(target) { invariant(typeof target.canDrop === 'function', 'Expected canDrop to be a function.'); invariant(typeof target.hover === 'function', 'Expected hover to be a function.'); invariant(typeof target.drop === 'function', 'Expected beginDrag to be a function.'); } function validateType(type, allowArray) { if (allowArray && Array.isArray(type)) { type.forEach(function (t) { return validateType(t, false); }); return; } invariant(typeof type === 'string' || _typeof$1(type) === 'symbol', allowArray ? 'Type can only be a string, a symbol, or an array of either.' : 'Type can only be a string or a symbol.'); } // Use the fastest means possible to execute a task in its own turn, with // priority over other events including IO, animation, reflow, and redraw // events in browsers. // // An exception thrown by a task will permanently interrupt the processing of // subsequent tasks. The higher level `asap` function ensures that if an // exception is thrown by a task, that the task queue will continue flushing as // soon as possible, but if you use `rawAsap` directly, you are responsible to // either ensure that no exceptions are thrown from your task, or to manually // call `rawAsap.requestFlush` if an exception is thrown. function rawAsap(task) { if (!queue.length) { requestFlush(); } // Equivalent to push, but avoids a function call. queue[queue.length] = task; } var queue = []; // Once a flush has been requested, no further calls to `requestFlush` are // off a `flush` event as quickly as possible. `flush` will attempt to exhaust // the event queue before yielding to the browser's own event loop. var requestFlush; // The position of the next task to execute in the task queue. This is // preserved between calls to `flush` so that it can be resumed if // a task throws an exception. var index = 0; // If a task schedules additional tasks recursively, the task queue can grow // unbounded. To prevent memory exhaustion, the task queue will periodically // truncate already-completed tasks. var capacity = 1024; // The flush function processes all tasks that have been scheduled with // `rawAsap` unless and until one of those tasks throws an exception. // If a task throws an exception, `flush` ensures that its state will remain // consistent and will resume where it left off when called again. // However, `flush` does not make any arrangements to be called again if an // exception is thrown. function flush() { while (index < queue.length) { var currentIndex = index; // Advance the index before calling the task. This ensures that we will // begin flushing on the next task the task throws an error. index = index + 1; queue[currentIndex].call(); // Prevent leaking memory for long chains of recursive calls to `asap`. // If we call `asap` within tasks scheduled by `asap`, the queue will // grow, but to avoid an O(n) walk for every task we execute, we don't // shift tasks off the queue after they have been executed. // Instead, we periodically shift 1024 tasks off the queue. if (index > capacity) { // Manually shift all values starting at the index back to the // beginning of the queue. for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { queue[scan] = queue[scan + index]; } queue.length -= index; index = 0; } } queue.length = 0; index = 0; } // `requestFlush` is implemented using a strategy based on data collected from // every available SauceLabs Selenium web driver worker at time of writing. // https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593 // Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that // have WebKitMutationObserver but not un-prefixed MutationObserver. // Must use `global` or `self` instead of `window` to work in both frames and web // workers. `global` is a provision of Browserify, Mr, Mrs, or Mop. /* globals self */ var scope = typeof global !== 'undefined' ? global : self; var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; // MutationObservers are desirable because they have high priority and work // reliably everywhere they are implemented. // They are implemented in all modern browsers. // // - Android 4-4.3 // - Chrome 26-34 // - Firefox 14-29 // - Internet Explorer 11 // - iPad Safari 6-7.1 // - iPhone Safari 7-7.1 // - Safari 6-7 if (typeof BrowserMutationObserver === 'function') { requestFlush = makeRequestCallFromMutationObserver(flush); // MessageChannels are desirable because they give direct access to the HTML // task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera // 11-12, and in web workers in many engines. // Although message channels yield to any queued rendering and IO tasks, they // would be better than imposing the 4ms delay of timers. // However, they do not work reliably in Internet Explorer or Safari. // Internet Explorer 10 is the only browser that has setImmediate but does // not have MutationObservers. // Although setImmediate yields to the browser's renderer, it would be // preferrable to falling back to setTimeout since it does not have // the minimum 4ms penalty. // Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and // Desktop to a lesser extent) that renders both setImmediate and // MessageChannel useless for the purposes of ASAP. // https://github.com/kriskowal/q/issues/396 // Timers are implemented universally. // We fall back to timers in workers in most engines, and in foreground // contexts in the following browsers. // However, note that even this simple case requires nuances to operate in a // broad spectrum of browsers. // // - Firefox 3-13 // - Internet Explorer 6-9 // - iPad Safari 4.3 // - Lynx 2.8.7 } else { requestFlush = makeRequestCallFromTimer(flush); } // `requestFlush` requests that the high priority event queue be flushed as // soon as possible. // This is useful to prevent an error thrown in a task from stalling the event // queue if the exception handled by Node.js’s // `process.on("uncaughtException")` or by a domain. rawAsap.requestFlush = requestFlush; // To request a high priority event, we induce a mutation observer by toggling // the text of a text node between "1" and "-1". function makeRequestCallFromMutationObserver(callback) { var toggle = 1; var observer = new BrowserMutationObserver(callback); var node = document.createTextNode(''); observer.observe(node, { characterData: true }); return function requestCall() { toggle = -toggle; node.data = toggle; }; } // The message channel technique was discovered by Malte Ubl and was the // original foundation for this library. // http://www.nonblocking.io/2011/06/windownexttick.html // Safari 6.0.5 (at least) intermittently fails to create message ports on a // page's first load. Thankfully, this version of Safari supports // MutationObservers, so we don't need to fall back in that case. // function makeRequestCallFromMessageChannel(callback) { // var channel = new MessageChannel(); // channel.port1.onmessage = callback; // return function requestCall() { // channel.port2.postMessage(0); // }; // } // For reasons explained above, we are also unable to use `setImmediate` // under any circumstances. // Even if we were, there is another bug in Internet Explorer 10. // It is not sufficient to assign `setImmediate` to `requestFlush` because // `setImmediate` must be called *by name* and therefore must be wrapped in a // closure. // Never forget. // function makeRequestCallFromSetImmediate(callback) { // return function requestCall() { // setImmediate(callback); // }; // } // Safari 6.0 has a problem where timers will get lost while the user is // scrolling. This problem does not impact ASAP because Safari 6.0 supports // mutation observers, so that implementation is used instead. // However, if we ever elect to use timers in Safari, the prevalent work-around // is to add a scroll event listener that calls for a flush. // `setTimeout` does not call the passed callback if the delay is less than // approximately 7 in web workers in Firefox 8 through 18, and sometimes not // even then. function makeRequestCallFromTimer(callback) { return function requestCall() { // We dispatch a timeout with a specified delay of 0 for engines that // can reliably accommodate that request. This will usually be snapped // to a 4 milisecond delay, but once we're flushing, there's no delay // between events. var timeoutHandle = setTimeout(handleTimer, 0); // However, since this timer gets frequently dropped in Firefox // workers, we enlist an interval handle that will try to fire // an event 20 times per second until it succeeds. var intervalHandle = setInterval(handleTimer, 50); function handleTimer() { // Whichever timer succeeds will cancel both timers and // execute the callback. clearTimeout(timeoutHandle); clearInterval(intervalHandle); callback(); } }; } // This is for `asap.js` only. // Its name will be periodically randomized to break any code that depends on // its existence. rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; // ASAP was originally a nextTick shim included in Q. This was factored out // into this ASAP package. It was later adapted to RSVP which made further // amendments. These decisions, particularly to marginalize MessageChannel and // to capture the MutationObserver implementation in a closure, were integrated // back into ASAP proper. // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js // RawTasks are recycled to reduce GC churn. var freeTasks = []; // We queue errors to ensure they are thrown in right order (FIFO). // Array-as-queue is good enough here, since we are just dealing with exceptions. var pendingErrors = []; var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); function throwFirstError() { if (pendingErrors.length) { throw pendingErrors.shift(); } } /** * Calls a task as soon as possible after returning, in its own event, with priority * over other events like animation, reflow, and repaint. An error thrown from an * event will not interrupt, nor even substantially slow down the processing of * other events, but will be rather postponed to a lower priority event. * @param {{call}} task A callable object, typically a function that takes no * arguments. */ function asap(task) { var rawTask; if (freeTasks.length) { rawTask = freeTasks.pop(); } else { rawTask = new RawTask(); } rawTask.task = task; rawAsap(rawTask); } // We wrap tasks with recyclable task objects. A task object implements // `call`, just like a function. var RawTask = /** @class */ function () { function RawTask() {} RawTask.prototype.call = function () { try { this.task.call(); } catch (error) { if (asap.onerror) { // This hook exists purely for testing purposes. // Its name will be periodically randomized to break any code that // depends on its existence. asap.onerror(error); } else { // In a web browser, exceptions are not fatal. However, to avoid // slowing down the queue of pending tasks, we rethrow the error in a // lower priority turn. pendingErrors.push(error); requestErrorThrow(); } } finally { this.task = null; freeTasks[freeTasks.length] = this; } }; return RawTask; }(); function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function getNextHandlerId(role) { var id = getNextUniqueId().toString(); switch (role) { case HandlerRole.SOURCE: return "S".concat(id); case HandlerRole.TARGET: return "T".concat(id); default: throw new Error("Unknown Handler Role: ".concat(role)); } } function parseRoleFromHandlerId(handlerId) { switch (handlerId[0]) { case 'S': return HandlerRole.SOURCE; case 'T': return HandlerRole.TARGET; default: invariant(false, "Cannot parse handler ID: ".concat(handlerId)); } } function mapContainsValue(map, searchValue) { var entries = map.entries(); var isDone = false; do { var _entries$next = entries.next(), done = _entries$next.done, _entries$next$value = _slicedToArray(_entries$next.value, 2), value = _entries$next$value[1]; if (value === searchValue) { return true; } isDone = !!done; } while (!isDone); return false; } var HandlerRegistryImpl = /*#__PURE__*/function () { function HandlerRegistryImpl(store) { _classCallCheck$1(this, HandlerRegistryImpl); this.types = new Map(); this.dragSources = new Map(); this.dropTargets = new Map(); this.pinnedSourceId = null; this.pinnedSource = null; this.store = store; } _createClass$1(HandlerRegistryImpl, [{ key: "addSource", value: function addSource$1(type, source) { validateType(type); validateSourceContract(source); var sourceId = this.addHandler(HandlerRole.SOURCE, type, source); this.store.dispatch(addSource(sourceId)); return sourceId; } }, { key: "addTarget", value: function addTarget$1(type, target) { validateType(type, true); validateTargetContract(target); var targetId = this.addHandler(HandlerRole.TARGET, type, target); this.store.dispatch(addTarget(targetId)); return targetId; } }, { key: "containsHandler", value: function containsHandler(handler) { return mapContainsValue(this.dragSources, handler) || mapContainsValue(this.dropTargets, handler); } }, { key: "getSource", value: function getSource(sourceId) { var includePinned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; invariant(this.isSourceId(sourceId), 'Expected a valid source ID.'); var isPinned = includePinned && sourceId === this.pinnedSourceId; var source = isPinned ? this.pinnedSource : this.dragSources.get(sourceId); return source; } }, { key: "getTarget", value: function getTarget(targetId) { invariant(this.isTargetId(targetId), 'Expected a valid target ID.'); return this.dropTargets.get(targetId); } }, { key: "getSourceType", value: function getSourceType(sourceId) { invariant(this.isSourceId(sourceId), 'Expected a valid source ID.'); return this.types.get(sourceId); } }, { key: "getTargetType", value: function getTargetType(targetId) { invariant(this.isTargetId(targetId), 'Expected a valid target ID.'); return this.types.get(targetId); } }, { key: "isSourceId", value: function isSourceId(handlerId) { var role = parseRoleFromHandlerId(handlerId); return role === HandlerRole.SOURCE; } }, { key: "isTargetId", value: function isTargetId(handlerId) { var role = parseRoleFromHandlerId(handlerId); return role === HandlerRole.TARGET; } }, { key: "removeSource", value: function removeSource$1(sourceId) { var _this = this; invariant(this.getSource(sourceId), 'Expected an existing source.'); this.store.dispatch(removeSource(sourceId)); asap(function () { _this.dragSources.delete(sourceId); _this.types.delete(sourceId); }); } }, { key: "removeTarget", value: function removeTarget$1(targetId) { invariant(this.getTarget(targetId), 'Expected an existing target.'); this.store.dispatch(removeTarget(targetId)); this.dropTargets.delete(targetId); this.types.delete(targetId); } }, { key: "pinSource", value: function pinSource(sourceId) { var source = this.getSource(sourceId); invariant(source, 'Expected an existing source.'); this.pinnedSourceId = sourceId; this.pinnedSource = source; } }, { key: "unpinSource", value: function unpinSource() { invariant(this.pinnedSource, 'No source is pinned at the time.'); this.pinnedSourceId = null; this.pinnedSource = null; } }, { key: "addHandler", value: function addHandler(role, type, handler) { var id = getNextHandlerId(role); this.types.set(id, type); if (role === HandlerRole.SOURCE) { this.dragSources.set(id, handler); } else if (role === HandlerRole.TARGET) { this.dropTargets.set(id, handler); } return id; } }]); return HandlerRegistryImpl; }(); function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; } function makeStoreInstance(debugMode) { // TODO: if we ever make a react-native version of this, // we'll need to consider how to pull off dev-tooling var reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__; return createStore(reduce$5, debugMode && reduxDevTools && reduxDevTools({ name: 'dnd-core', instanceId: 'dnd-core' })); } var DragDropManagerImpl = /*#__PURE__*/function () { function DragDropManagerImpl() { var _this = this; var debugMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; _classCallCheck$2(this, DragDropManagerImpl); this.isSetUp = false; this.handleRefCountChange = function () { var shouldSetUp = _this.store.getState().refCount > 0; if (_this.backend) { if (shouldSetUp && !_this.isSetUp) { _this.backend.setup(); _this.isSetUp = true; } else if (!shouldSetUp && _this.isSetUp) { _this.backend.teardown(); _this.isSetUp = false; } } }; var store = makeStoreInstance(debugMode); this.store = store; this.monitor = new DragDropMonitorImpl(store, new HandlerRegistryImpl(store)); store.subscribe(this.handleRefCountChange); } _createClass$2(DragDropManagerImpl, [{ key: "receiveBackend", value: function receiveBackend(backend) { this.backend = backend; } }, { key: "getMonitor", value: function getMonitor() { return this.monitor; } }, { key: "getBackend", value: function getBackend() { return this.backend; } }, { key: "getRegistry", value: function getRegistry() { return this.monitor.registry; } }, { key: "getActions", value: function getActions() { /* eslint-disable-next-line @typescript-eslint/no-this-alias */ var manager = this; var dispatch = this.store.dispatch; function bindActionCreator(actionCreator) { return function () { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } var action = actionCreator.apply(manager, args); if (typeof action !== 'undefined') { dispatch(action); } }; } var actions = createDragDropActions(this); return Object.keys(actions).reduce(function (boundActions, key) { var action = actions[key]; boundActions[key] = bindActionCreator(action); return boundActions; }, {}); } }, { key: "dispatch", value: function dispatch(action) { this.store.dispatch(action); } }]); return DragDropManagerImpl; }(); function createDragDropManager(backendFactory, globalContext, backendOptions, debugMode) { var manager = new DragDropManagerImpl(debugMode); var backend = backendFactory(manager, globalContext, backendOptions); manager.receiveBackend(backend); return manager; } /** * Create the React Context */ var DndContext = React.createContext({ dragDropManager: undefined }); /** * Creates the context object we're providing * @param backend * @param context */ function createDndContext(backend, context, options, debugMode) { return { dragDropManager: createDragDropManager(backend, context, options, debugMode) }; } function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); } function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); } function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$1(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; } 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; } var refCount = 0; /** * A React component that provides the React-DnD context */ var DndProvider = React.memo(function (_ref) { var children = _ref.children, props = _objectWithoutProperties(_ref, ["children"]); var _getDndContextValue = getDndContextValue(props), _getDndContextValue2 = _slicedToArray$1(_getDndContextValue, 2), manager = _getDndContextValue2[0], isGlobalInstance = _getDndContextValue2[1]; // 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 */ React.useEffect(function () { if (isGlobalInstance) { refCount++; } return function () { if (isGlobalInstance) { refCount--; if (refCount === 0) { var context = getGlobalContext(); context[instanceSymbol] = null; } } }; }, []); return React.createElement(DndContext.Provider, { value: manager }, children); }); DndProvider.displayName = 'DndProvider'; function getDndContextValue(props) { if ('manager' in props) { var _manager = { dragDropManager: props.manager }; return [_manager, false]; } var manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode); var isGlobalInstance = !props.context; return [manager, isGlobalInstance]; } var instanceSymbol = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__'); function createSingletonDndContext(backend) { var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getGlobalContext(); var options = arguments.length > 2 ? arguments[2] : undefined; var debugMode = arguments.length > 3 ? arguments[3] : undefined; var ctx = context; if (!ctx[instanceSymbol]) { ctx[instanceSymbol] = createDndContext(backend, context, options, debugMode); } return ctx[instanceSymbol]; } function getGlobalContext() { return typeof global !== 'undefined' ? global : window; } /* * A utility for rendering a drag preview image */ var DragPreviewImage = React.memo(function (_ref) { var connect = _ref.connect, src = _ref.src; React.useEffect(function () { if (typeof Image === 'undefined') return; var connected = false; var img = new Image(); img.src = src; img.onload = function () { connect(img); connected = true; }; return function () { if (connected) { connect(null); } }; }); return null; }); DragPreviewImage.displayName = 'DragPreviewImage'; var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; function shallowEqual(objA, objB, compare, compareContext) { var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0; if (compareResult !== void 0) { return !!compareResult; } if (objA === objB) { return true; } if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) { return false; } var keysA = Object.keys(objA); var keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B. for (var idx = 0; idx < keysA.length; idx++) { var key = keysA[idx]; if (!bHasOwnProperty(key)) { return false; } var valueA = objA[key]; var valueB = objB[key]; compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0; if (compareResult === false || compareResult === void 0 && valueA !== valueB) { return false; } } return true; } function _slicedToArray$2(arr, i) { return _arrayWithHoles$2(arr) || _iterableToArrayLimit$2(arr, i) || _unsupportedIterableToArray$2(arr, i) || _nonIterableRest$2(); } function _nonIterableRest$2() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); } function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$2(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$2(arr) { if (Array.isArray(arr)) return arr; } /** * * @param monitor The monitor to collect state from * @param collect The collecting function * @param onUpdate A method to invoke when updates occur */ function useCollector(monitor, collect, onUpdate) { var _useState = React.useState(function () { return collect(monitor); }), _useState2 = _slicedToArray$2(_useState, 2), collected = _useState2[0], setCollected = _useState2[1]; var updateCollected = React.useCallback(function () { var nextValue = collect(monitor); if (!shallowEqual(collected, nextValue)) { setCollected(nextValue); if (onUpdate) { onUpdate(); } } }, [collected, monitor, onUpdate]); // update the collected properties after the first render // and the components are attached to dnd-core useIsomorphicLayoutEffect(updateCollected, []); return [collected, updateCollected]; } function _slicedToArray$3(arr, i) { return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$3(); } function _nonIterableRest$3() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); } function _arrayLikeToArray$3(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$3(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$3(arr) { if (Array.isArray(arr)) return arr; } function useMonitorOutput(monitor, collect, onCollect) { var _useCollector = useCollector(monitor, collect, onCollect), _useCollector2 = _slicedToArray$3(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; useIsomorphicLayoutEffect(function subscribeToMonitorStateChange() { var handlerId = monitor.getHandlerId(); if (handlerId == null) { return undefined; } return monitor.subscribeToStateChange(updateCollected, { handlerIds: [handlerId] }); }, [monitor, updateCollected]); return collected; } function registerTarget(type, target, manager) { var registry = manager.getRegistry(); var targetId = registry.addTarget(type, target); return [targetId, function () { return registry.removeTarget(targetId); }]; } function registerSource(type, source, manager) { var registry = manager.getRegistry(); var sourceId = registry.addSource(type, source); return [sourceId, function () { return registry.removeSource(sourceId); }]; } /** * A hook to retrieve the DragDropManager from Context */ function useDragDropManager() { var _useContext = React.useContext(DndContext), dragDropManager = _useContext.dragDropManager; invariant(dragDropManager != null, 'Expected drag drop context'); return dragDropManager; } function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; } var isCallingCanDrag = false; var isCallingIsDragging = false; var DragSourceMonitorImpl = /*#__PURE__*/function () { function DragSourceMonitorImpl(manager) { _classCallCheck$3(this, DragSourceMonitorImpl); this.sourceId = null; this.internalMonitor = manager.getMonitor(); } _createClass$3(DragSourceMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(sourceId) { this.sourceId = sourceId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.sourceId; } }, { key: "canDrag", value: function 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; } } }, { key: "isDragging", value: function 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; } } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "isDraggingSource", value: function isDraggingSource(sourceId) { return this.internalMonitor.isDraggingSource(sourceId); } }, { key: "isOverTarget", value: function isOverTarget(targetId, options) { return this.internalMonitor.isOverTarget(targetId, options); } }, { key: "getTargetIds", value: function getTargetIds() { return this.internalMonitor.getTargetIds(); } }, { key: "isSourcePublic", value: function isSourcePublic() { return this.internalMonitor.isSourcePublic(); } }, { key: "getSourceId", value: function getSourceId() { return this.internalMonitor.getSourceId(); } }, { key: "subscribeToOffsetChange", value: function subscribeToOffsetChange(listener) { return this.internalMonitor.subscribeToOffsetChange(listener); } }, { key: "canDragSource", value: function canDragSource(sourceId) { return this.internalMonitor.canDragSource(sourceId); } }, { key: "canDropOnTarget", value: function canDropOnTarget(targetId) { return this.internalMonitor.canDropOnTarget(targetId); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DragSourceMonitorImpl; }(); function setRef(ref, node) { if (typeof ref === 'function') { ref(node); } else { ref.current = node; } } function cloneWithRef(element, newRef) { var 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://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute'); if (!previousRef) { // When there is no ref on the element, use the new ref directly return React.cloneElement(element, { ref: newRef }); } else { return React.cloneElement(element, { ref: function ref(node) { setRef(previousRef, node); setRef(newRef, node); } }); } } 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; } var 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 ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.'); } function wrapHookToRecognizeElement(hook) { return function () { var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; // When passed a node, call the hook straight away. if (!React.isValidElement(elementOrNode)) { var 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. var element = elementOrNode; throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly var ref = options ? function (node) { return hook(node, options); } : hook; return cloneWithRef(element, ref); }; } function wrapConnectorHooks(hooks) { var wrappedHooks = {}; Object.keys(hooks).forEach(function (key) { var hook = hooks[key]; // ref objects should be passed straight through without wrapping if (key.endsWith('Ref')) { wrappedHooks[key] = hooks[key]; } else { var wrappedHook = wrapHookToRecognizeElement(hook); wrappedHooks[key] = function () { return wrappedHook; }; } }); return wrappedHooks; } function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); } function isRef(obj) { return (// eslint-disable-next-line no-prototype-builtins obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current') ); } function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$4(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; } var SourceConnector = /*#__PURE__*/function () { function SourceConnector(backend) { var _this = this; _classCallCheck$4(this, SourceConnector); this.hooks = wrapConnectorHooks({ dragSource: function dragSource(node, options) { _this.clearDragSource(); _this.dragSourceOptions = options || null; if (isRef(node)) { _this.dragSourceRef = node; } else { _this.dragSourceNode = node; } _this.reconnectDragSource(); }, dragPreview: function 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; } _createClass$4(SourceConnector, [{ key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (this.handlerId === newHandlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "reconnect", value: function reconnect() { this.reconnectDragSource(); this.reconnectDragPreview(); } }, { key: "reconnectDragSource", value: function reconnectDragSource() { var dragSource = this.dragSource; // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange(); if (didChange) { this.disconnectDragSource(); } if (!this.handlerId) { return; } if (!dragSource) { this.lastConnectedDragSource = dragSource; return; } if (didChange) { this.lastConnectedHandlerId = this.handlerId; this.lastConnectedDragSource = dragSource; this.lastConnectedDragSourceOptions = this.dragSourceOptions; this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions); } } }, { key: "reconnectDragPreview", value: function reconnectDragPreview() { var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe var didChange = 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); } } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didConnectedDragSourceChange", value: function didConnectedDragSourceChange() { return this.lastConnectedDragSource !== this.dragSource; } }, { key: "didConnectedDragPreviewChange", value: function didConnectedDragPreviewChange() { return this.lastConnectedDragPreview !== this.dragPreview; } }, { key: "didDragSourceOptionsChange", value: function didDragSourceOptionsChange() { return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions); } }, { key: "didDragPreviewOptionsChange", value: function didDragPreviewOptionsChange() { return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions); } }, { key: "disconnectDragSource", value: function disconnectDragSource() { if (this.dragSourceUnsubscribe) { this.dragSourceUnsubscribe(); this.dragSourceUnsubscribe = undefined; } } }, { key: "disconnectDragPreview", value: function disconnectDragPreview() { if (this.dragPreviewUnsubscribe) { this.dragPreviewUnsubscribe(); this.dragPreviewUnsubscribe = undefined; this.dragPreviewNode = null; this.dragPreviewRef = null; } } }, { key: "clearDragSource", value: function clearDragSource() { this.dragSourceNode = null; this.dragSourceRef = null; } }, { key: "clearDragPreview", value: function clearDragPreview() { this.dragPreviewNode = null; this.dragPreviewRef = null; } }, { key: "connectTarget", get: function get() { return this.dragSource; } }, { key: "dragSourceOptions", get: function get() { return this.dragSourceOptionsInternal; }, set: function set(options) { this.dragSourceOptionsInternal = options; } }, { key: "dragPreviewOptions", get: function get() { return this.dragPreviewOptionsInternal; }, set: function set(options) { this.dragPreviewOptionsInternal = options; } }, { key: "dragSource", get: function get() { return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current; } }, { key: "dragPreview", get: function get() { return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current; } }]); return SourceConnector; }(); function _slicedToArray$4(arr, i) { return _arrayWithHoles$4(arr) || _iterableToArrayLimit$4(arr, i) || _unsupportedIterableToArray$4(arr, i) || _nonIterableRest$4(); } function _nonIterableRest$4() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$4(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$4(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$4(o, minLen); } function _arrayLikeToArray$4(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$4(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$4(arr) { if (Array.isArray(arr)) return arr; } function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); } function useDragSourceMonitor() { var manager = useDragDropManager(); var monitor = React.useMemo(function () { return new DragSourceMonitorImpl(manager); }, [manager]); var connector = React.useMemo(function () { return new SourceConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } function useDragHandler(spec, monitor, connector) { var manager = useDragDropManager(); var handler = React.useMemo(function () { return { beginDrag: function beginDrag() { var _spec$current = spec.current, begin = _spec$current.begin, item = _spec$current.item; if (begin) { var beginResult = begin(monitor); invariant(beginResult == null || _typeof$3(beginResult) === 'object', 'dragSpec.begin() must either return an object, undefined, or null'); return beginResult || item || {}; } return item || {}; }, canDrag: function canDrag() { if (typeof spec.current.canDrag === 'boolean') { return spec.current.canDrag; } else if (typeof spec.current.canDrag === 'function') { return spec.current.canDrag(monitor); } else { return true; } }, isDragging: function isDragging(globalMonitor, target) { var isDragging = spec.current.isDragging; return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId(); }, endDrag: function endDrag() { var end = spec.current.end; if (end) { end(monitor.getItem(), monitor); } connector.reconnect(); } }; }, []); useIsomorphicLayoutEffect(function registerHandler() { var _registerSource = registerSource(spec.current.item.type, handler, manager), _registerSource2 = _slicedToArray$4(_registerSource, 2), handlerId = _registerSource2[0], unregister = _registerSource2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, []); } function _slicedToArray$5(arr, i) { return _arrayWithHoles$5(arr) || _iterableToArrayLimit$5(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest$5(); } function _nonIterableRest$5() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$5(o, minLen); } function _arrayLikeToArray$5(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$5(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$5(arr) { if (Array.isArray(arr)) return arr; } /** * useDragSource hook * @param sourceSpec The drag source specification * */ function useDrag(spec) { var specRef = React.useRef(spec); specRef.current = spec; // TODO: wire options into createSourceConnector invariant(spec.item != null, 'item must be defined'); invariant(spec.item.type != null, 'item type must be defined'); var _useDragSourceMonitor = useDragSourceMonitor(), _useDragSourceMonitor2 = _slicedToArray$5(_useDragSourceMonitor, 2), monitor = _useDragSourceMonitor2[0], connector = _useDragSourceMonitor2[1]; useDragHandler(specRef, monitor, connector); var result = useMonitorOutput(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDragSource = React.useMemo(function () { return connector.hooks.dragSource(); }, [connector]); var connectDragPreview = React.useMemo(function () { return connector.hooks.dragPreview(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dragSourceOptions = specRef.current.options || null; connector.reconnect(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dragPreviewOptions = specRef.current.previewOptions || null; connector.reconnect(); }, [connector]); return [result, connectDragSource, connectDragPreview]; } function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$5(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; } var TargetConnector = /*#__PURE__*/function () { function TargetConnector(backend) { var _this = this; _classCallCheck$5(this, TargetConnector); this.hooks = wrapConnectorHooks({ dropTarget: function 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; } _createClass$5(TargetConnector, [{ key: "reconnect", value: function reconnect() { // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange(); if (didChange) { this.disconnectDropTarget(); } var 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); } } }, { key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (newHandlerId === this.handlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didDropTargetChange", value: function didDropTargetChange() { return this.lastConnectedDropTarget !== this.dropTarget; } }, { key: "didOptionsChange", value: function didOptionsChange() { return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions); } }, { key: "disconnectDropTarget", value: function disconnectDropTarget() { if (this.unsubscribeDropTarget) { this.unsubscribeDropTarget(); this.unsubscribeDropTarget = undefined; } } }, { key: "clearDropTarget", value: function clearDropTarget() { this.dropTargetRef = null; this.dropTargetNode = null; } }, { key: "connectTarget", get: function get() { return this.dropTarget; } }, { key: "dropTargetOptions", get: function get() { return this.dropTargetOptionsInternal; }, set: function set(options) { this.dropTargetOptionsInternal = options; } }, { key: "dropTarget", get: function get() { return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current; } }]); return TargetConnector; }(); function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$6(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; } var isCallingCanDrop = false; var DropTargetMonitorImpl = /*#__PURE__*/function () { function DropTargetMonitorImpl(manager) { _classCallCheck$6(this, DropTargetMonitorImpl); this.targetId = null; this.internalMonitor = manager.getMonitor(); } _createClass$6(DropTargetMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(targetId) { this.targetId = targetId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.targetId; } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "canDrop", value: function 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; } } }, { key: "isOver", value: function isOver(options) { if (!this.targetId) { return false; } return this.internalMonitor.isOverTarget(this.targetId, options); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DropTargetMonitorImpl; }(); function _slicedToArray$6(arr, i) { return _arrayWithHoles$6(arr) || _iterableToArrayLimit$6(arr, i) || _unsupportedIterableToArray$6(arr, i) || _nonIterableRest$6(); } function _nonIterableRest$6() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$6(o, minLen); } function _arrayLikeToArray$6(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$6(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$6(arr) { if (Array.isArray(arr)) return arr; } function useDropTargetMonitor() { var manager = useDragDropManager(); var monitor = React.useMemo(function () { return new DropTargetMonitorImpl(manager); }, [manager]); var connector = React.useMemo(function () { return new TargetConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } function useDropHandler(spec, monitor, connector) { var manager = useDragDropManager(); var handler = React.useMemo(function () { return { canDrop: function canDrop() { var canDrop = spec.current.canDrop; return canDrop ? canDrop(monitor.getItem(), monitor) : true; }, hover: function hover() { var hover = spec.current.hover; if (hover) { hover(monitor.getItem(), monitor); } }, drop: function drop() { var drop = spec.current.drop; if (drop) { return drop(monitor.getItem(), monitor); } } }; }, [monitor]); useIsomorphicLayoutEffect(function registerHandler() { var _registerTarget = registerTarget(spec.current.accept, handler, manager), _registerTarget2 = _slicedToArray$6(_registerTarget, 2), handlerId = _registerTarget2[0], unregister = _registerTarget2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, [monitor, connector]); } function _slicedToArray$7(arr, i) { return _arrayWithHoles$7(arr) || _iterableToArrayLimit$7(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest$7(); } function _nonIterableRest$7() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$7(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$7(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen); } function _arrayLikeToArray$7(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$7(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$7(arr) { if (Array.isArray(arr)) return arr; } /** * useDropTarget Hook * @param spec The drop target specification */ function useDrop(spec) { var specRef = React.useRef(spec); specRef.current = spec; invariant(spec.accept != null, 'accept must be defined'); var _useDropTargetMonitor = useDropTargetMonitor(), _useDropTargetMonitor2 = _slicedToArray$7(_useDropTargetMonitor, 2), monitor = _useDropTargetMonitor2[0], connector = _useDropTargetMonitor2[1]; useDropHandler(specRef, monitor, connector); var result = useMonitorOutput(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDropTarget = React.useMemo(function () { return connector.hooks.dropTarget(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dropTargetOptions = spec.options || null; connector.reconnect(); }, [spec.options]); return [result, connectDropTarget]; } function _slicedToArray$8(arr, i) { return _arrayWithHoles$8(arr) || _iterableToArrayLimit$8(arr, i) || _unsupportedIterableToArray$8(arr, i) || _nonIterableRest$8(); } function _nonIterableRest$8() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$8(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$8(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$8(o, minLen); } function _arrayLikeToArray$8(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$8(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$8(arr) { if (Array.isArray(arr)) return arr; } /** * useDragLayer Hook * @param collector The property collector */ function useDragLayer(collect) { var dragDropManager = useDragDropManager(); var monitor = dragDropManager.getMonitor(); var _useCollector = useCollector(monitor, collect), _useCollector2 = _slicedToArray$8(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; React.useEffect(function () { return monitor.subscribeToOffsetChange(updateCollected); }); React.useEffect(function () { return monitor.subscribeToStateChange(updateCollected); }); return collected; } function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); } // cheap lodash replacements function isFunction(input) { return typeof input === 'function'; } function noop() {// noop } function isObjectLike(input) { return _typeof$4(input) === 'object' && input !== null; } function isPlainObject$1(input) { if (!isObjectLike(input)) { return false; } if (Object.getPrototypeOf(input) === null) { return true; } var proto = input; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(input) === proto; } function getDecoratedComponent(instanceRef) { var currentRef = instanceRef.current; if (currentRef == null) { return null; } else if (currentRef.decoratedRef) { // go through the private field in decorateHandler to avoid the invariant hit return currentRef.decoratedRef.current; } else { return currentRef; } } function isClassComponent(Component) { return Component && Component.prototype && typeof Component.prototype.render === 'function'; } function isRefForwardingComponent(C) { var _item$$$typeof; var item = C; return (item === null || item === void 0 ? void 0 : (_item$$$typeof = item.$$typeof) === null || _item$$$typeof === void 0 ? void 0 : _item$$$typeof.toString()) === 'Symbol(react.forward_ref)'; } function isRefable(C) { return isClassComponent(C) || isRefForwardingComponent(C); } function checkDecoratorArguments(functionName, signature) { { for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) { var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2]; if (arg && arg.prototype && arg.prototype.render) { // eslint-disable-next-line no-console console.error('You seem to be applying the arguments in the wrong order. ' + "It should be ".concat(functionName, "(").concat(signature, ")(Component), not the other way around. ") + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order'); return; } } } } function createCommonjsModule(fn, basedir, module) { return module = { path: basedir, exports: {}, require: function (path, base) { return commonjsRequire(path, (base === undefined || base === null) ? module.path : base); } }, fn(module, module.exports), module.exports; } function commonjsRequire () { throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs'); } var reactIs_development = createCommonjsModule(function (module, exports) { { (function() { // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === 'function' && Symbol.for; var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary // (unstable) APIs that have been removed. Can we remove the symbols? var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf; var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9; var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; function isValidElementType(type) { return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); } function typeOf(object) { if (typeof object === 'object' && object !== null) { var $$typeof = object.$$typeof; switch ($$typeof) { case REACT_ELEMENT_TYPE: var type = object.type; switch (type) { case REACT_ASYNC_MODE_TYPE: case REACT_CONCURRENT_MODE_TYPE: case REACT_FRAGMENT_TYPE: case REACT_PROFILER_TYPE: case REACT_STRICT_MODE_TYPE: case REACT_SUSPENSE_TYPE: return type; default: var $$typeofType = type && type.$$typeof; switch ($$typeofType) { case REACT_CONTEXT_TYPE: case REACT_FORWARD_REF_TYPE: case REACT_LAZY_TYPE: case REACT_MEMO_TYPE: case REACT_PROVIDER_TYPE: return $$typeofType; default: return $$typeof; } } case REACT_PORTAL_TYPE: return $$typeof; } } return undefined; } // AsyncMode is deprecated along with isAsyncMode var AsyncMode = REACT_ASYNC_MODE_TYPE; var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; var ContextConsumer = REACT_CONTEXT_TYPE; var ContextProvider = REACT_PROVIDER_TYPE; var Element = REACT_ELEMENT_TYPE; var ForwardRef = REACT_FORWARD_REF_TYPE; var Fragment = REACT_FRAGMENT_TYPE; var Lazy = REACT_LAZY_TYPE; var Memo = REACT_MEMO_TYPE; var Portal = REACT_PORTAL_TYPE; var Profiler = REACT_PROFILER_TYPE; var StrictMode = REACT_STRICT_MODE_TYPE; var Suspense = REACT_SUSPENSE_TYPE; var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated function isAsyncMode(object) { { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); } } return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; } function isConcurrentMode(object) { return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; } function isContextConsumer(object) { return typeOf(object) === REACT_CONTEXT_TYPE; } function isContextProvider(object) { return typeOf(object) === REACT_PROVIDER_TYPE; } function isElement(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } function isForwardRef(object) { return typeOf(object) === REACT_FORWARD_REF_TYPE; } function isFragment(object) { return typeOf(object) === REACT_FRAGMENT_TYPE; } function isLazy(object) { return typeOf(object) === REACT_LAZY_TYPE; } function isMemo(object) { return typeOf(object) === REACT_MEMO_TYPE; } function isPortal(object) { return typeOf(object) === REACT_PORTAL_TYPE; } function isProfiler(object) { return typeOf(object) === REACT_PROFILER_TYPE; } function isStrictMode(object) { return typeOf(object) === REACT_STRICT_MODE_TYPE; } function isSuspense(object) { return typeOf(object) === REACT_SUSPENSE_TYPE; } exports.AsyncMode = AsyncMode; exports.ConcurrentMode = ConcurrentMode; exports.ContextConsumer = ContextConsumer; exports.ContextProvider = ContextProvider; exports.Element = Element; exports.ForwardRef = ForwardRef; exports.Fragment = Fragment; exports.Lazy = Lazy; exports.Memo = Memo; exports.Portal = Portal; exports.Profiler = Profiler; exports.StrictMode = StrictMode; exports.Suspense = Suspense; exports.isAsyncMode = isAsyncMode; exports.isConcurrentMode = isConcurrentMode; exports.isContextConsumer = isContextConsumer; exports.isContextProvider = isContextProvider; exports.isElement = isElement; exports.isForwardRef = isForwardRef; exports.isFragment = isFragment; exports.isLazy = isLazy; exports.isMemo = isMemo; exports.isPortal = isPortal; exports.isProfiler = isProfiler; exports.isStrictMode = isStrictMode; exports.isSuspense = isSuspense; exports.isValidElementType = isValidElementType; exports.typeOf = typeOf; })(); } }); var reactIs_development_1 = reactIs_development.AsyncMode; var reactIs_development_2 = reactIs_development.ConcurrentMode; var reactIs_development_3 = reactIs_development.ContextConsumer; var reactIs_development_4 = reactIs_development.ContextProvider; var reactIs_development_5 = reactIs_development.Element; var reactIs_development_6 = reactIs_development.ForwardRef; var reactIs_development_7 = reactIs_development.Fragment; var reactIs_development_8 = reactIs_development.Lazy; var reactIs_development_9 = reactIs_development.Memo; var reactIs_development_10 = reactIs_development.Portal; var reactIs_development_11 = reactIs_development.Profiler; var reactIs_development_12 = reactIs_development.StrictMode; var reactIs_development_13 = reactIs_development.Suspense; var reactIs_development_14 = reactIs_development.isAsyncMode; var reactIs_development_15 = reactIs_development.isConcurrentMode; var reactIs_development_16 = reactIs_development.isContextConsumer; var reactIs_development_17 = reactIs_development.isContextProvider; var reactIs_development_18 = reactIs_development.isElement; var reactIs_development_19 = reactIs_development.isForwardRef; var reactIs_development_20 = reactIs_development.isFragment; var reactIs_development_21 = reactIs_development.isLazy; var reactIs_development_22 = reactIs_development.isMemo; var reactIs_development_23 = reactIs_development.isPortal; var reactIs_development_24 = reactIs_development.isProfiler; var reactIs_development_25 = reactIs_development.isStrictMode; var reactIs_development_26 = reactIs_development.isSuspense; var reactIs_development_27 = reactIs_development.isValidElementType; var reactIs_development_28 = reactIs_development.typeOf; var reactIs = createCommonjsModule(function (module) { { module.exports = reactIs_development; } }); /** * Copyright 2015, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ var REACT_STATICS = { childContextTypes: true, contextType: true, contextTypes: true, defaultProps: true, displayName: true, getDefaultProps: true, getDerivedStateFromError: true, getDerivedStateFromProps: true, mixins: true, propTypes: true, type: true }; var KNOWN_STATICS = { name: true, length: true, prototype: true, caller: true, callee: true, arguments: true, arity: true }; var FORWARD_REF_STATICS = { '$$typeof': true, render: true, defaultProps: true, displayName: true, propTypes: true }; var MEMO_STATICS = { '$$typeof': true, compare: true, defaultProps: true, displayName: true, propTypes: true, type: true }; var TYPE_STATICS = {}; TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS; TYPE_STATICS[reactIs.Memo] = MEMO_STATICS; function getStatics(component) { // React v16.11 and below if (reactIs.isMemo(component)) { return MEMO_STATICS; } // React v16.12 and above return TYPE_STATICS[component['$$typeof']] || REACT_STATICS; } var defineProperty = Object.defineProperty; var getOwnPropertyNames = Object.getOwnPropertyNames; var getOwnPropertySymbols = Object.getOwnPropertySymbols; var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var getPrototypeOf = Object.getPrototypeOf; var objectPrototype = Object.prototype; function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) { if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components if (objectPrototype) { var inheritedComponent = getPrototypeOf(sourceComponent); if (inheritedComponent && inheritedComponent !== objectPrototype) { hoistNonReactStatics(targetComponent, inheritedComponent, blacklist); } } var keys = getOwnPropertyNames(sourceComponent); if (getOwnPropertySymbols) { keys = keys.concat(getOwnPropertySymbols(sourceComponent)); } var targetStatics = getStatics(targetComponent); var sourceStatics = getStatics(sourceComponent); for (var i = 0; i < keys.length; ++i) { var key = keys[i]; if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) { var descriptor = getOwnPropertyDescriptor(sourceComponent, key); try { // Avoid failures from read-only properties defineProperty(targetComponent, key, descriptor); } catch (e) {} } } } return targetComponent; } var hoistNonReactStatics_cjs = hoistNonReactStatics; function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$7(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; } /** * Provides a set of static methods for creating Disposables. * @param {Function} action Action to run during the first call to dispose. * The action is guaranteed to be run at most once. */ var Disposable = /** @class */ function () { var Disposable = /*#__PURE__*/function () { function Disposable(action) { _classCallCheck$7(this, Disposable); this.isDisposed = false; this.action = isFunction(action) ? action : noop; } /** * Validates whether the given object is a disposable * @param {Object} Object to test whether it has a dispose method * @returns {Boolean} true if a disposable object, else false. */ _createClass$7(Disposable, [{ key: "dispose", /** Performs the task of cleaning up resources. */ value: function dispose() { if (!this.isDisposed) { this.action(); this.isDisposed = true; } } }], [{ key: "isDisposable", value: function isDisposable(d) { return Boolean(d && isFunction(d.dispose)); } }, { key: "_fixup", value: function _fixup(result) { return Disposable.isDisposable(result) ? result : Disposable.empty; } /** * Creates a disposable object that invokes the specified action when disposed. * @param {Function} dispose Action to run during the first call to dispose. * The action is guaranteed to be run at most once. * @return {Disposable} The disposable object that runs the given action upon disposal. */ }, { key: "create", value: function create(action) { return new Disposable(action); } }]); return Disposable; }(); /** * Gets the disposable that does nothing when disposed. */ Disposable.empty = { dispose: noop }; return Disposable; }(); /** * Represents a group of disposable resources that are disposed together. * @constructor */ var CompositeDisposable = /*#__PURE__*/function () { function CompositeDisposable() { _classCallCheck$7(this, CompositeDisposable); this.isDisposed = false; for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) { disposables[_key] = arguments[_key]; } this.disposables = disposables; } /** * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. * @param {Any} item Disposable to add. */ _createClass$7(CompositeDisposable, [{ key: "add", value: function add(item) { if (this.isDisposed) { item.dispose(); } else { this.disposables.push(item); } } /** * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. * @param {Any} item Disposable to remove. * @returns {Boolean} true if found; false otherwise. */ }, { key: "remove", value: function remove(item) { var shouldDispose = false; if (!this.isDisposed) { var idx = this.disposables.indexOf(item); if (idx !== -1) { shouldDispose = true; this.disposables.splice(idx, 1); item.dispose(); } } return shouldDispose; } /** * Disposes all disposables in the group and removes them from the group but * does not dispose the CompositeDisposable. */ }, { key: "clear", value: function clear() { if (!this.isDisposed) { var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i = 0; _i < len; _i++) { currentDisposables[_i].dispose(); } } } /** * Disposes all disposables in the group and removes them from the group. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i2 = 0; _i2 < len; _i2++) { currentDisposables[_i2].dispose(); } } } }]); return CompositeDisposable; }(); /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ var SerialDisposable = /*#__PURE__*/function () { function SerialDisposable() { _classCallCheck$7(this, SerialDisposable); this.isDisposed = false; } /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ _createClass$7(SerialDisposable, [{ key: "getDisposable", value: function getDisposable() { return this.current; } }, { key: "setDisposable", value: function setDisposable(value) { var shouldDispose = this.isDisposed; if (!shouldDispose) { var old = this.current; this.current = value; if (old) { old.dispose(); } } if (shouldDispose && value) { value.dispose(); } } /** Performs the task of cleaning up resources. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var old = this.current; this.current = undefined; if (old) { old.dispose(); } } } }]); return SerialDisposable; }(); function _typeof$5(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$5 = function _typeof(obj) { return typeof obj; }; } else { _typeof$5 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$5(obj); } function _slicedToArray$9(arr, i) { return _arrayWithHoles$9(arr) || _iterableToArrayLimit$9(arr, i) || _unsupportedIterableToArray$9(arr, i) || _nonIterableRest$9(); } function _nonIterableRest$9() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray$9(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$9(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$9(o, minLen); } function _arrayLikeToArray$9(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit$9(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles$9(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck$8(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$8(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$8(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$8(Constructor.prototype, protoProps); if (staticProps) _defineProperties$8(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof$5(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function decorateHandler(_ref) { var DecoratedComponent = _ref.DecoratedComponent, createHandler = _ref.createHandler, createMonitor = _ref.createMonitor, createConnector = _ref.createConnector, registerHandler = _ref.registerHandler, containerDisplayName = _ref.containerDisplayName, getType = _ref.getType, collect = _ref.collect, options = _ref.options; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua; var Decorated = DecoratedComponent; var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component'; var DragDropContainer = /** @class */ function () { var DragDropContainer = /*#__PURE__*/function (_React$Component) { _inherits(DragDropContainer, _React$Component); var _super = _createSuper(DragDropContainer); function DragDropContainer(props) { var _this; _classCallCheck$8(this, DragDropContainer); _this = _super.call(this, props); _this.decoratedRef = React.createRef(); _this.handleChange = function () { var nextState = _this.getCurrentState(); if (!shallowEqual(nextState, _this.state)) { _this.setState(nextState); } }; _this.disposable = new SerialDisposable(); _this.receiveProps(props); _this.dispose(); return _this; } _createClass$8(DragDropContainer, [{ key: "getHandlerId", value: function getHandlerId() { return this.handlerId; } }, { key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.decoratedRef.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.disposable = new SerialDisposable(); this.currentType = undefined; this.receiveProps(this.props); this.handleChange(); } }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { if (!arePropsEqual(this.props, prevProps)) { this.receiveProps(this.props); this.handleChange(); } } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.dispose(); } }, { key: "receiveProps", value: function receiveProps(props) { if (!this.handler) { return; } this.handler.receiveProps(props); this.receiveType(getType(props)); } }, { key: "receiveType", value: function receiveType(type) { if (!this.handlerMonitor || !this.manager || !this.handlerConnector) { return; } if (type === this.currentType) { return; } this.currentType = type; var _registerHandler = registerHandler(type, this.handler, this.manager), _registerHandler2 = _slicedToArray$9(_registerHandler, 2), handlerId = _registerHandler2[0], unregister = _registerHandler2[1]; this.handlerId = handlerId; this.handlerMonitor.receiveHandlerId(handlerId); this.handlerConnector.receiveHandlerId(handlerId); var globalMonitor = this.manager.getMonitor(); var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, { handlerIds: [handlerId] }); this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister))); } }, { key: "dispose", value: function dispose() { this.disposable.dispose(); if (this.handlerConnector) { this.handlerConnector.receiveHandlerId(null); } } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.handlerConnector) { return {}; } var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props); { invariant(isPlainObject$1(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState); } return nextState; } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(DndContext.Consumer, null, function (_ref2) { var dragDropManager = _ref2.dragDropManager; _this2.receiveDragDropManager(dragDropManager); if (typeof requestAnimationFrame !== 'undefined') { requestAnimationFrame(function () { var _this2$handlerConnect; return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect(); }); } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), { // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. ref: isRefable(Decorated) ? _this2.decoratedRef : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } invariant(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); if (dragDropManager === undefined) { return; } this.manager = dragDropManager; this.handlerMonitor = createMonitor(dragDropManager); this.handlerConnector = createConnector(dragDropManager.getBackend()); this.handler = createHandler(this.handlerMonitor, this.decoratedRef); } }]); return DragDropContainer; }(React.Component); DragDropContainer.DecoratedComponent = DecoratedComponent; DragDropContainer.displayName = "".concat(containerDisplayName, "(").concat(displayName, ")"); return DragDropContainer; }(); return hoistNonReactStatics_cjs(DragDropContainer, DecoratedComponent); } function _typeof$6(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$6 = function _typeof(obj) { return typeof obj; }; } else { _typeof$6 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$6(obj); } function isValidType(type, allowArray) { return typeof type === 'string' || _typeof$6(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) { return isValidType(t, false); }); } function _classCallCheck$9(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$9(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$9(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$9(Constructor.prototype, protoProps); if (staticProps) _defineProperties$9(Constructor, staticProps); return Constructor; } var ALLOWED_SPEC_METHODS = ['canDrag', 'beginDrag', 'isDragging', 'endDrag']; var REQUIRED_SPEC_METHODS = ['beginDrag']; var SourceImpl = /*#__PURE__*/function () { function SourceImpl(spec, monitor, ref) { var _this = this; _classCallCheck$9(this, SourceImpl); this.props = null; this.beginDrag = function () { if (!_this.props) { return; } var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current); { invariant(isPlainObject$1(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item); } return item; }; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass$9(SourceImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "canDrag", value: function canDrag() { if (!this.props) { return false; } if (!this.spec.canDrag) { return true; } return this.spec.canDrag(this.props, this.monitor); } }, { key: "isDragging", value: function isDragging(globalMonitor, sourceId) { if (!this.props) { return false; } if (!this.spec.isDragging) { return sourceId === globalMonitor.getSourceId(); } return this.spec.isDragging(this.props, this.monitor); } }, { key: "endDrag", value: function endDrag() { if (!this.props) { return; } if (!this.spec.endDrag) { return; } this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref)); } }]); return SourceImpl; }(); function createSourceFactory(spec) { Object.keys(spec).forEach(function (key) { invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); REQUIRED_SPEC_METHODS.forEach(function (key) { invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); return function createSource(monitor, ref) { return new SourceImpl(spec, monitor, ref); }; } /** * Decorates a component as a dragsource * @param type The dragsource type * @param spec The drag source specification * @param collect The props collector function * @param options DnD options */ function DragSource(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { invariant(isValidType(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type); getType = function getType() { return type; }; } invariant(isPlainObject$1(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec); var createSource = createSourceFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); invariant(isPlainObject$1(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); return function decorateSource(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DragSource', createHandler: createSource, registerHandler: registerSource, createConnector: function createConnector(backend) { return new SourceConnector(backend); }, createMonitor: function createMonitor(manager) { return new DragSourceMonitorImpl(manager); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; } function _classCallCheck$a(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$a(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$a(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$a(Constructor.prototype, protoProps); if (staticProps) _defineProperties$a(Constructor, staticProps); return Constructor; } var ALLOWED_SPEC_METHODS$1 = ['canDrop', 'hover', 'drop']; var TargetImpl = /*#__PURE__*/function () { function TargetImpl(spec, monitor, ref) { _classCallCheck$a(this, TargetImpl); this.props = null; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass$a(TargetImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "receiveMonitor", value: function receiveMonitor(monitor) { this.monitor = monitor; } }, { key: "canDrop", value: function canDrop() { if (!this.spec.canDrop) { return true; } return this.spec.canDrop(this.props, this.monitor); } }, { key: "hover", value: function hover() { if (!this.spec.hover || !this.props) { return; } this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref)); } }, { key: "drop", value: function drop() { if (!this.spec.drop) { return undefined; } var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current); { invariant(typeof dropResult === 'undefined' || isPlainObject$1(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult); } return dropResult; } }]); return TargetImpl; }(); function createTargetFactory(spec) { Object.keys(spec).forEach(function (key) { invariant(ALLOWED_SPEC_METHODS$1.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS$1.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]); }); return function createTarget(monitor, ref) { return new TargetImpl(spec, monitor, ref); }; } function DropTarget(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { invariant(isValidType(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type); getType = function getType() { return type; }; } invariant(isPlainObject$1(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec); var createTarget = createTargetFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); invariant(isPlainObject$1(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); return function decorateTarget(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DropTarget', createHandler: createTarget, registerHandler: registerTarget, createMonitor: function createMonitor(manager) { return new DropTargetMonitorImpl(manager); }, createConnector: function createConnector(backend) { return new TargetConnector(backend); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; } function _typeof$7(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$7 = function _typeof(obj) { return typeof obj; }; } else { _typeof$7 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$7(obj); } function _classCallCheck$b(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$b(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$b(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$b(Constructor.prototype, protoProps); if (staticProps) _defineProperties$b(Constructor, staticProps); return Constructor; } function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); } function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); } function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf$1(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$1(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$1(this, result); }; } function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$7(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); } function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); } function DragLayer(collect) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; checkDecoratorArguments('DragLayer', 'collect[, options]', collect, options); invariant(typeof collect === 'function', 'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ', 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', collect); invariant(isPlainObject$1(options), 'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. ' + 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', options); return function decorateLayer(DecoratedComponent) { var Decorated = DecoratedComponent; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua; var displayName = Decorated.displayName || Decorated.name || 'Component'; var DragLayerContainer = /** @class */ function () { var DragLayerContainer = /*#__PURE__*/function (_React$Component) { _inherits$1(DragLayerContainer, _React$Component); var _super = _createSuper$1(DragLayerContainer); function DragLayerContainer() { var _this; _classCallCheck$b(this, DragLayerContainer); _this = _super.apply(this, arguments); _this.isCurrentlyMounted = false; _this.ref = React.createRef(); _this.handleChange = function () { if (!_this.isCurrentlyMounted) { return; } var nextState = _this.getCurrentState(); if (!shallowEqual(nextState, _this.state)) { _this.setState(nextState); } }; return _this; } _createClass$b(DragLayerContainer, [{ key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.ref.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.isCurrentlyMounted = true; this.handleChange(); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.isCurrentlyMounted = false; if (this.unsubscribeFromOffsetChange) { this.unsubscribeFromOffsetChange(); this.unsubscribeFromOffsetChange = undefined; } if (this.unsubscribeFromStateChange) { this.unsubscribeFromStateChange(); this.unsubscribeFromStateChange = undefined; } } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(DndContext.Consumer, null, function (_ref) { var dragDropManager = _ref.dragDropManager; if (dragDropManager === undefined) { return null; } _this2.receiveDragDropManager(dragDropManager); // Let componentDidMount fire to initialize the collected state if (!_this2.isCurrentlyMounted) { return null; } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.state, { ref: isRefable(Decorated) ? _this2.ref : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } this.manager = dragDropManager; invariant(_typeof$7(dragDropManager) === 'object', 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); var monitor = this.manager.getMonitor(); this.unsubscribeFromOffsetChange = monitor.subscribeToOffsetChange(this.handleChange); this.unsubscribeFromStateChange = monitor.subscribeToStateChange(this.handleChange); } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.manager) { return {}; } var monitor = this.manager.getMonitor(); return collect(monitor, this.props); } }]); return DragLayerContainer; }(React.Component); DragLayerContainer.displayName = "DragLayer(".concat(displayName, ")"); DragLayerContainer.DecoratedComponent = DecoratedComponent; return DragLayerContainer; }(); return hoistNonReactStatics_cjs(DragLayerContainer, DecoratedComponent); }; } exports.DndContext = DndContext; exports.DndProvider = DndProvider; exports.DragLayer = DragLayer; exports.DragPreviewImage = DragPreviewImage; exports.DragSource = DragSource; exports.DropTarget = DropTarget; exports.createDndContext = createDndContext; exports.useDrag = useDrag; exports.useDragDropManager = useDragDropManager; exports.useDragLayer = useDragLayer; exports.useDrop = useDrop; Object.defineProperty(exports, '__esModule', { value: true }); }))); dist/umd/ReactDnD.min.js000064400000216406151676724530011071 0ustar00!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactDnD={},e.React)}(this,(function(e,t){"use strict";var r;!function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"}(r||(r={}));var n=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),o=function(){return Math.random().toString(36).substring(7).split("").join(".")},i={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function a(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function u(e,t,r){var o;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(u)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var c=e,s=t,f=[],l=f,d=!1;function p(){l===f&&(l=f.slice())}function h(){if(d)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}function g(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(d)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribelistener for more details.");var t=!0;return p(),l.push(e),function(){if(t){if(d)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribelistener for more details.");t=!1,p();var r=l.indexOf(e);l.splice(r,1),f=null}}}function y(e){if(!a(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(d)throw new Error("Reducers may not dispatch actions.");try{d=!0,s=c(s,e)}finally{d=!1}for(var t=f=l,r=0;r<t.length;r++){(0,t[r])()}return e}function v(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");c=e,y({type:i.REPLACE})}function b(){var e,t=g;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function r(){e.next&&e.next(h())}return r(),{unsubscribe:t(r)}}})[n]=function(){return this},e}return y({type:i.INIT}),(o={dispatch:y,subscribe:g,getState:h,replaceReducer:v})[n]=b,o}function c(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];if(!e){var i;if(void 0===t)i=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=0;(i=new Error(t.replace(/%s/g,(function(){return n[a++]})))).name="Invariant Violation"}throw i.framesToPop=1,i}}var s="dnd-core/INIT_COORDS",f="dnd-core/BEGIN_DRAG",l="dnd-core/PUBLISH_DRAG_SOURCE",d="dnd-core/HOVER",p="dnd-core/DROP",h="dnd-core/END_DRAG";function g(e,t){return{type:s,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(e,t,r){return t.split(".").reduce((function(e,t){return e&&e[t]?e[t]:r||null}),e)}function b(e,t){return e.filter((function(e){return e!==t}))}function m(e){return"object"===y(e)}function O(e,t){var r=new Map,n=function(e){r.set(e,r.has(e)?r.get(e)+1:1)};e.forEach(n),t.forEach(n);var o=[];return r.forEach((function(e,t){1===e&&o.push(t)})),o}var S={type:s,payload:{clientOffset:null,sourceClientOffset:null}};function w(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},n=r.publishSource,o=void 0===n||n,i=r.clientOffset,a=r.getSourceClientOffset,u=e.getMonitor(),c=e.getRegistry();e.dispatch(g(i)),D(t,u,c);var s=k(t,u);if(null!==s){var l=null;if(i){if(!a)throw new Error("getSourceClientOffset must be defined");I(a),l=a(s)}e.dispatch(g(i,l));var d=c.getSource(s),p=d.beginDrag(u,s);C(p),c.pinSource(s);var h=c.getSourceType(s);return{type:f,payload:{itemType:h,item:p,sourceId:s,clientOffset:i||null,sourceClientOffset:l||null,isSourcePublic:!!o}}}e.dispatch(S)}}function D(e,t,r){c(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach((function(e){c(r.getSource(e),"Expected sourceIds to be registered.")}))}function I(e){c("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}function C(e){c(m(e),"Item must be an object.")}function k(e,t){for(var r=null,n=e.length-1;n>=0;n--)if(t.canDragSource(e[n])){r=e[n];break}return r}function T(e){return function(){if(e.getMonitor().isDragging())return{type:l}}}function P(e,t){return null===t?null===e:Array.isArray(e)?e.some((function(e){return e===t})):e===t}function j(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.clientOffset;E(t);var o=t.slice(0),i=e.getMonitor(),a=e.getRegistry();R(o,i,a);var u=i.getItemType();return x(o,a,u),M(o,i,a),{type:d,payload:{targetIds:o,clientOffset:n||null}}}}function E(e){c(Array.isArray(e),"Expected targetIds to be an array.")}function R(e,t,r){c(t.isDragging(),"Cannot call hover while not dragging."),c(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n<e.length;n++){var o=e[n];c(e.lastIndexOf(o)===n,"Expected targetIds to be unique in the passed array."),c(r.getTarget(o),"Expected targetIds to be registered.")}}function x(e,t,r){for(var n=e.length-1;n>=0;n--){var o=e[n];P(t.getTargetType(o),r)||e.splice(n,1)}}function M(e,t,r){e.forEach((function(e){r.getTarget(e).hover(t,e)}))}function A(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?A(Object(r),!0).forEach((function(t){N(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function N(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function H(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.getMonitor(),n=e.getRegistry();U(r);var o=F(r);o.forEach((function(o,i){var a=$(o,i,n,r),u={type:p,payload:{dropResult:_(_({},t),a)}};e.dispatch(u)}))}}function U(e){c(e.isDragging(),"Cannot call drop while not dragging."),c(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function $(e,t,r,n){var o=r.getTarget(e),i=o?o.drop(n,e):void 0;return function(e){c(void 0===e||m(e),"Drop result must either be an object or undefined.")}(i),void 0===i&&(i=0===t?{}:n.getDropResult()),i}function F(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function L(e){return function(){var t=e.getMonitor(),r=e.getRegistry();!function(e){c(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);var n=t.getSourceId();null!=n&&(r.getSource(n,!0).endDrag(t,n),r.unpinSource());return{type:h}}}var B=function(e,t){return e===t};function G(e,t){return!e&&!t||!(!e||!t)&&(e.x===t.x&&e.y===t.y)}function q(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:B;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!r(e[n],t[n]))return!1;return!0}function V(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function W(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach((function(t){Y(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):V(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var z={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function K(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:z,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case s:case f:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case d:return G(e.clientOffset,r.clientOffset)?e:W(W({},e),{},{clientOffset:r.clientOffset});case h:case p:return z;default:return e}}var X="dnd-core/ADD_SOURCE",J="dnd-core/ADD_TARGET",Q="dnd-core/REMOVE_SOURCE",Z="dnd-core/REMOVE_TARGET";function ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function te(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(r),!0).forEach((function(t){re(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ee(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function re(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ne={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function oe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ne,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case f:return te(te({},e),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case l:return te(te({},e),{},{isSourcePublic:!0});case d:return te(te({},e),{},{targetIds:r.targetIds});case Z:return-1===e.targetIds.indexOf(r.targetId)?e:te(te({},e),{},{targetIds:b(e.targetIds,r.targetId)});case p:return te(te({},e),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case h:return te(te({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function ie(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case X:case J:return e+1;case Q:case Z:return e-1;default:return e}}var ae=[],ue=[];function ce(e,t){return e!==ae&&(e===ue||void 0===t||(r=e,t.filter((function(e){return r.indexOf(e)>-1}))).length>0);var r}function se(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case d:break;case X:case J:case Z:case Q:return ae;case f:case l:case h:case p:default:return ue}var t=e.payload,r=t.targetIds,n=void 0===r?[]:r,o=t.prevTargetIds,i=void 0===o?[]:o,a=O(n,i),u=a.length>0||!q(n,i);if(!u)return ae;var c=i[i.length-1],s=n[n.length-1];return c!==s&&(c&&a.push(c),s&&a.push(s)),a}function fe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e+1}function le(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function de(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?le(Object(r),!0).forEach((function(t){pe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):le(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function pe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function he(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:se(e.dirtyHandlerIds,{type:t.type,payload:de(de({},t.payload),{},{prevTargetIds:v(e,"dragOperation.targetIds",[])})}),dragOffset:K(e.dragOffset,t),refCount:ie(e.refCount,t),dragOperation:oe(e.dragOperation,t),stateId:fe(e.stateId)}}function ge(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ye(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}ae.__IS_NONE__=!0,ue.__IS_ALL__=!0;var ve=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.store=t,this.registry=r}var t,r,n;return t=e,(r=[{key:"subscribeToStateChange",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0},n=r.handlerIds;c("function"==typeof e,"listener must be a function."),c(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");var o=this.store.getState().stateId,i=function(){var r=t.store.getState(),i=r.stateId;try{i===o||i===o+1&&!ce(r.dirtyHandlerIds,n)||e()}finally{o=i}};return this.store.subscribe(i)}},{key:"subscribeToOffsetChange",value:function(e){var t=this;c("function"==typeof e,"listener must be a function.");var r=this.store.getState().dragOffset;return this.store.subscribe((function(){var n=t.store.getState().dragOffset;n!==r&&(r=n,e())}))}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return c(t,"Expected to find a valid source."),!this.isDragging()&&t.canDrag(this,e)}},{key:"canDropOnTarget",value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return c(t,"Expected to find a valid target."),!(!this.isDragging()||this.didDrop())&&P(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:"isDragging",value:function(){return Boolean(this.getItemType())}},{key:"isDraggingSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return c(t,"Expected to find a valid source."),!(!this.isDragging()||!this.isSourcePublic())&&this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}},{key:"isOverTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shallow:!1};if(!e)return!1;var r=t.shallow;if(!this.isDragging())return!1;var n=this.registry.getTargetType(e),o=this.getItemType();if(o&&!P(n,o))return!1;var i=this.getTargetIds();if(!i.length)return!1;var a=i.indexOf(e);return r?a===i.length-1:a>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return Boolean(this.store.getState().dragOperation.isSourcePublic)}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return e=this.store.getState().dragOffset,t=e.clientOffset,r=e.initialClientOffset,n=e.initialSourceClientOffset,t&&r&&n?ge(function(e,t){return{x:e.x+t.x,y:e.y+t.y}}(t,n),r):null;var e,t,r,n}},{key:"getDifferenceFromInitialOffset",value:function(){return e=this.store.getState().dragOffset,t=e.clientOffset,r=e.initialClientOffset,t&&r?ge(t,r):null;var e,t,r}}])&&ye(t.prototype,r),n&&ye(t,n),e}(),be=0;function me(e){return(me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Oe(e,t){t&&Array.isArray(e)?e.forEach((function(e){return Oe(e,!1)})):c("string"==typeof e||"symbol"===me(e),t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}function Se(e){De.length||we(),De[De.length]=e}var we,De=[],Ie=0;function Ce(){for(;Ie<De.length;){var e=Ie;if(Ie+=1,De[e].call(),Ie>1024){for(var t=0,r=De.length-Ie;t<r;t++)De[t]=De[t+Ie];De.length-=Ie,Ie=0}}De.length=0,Ie=0}var ke,Te,Pe,je="undefined"!=typeof global?global:self,Ee=je.MutationObserver||je.WebKitMutationObserver;function Re(e){return function(){var t=setTimeout(n,0),r=setInterval(n,50);function n(){clearTimeout(t),clearInterval(r),e()}}}"function"==typeof Ee?(ke=1,Te=new Ee(Ce),Pe=document.createTextNode(""),Te.observe(Pe,{characterData:!0}),we=function(){ke=-ke,Pe.data=ke}):we=Re(Ce),Se.requestFlush=we,Se.makeRequestCallFromTimer=Re;var xe=[],Me=[],Ae=Se.makeRequestCallFromTimer((function(){if(Me.length)throw Me.shift()}));function _e(e){var t;(t=xe.length?xe.pop():new Ne).task=e,Se(t)}var Ne=function(){function e(){}return e.prototype.call=function(){try{this.task.call()}catch(e){_e.onerror?_e.onerror(e):(Me.push(e),Ae())}finally{this.task=null,xe[xe.length]=this}},e}();function He(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Ue(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return $e(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $e(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Fe(e){var t=(be++).toString();switch(e){case r.SOURCE:return"S".concat(t);case r.TARGET:return"T".concat(t);default:throw new Error("Unknown Handler Role: ".concat(e))}}function Le(e){switch(e[0]){case"S":return r.SOURCE;case"T":return r.TARGET;default:c(!1,"Cannot parse handler ID: ".concat(e))}}function Be(e,t){var r=e.entries(),n=!1;do{var o=r.next(),i=o.done;if(Ue(o.value,2)[1]===t)return!0;n=!!i}while(!n);return!1}var Ge=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=t}var t,n,o;return t=e,(n=[{key:"addSource",value:function(e,t){Oe(e),function(e){c("function"==typeof e.canDrag,"Expected canDrag to be a function."),c("function"==typeof e.beginDrag,"Expected beginDrag to be a function."),c("function"==typeof e.endDrag,"Expected endDrag to be a function.")}(t);var n=this.addHandler(r.SOURCE,e,t);return this.store.dispatch(function(e){return{type:X,payload:{sourceId:e}}}(n)),n}},{key:"addTarget",value:function(e,t){Oe(e,!0),function(e){c("function"==typeof e.canDrop,"Expected canDrop to be a function."),c("function"==typeof e.hover,"Expected hover to be a function."),c("function"==typeof e.drop,"Expected beginDrag to be a function.")}(t);var n=this.addHandler(r.TARGET,e,t);return this.store.dispatch(function(e){return{type:J,payload:{targetId:e}}}(n)),n}},{key:"containsHandler",value:function(e){return Be(this.dragSources,e)||Be(this.dropTargets,e)}},{key:"getSource",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];c(this.isSourceId(e),"Expected a valid source ID.");var r=t&&e===this.pinnedSourceId,n=r?this.pinnedSource:this.dragSources.get(e);return n}},{key:"getTarget",value:function(e){return c(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return c(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return c(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return Le(e)===r.SOURCE}},{key:"isTargetId",value:function(e){return Le(e)===r.TARGET}},{key:"removeSource",value:function(e){var t=this;c(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:Q,payload:{sourceId:e}}}(e)),_e((function(){t.dragSources.delete(e),t.types.delete(e)}))}},{key:"removeTarget",value:function(e){c(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:Z,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);c(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){c(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,n){var o=Fe(e);return this.types.set(o,t),e===r.SOURCE?this.dragSources.set(o,n):e===r.TARGET&&this.dropTargets.set(o,n),o}}])&&He(t.prototype,n),o&&He(t,o),e}();function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ve(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function We(e){var t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return u(he,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}var Ye=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];qe(this,e),this.isSetUp=!1,this.handleRefCountChange=function(){var e=t.store.getState().refCount>0;t.backend&&(e&&!t.isSetUp?(t.backend.setup(),t.isSetUp=!0):!e&&t.isSetUp&&(t.backend.teardown(),t.isSetUp=!1))};var n=We(r);this.store=n,this.monitor=new ve(n,new Ge(n)),n.subscribe(this.handleRefCountChange)}var t,r,n;return t=e,(r=[{key:"receiveBackend",value:function(e){this.backend=e}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var e=this,t=this.store.dispatch,r=function(e){return{beginDrag:w(e),publishDragSource:T(e),hover:j(e),drop:H(e),endDrag:L(e)}}(this);return Object.keys(r).reduce((function(n,o){var i,a=r[o];return n[o]=(i=a,function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var a=i.apply(e,n);void 0!==a&&t(a)}),n}),{})}},{key:"dispatch",value:function(e){this.store.dispatch(e)}}])&&Ve(t.prototype,r),n&&Ve(t,n),e}();function ze(e,t,r,n){var o=new Ye(n),i=e(o,t,r);return o.receiveBackend(i),o}var Ke=t.createContext({dragDropManager:void 0});function Xe(e,t,r,n){return{dragDropManager:ze(e,t,r,n)}}function Je(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Qe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Qe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ze(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var et=0,tt=t.memo((function(e){var r=e.children,n=Je(function(e){if("manager"in e){return[{dragDropManager:e.manager},!1]}var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nt(),r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=t;o[rt]||(o[rt]=Xe(e,t,r,n));return o[rt]}(e.backend,e.context,e.options,e.debugMode),r=!e.context;return[t,r]}(Ze(e,["children"])),2),o=n[0],i=n[1];return t.useEffect((function(){return i&&et++,function(){i&&(0===--et&&(nt()[rt]=null))}}),[]),t.createElement(Ke.Provider,{value:o},r)}));tt.displayName="DndProvider";var rt=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");function nt(){return"undefined"!=typeof global?global:window}var ot=t.memo((function(e){var r=e.connect,n=e.src;return t.useEffect((function(){if("undefined"!=typeof Image){var e=!1,t=new Image;return t.src=n,t.onload=function(){r(t),e=!0},function(){e&&r(null)}}})),null}));ot.displayName="DragPreviewImage";var it="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function at(e,t,r,n){var o=r?r.call(n,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(var u=Object.prototype.hasOwnProperty.bind(t),c=0;c<i.length;c++){var s=i[c];if(!u(s))return!1;var f=e[s],l=t[s];if(!1===(o=r?r.call(n,f,l,s):void 0)||void 0===o&&f!==l)return!1}return!0}function ut(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return ct(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ct(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ct(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function st(e,r,n){var o=ut(t.useState((function(){return r(e)})),2),i=o[0],a=o[1],u=t.useCallback((function(){var t=r(e);at(i,t)||(a(t),n&&n())}),[i,e,n]);return it(u,[]),[i,u]}function ft(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return lt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return lt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function dt(e,t,r){var n=ft(st(e,t,r),2),o=n[0],i=n[1];return it((function(){var t=e.getHandlerId();if(null!=t)return e.subscribeToStateChange(i,{handlerIds:[t]})}),[e,i]),o}function pt(e,t,r){var n=r.getRegistry(),o=n.addTarget(e,t);return[o,function(){return n.removeTarget(o)}]}function ht(e,t,r){var n=r.getRegistry(),o=n.addSource(e,t);return[o,function(){return n.removeSource(o)}]}function gt(){var e=t.useContext(Ke).dragDropManager;return c(null!=e,"Expected drag drop context"),e}function yt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var vt=!1,bt=!1,mt=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.sourceId=null,this.internalMonitor=t.getMonitor()}var t,r,n;return t=e,(r=[{key:"receiveHandlerId",value:function(e){this.sourceId=e}},{key:"getHandlerId",value:function(){return this.sourceId}},{key:"canDrag",value:function(){c(!vt,"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{return vt=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{vt=!1}}},{key:"isDragging",value:function(){if(!this.sourceId)return!1;c(!bt,"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{return bt=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{bt=!1}}},{key:"subscribeToStateChange",value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:"isDraggingSource",value:function(e){return this.internalMonitor.isDraggingSource(e)}},{key:"isOverTarget",value:function(e,t){return this.internalMonitor.isOverTarget(e,t)}},{key:"getTargetIds",value:function(){return this.internalMonitor.getTargetIds()}},{key:"isSourcePublic",value:function(){return this.internalMonitor.isSourcePublic()}},{key:"getSourceId",value:function(){return this.internalMonitor.getSourceId()}},{key:"subscribeToOffsetChange",value:function(e){return this.internalMonitor.subscribeToOffsetChange(e)}},{key:"canDragSource",value:function(e){return this.internalMonitor.canDragSource(e)}},{key:"canDropOnTarget",value:function(e){return this.internalMonitor.canDropOnTarget(e)}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}])&&yt(t.prototype,r),n&&yt(t,n),e}();function Ot(e,t){"function"==typeof e?e(t):e.current=t}function St(e,r){var n=e.ref;return c("string"!=typeof n,"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://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute"),n?t.cloneElement(e,{ref:function(e){Ot(n,e),Ot(r,e)}}):t.cloneElement(e,{ref:r})}function wt(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw new Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a <div>, or turn it into a ")+"drag source or a drop target itself.")}}function Dt(e){var r={};return Object.keys(e).forEach((function(n){var o=e[n];if(n.endsWith("Ref"))r[n]=e[n];else{var i=function(e){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t.isValidElement(r)){var o=r;return e(o,n),o}var i=r;wt(i);var a=n?function(t){return e(t,n)}:e;return St(i,a)}}(o);r[n]=function(){return i}}})),r}function It(e){return(It="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ct(e){return null!==e&&"object"===It(e)&&Object.prototype.hasOwnProperty.call(e,"current")}function kt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Tt=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hooks=Dt({dragSource:function(e,t){r.clearDragSource(),r.dragSourceOptions=t||null,Ct(e)?r.dragSourceRef=e:r.dragSourceNode=e,r.reconnectDragSource()},dragPreview:function(e,t){r.clearDragPreview(),r.dragPreviewOptions=t||null,Ct(e)?r.dragPreviewRef=e:r.dragPreviewNode=e,r.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=t}var t,r,n;return t=e,(r=[{key:"receiveHandlerId",value:function(e){this.handlerId!==e&&(this.handlerId=e,this.reconnect())}},{key:"reconnect",value:function(){this.reconnectDragSource(),this.reconnectDragPreview()}},{key:"reconnectDragSource",value:function(){var e=this.dragSource,t=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();t&&this.disconnectDragSource(),this.handlerId&&(e?t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=e,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,e,this.dragSourceOptions)):this.lastConnectedDragSource=e)}},{key:"reconnectDragPreview",value:function(){var e=this.dragPreview,t=this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();t&&this.disconnectDragPreview(),this.handlerId&&(e?t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=e,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,e,this.dragPreviewOptions)):this.lastConnectedDragPreview=e)}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didConnectedDragSourceChange",value:function(){return this.lastConnectedDragSource!==this.dragSource}},{key:"didConnectedDragPreviewChange",value:function(){return this.lastConnectedDragPreview!==this.dragPreview}},{key:"didDragSourceOptionsChange",value:function(){return!at(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}},{key:"didDragPreviewOptionsChange",value:function(){return!at(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}},{key:"disconnectDragSource",value:function(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}},{key:"disconnectDragPreview",value:function(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}},{key:"clearDragSource",value:function(){this.dragSourceNode=null,this.dragSourceRef=null}},{key:"clearDragPreview",value:function(){this.dragPreviewNode=null,this.dragPreviewRef=null}},{key:"connectTarget",get:function(){return this.dragSource}},{key:"dragSourceOptions",get:function(){return this.dragSourceOptionsInternal},set:function(e){this.dragSourceOptionsInternal=e}},{key:"dragPreviewOptions",get:function(){return this.dragPreviewOptionsInternal},set:function(e){this.dragPreviewOptionsInternal=e}},{key:"dragSource",get:function(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}},{key:"dragPreview",get:function(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}}])&&kt(t.prototype,r),n&&kt(t,n),e}();function Pt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return jt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Et(e){return(Et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Rt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return xt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Mt(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var At=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hooks=Dt({dropTarget:function(e,t){r.clearDropTarget(),r.dropTargetOptions=t,Ct(e)?r.dropTargetRef=e:r.dropTargetNode=e,r.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=t}var t,r,n;return t=e,(r=[{key:"reconnect",value:function(){var e=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();e&&this.disconnectDropTarget();var t=this.dropTarget;this.handlerId&&(t?e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=t,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,t,this.dropTargetOptions)):this.lastConnectedDropTarget=t)}},{key:"receiveHandlerId",value:function(e){e!==this.handlerId&&(this.handlerId=e,this.reconnect())}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didDropTargetChange",value:function(){return this.lastConnectedDropTarget!==this.dropTarget}},{key:"didOptionsChange",value:function(){return!at(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}},{key:"disconnectDropTarget",value:function(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}},{key:"clearDropTarget",value:function(){this.dropTargetRef=null,this.dropTargetNode=null}},{key:"connectTarget",get:function(){return this.dropTarget}},{key:"dropTargetOptions",get:function(){return this.dropTargetOptionsInternal},set:function(e){this.dropTargetOptionsInternal=e}},{key:"dropTarget",get:function(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}}])&&Mt(t.prototype,r),n&&Mt(t,n),e}();function _t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Nt=!1,Ht=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.targetId=null,this.internalMonitor=t.getMonitor()}var t,r,n;return t=e,(r=[{key:"receiveHandlerId",value:function(e){this.targetId=e}},{key:"getHandlerId",value:function(){return this.targetId}},{key:"subscribeToStateChange",value:function(e,t){return this.internalMonitor.subscribeToStateChange(e,t)}},{key:"canDrop",value:function(){if(!this.targetId)return!1;c(!Nt,"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{return Nt=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{Nt=!1}}},{key:"isOver",value:function(e){return!!this.targetId&&this.internalMonitor.isOverTarget(this.targetId,e)}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}])&&_t(t.prototype,r),n&&_t(t,n),e}();function Ut(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return $t(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $t(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Ft(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Lt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Lt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Bt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Gt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Gt(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function qt(e){return(qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Vt(e){return"function"==typeof e}function Wt(){}function Yt(e){if(!function(e){return"object"===qt(e)&&null!==e}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function zt(e){var t=e.current;return null==t?null:t.decoratedRef?t.decoratedRef.current:t}function Kt(e){return(t=e)&&t.prototype&&"function"==typeof t.prototype.render||function(e){var t,r=e;return"Symbol(react.forward_ref)"===(null==r||null===(t=r.$$typeof)||void 0===t?void 0:t.toString())}(e);var t}function Xt(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")} /** @license React v16.13.1 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */(null==t&&r.path)}},r.exports),r.exports}var Jt="function"==typeof Symbol&&Symbol.for,Qt=Jt?Symbol.for("react.element"):60103,Zt=Jt?Symbol.for("react.portal"):60106,er=Jt?Symbol.for("react.fragment"):60107,tr=Jt?Symbol.for("react.strict_mode"):60108,rr=Jt?Symbol.for("react.profiler"):60114,nr=Jt?Symbol.for("react.provider"):60109,or=Jt?Symbol.for("react.context"):60110,ir=Jt?Symbol.for("react.async_mode"):60111,ar=Jt?Symbol.for("react.concurrent_mode"):60111,ur=Jt?Symbol.for("react.forward_ref"):60112,cr=Jt?Symbol.for("react.suspense"):60113,sr=Jt?Symbol.for("react.suspense_list"):60120,fr=Jt?Symbol.for("react.memo"):60115,lr=Jt?Symbol.for("react.lazy"):60116,dr=Jt?Symbol.for("react.block"):60121,pr=Jt?Symbol.for("react.fundamental"):60117,hr=Jt?Symbol.for("react.responder"):60118,gr=Jt?Symbol.for("react.scope"):60119;function yr(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case Qt:switch(e=e.type){case ir:case ar:case er:case rr:case tr:case cr:return e;default:switch(e=e&&e.$$typeof){case or:case ur:case lr:case fr:case nr:return e;default:return t}}case Zt:return t}}}function vr(e){return yr(e)===ar}var br={AsyncMode:ir,ConcurrentMode:ar,ContextConsumer:or,ContextProvider:nr,Element:Qt,ForwardRef:ur,Fragment:er,Lazy:lr,Memo:fr,Portal:Zt,Profiler:rr,StrictMode:tr,Suspense:cr,isAsyncMode:function(e){return vr(e)||yr(e)===ir},isConcurrentMode:vr,isContextConsumer:function(e){return yr(e)===or},isContextProvider:function(e){return yr(e)===nr},isElement:function(e){return"object"==typeof e&&null!==e&&e.$$typeof===Qt},isForwardRef:function(e){return yr(e)===ur},isFragment:function(e){return yr(e)===er},isLazy:function(e){return yr(e)===lr},isMemo:function(e){return yr(e)===fr},isPortal:function(e){return yr(e)===Zt},isProfiler:function(e){return yr(e)===rr},isStrictMode:function(e){return yr(e)===tr},isSuspense:function(e){return yr(e)===cr},isValidElementType:function(e){return"string"==typeof e||"function"==typeof e||e===er||e===ar||e===rr||e===tr||e===cr||e===sr||"object"==typeof e&&null!==e&&(e.$$typeof===lr||e.$$typeof===fr||e.$$typeof===nr||e.$$typeof===or||e.$$typeof===ur||e.$$typeof===pr||e.$$typeof===hr||e.$$typeof===gr||e.$$typeof===dr)},typeOf:yr},mr=Xt((function(e,t){})),Or=(mr.AsyncMode,mr.ConcurrentMode,mr.ContextConsumer,mr.ContextProvider,mr.Element,mr.ForwardRef,mr.Fragment,mr.Lazy,mr.Memo,mr.Portal,mr.Profiler,mr.StrictMode,mr.Suspense,mr.isAsyncMode,mr.isConcurrentMode,mr.isContextConsumer,mr.isContextProvider,mr.isElement,mr.isForwardRef,mr.isFragment,mr.isLazy,mr.isMemo,mr.isPortal,mr.isProfiler,mr.isStrictMode,mr.isSuspense,mr.isValidElementType,mr.typeOf,Xt((function(e){e.exports=br}))),Sr={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},wr={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Dr={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Ir={};function Cr(e){return Or.isMemo(e)?Dr:Ir[e.$$typeof]||Sr}Ir[Or.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},Ir[Or.Memo]=Dr;var kr=Object.defineProperty,Tr=Object.getOwnPropertyNames,Pr=Object.getOwnPropertySymbols,jr=Object.getOwnPropertyDescriptor,Er=Object.getPrototypeOf,Rr=Object.prototype;var xr=function e(t,r,n){if("string"!=typeof r){if(Rr){var o=Er(r);o&&o!==Rr&&e(t,o,n)}var i=Tr(r);Pr&&(i=i.concat(Pr(r)));for(var a=Cr(t),u=Cr(r),c=0;c<i.length;++c){var s=i[c];if(!(wr[s]||n&&n[s]||u&&u[s]||a&&a[s])){var f=jr(r,s);try{kr(t,s,f)}catch(e){}}}}return t};function Mr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ar(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _r(e,t,r){return t&&Ar(e.prototype,t),r&&Ar(e,r),e}var Nr=function(){var e=function(){function e(t){Mr(this,e),this.isDisposed=!1,this.action=Vt(t)?t:Wt}return _r(e,[{key:"dispose",value:function(){this.isDisposed||(this.action(),this.isDisposed=!0)}}],[{key:"isDisposable",value:function(e){return Boolean(e&&Vt(e.dispose))}},{key:"_fixup",value:function(t){return e.isDisposable(t)?t:e.empty}},{key:"create",value:function(t){return new e(t)}}]),e}();return e.empty={dispose:Wt},e}(),Hr=function(){function e(){Mr(this,e),this.isDisposed=!1;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.disposables=r}return _r(e,[{key:"add",value:function(e){this.isDisposed?e.dispose():this.disposables.push(e)}},{key:"remove",value:function(e){var t=!1;if(!this.isDisposed){var r=this.disposables.indexOf(e);-1!==r&&(t=!0,this.disposables.splice(r,1),e.dispose())}return t}},{key:"clear",value:function(){if(!this.isDisposed){for(var e=this.disposables.length,t=new Array(e),r=0;r<e;r++)t[r]=this.disposables[r];this.disposables=[];for(var n=0;n<e;n++)t[n].dispose()}}},{key:"dispose",value:function(){if(!this.isDisposed){this.isDisposed=!0;for(var e=this.disposables.length,t=new Array(e),r=0;r<e;r++)t[r]=this.disposables[r];this.disposables=[];for(var n=0;n<e;n++)t[n].dispose()}}}]),e}(),Ur=function(){function e(){Mr(this,e),this.isDisposed=!1}return _r(e,[{key:"getDisposable",value:function(){return this.current}},{key:"setDisposable",value:function(e){var t=this.isDisposed;if(!t){var r=this.current;this.current=e,r&&r.dispose()}t&&e&&e.dispose()}},{key:"dispose",value:function(){if(!this.isDisposed){this.isDisposed=!0;var e=this.current;this.current=void 0,e&&e.dispose()}}}]),e}();function $r(e){return($r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Fr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Lr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Lr(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Lr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Br(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Gr(e,t){return(Gr=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function qr(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=Wr(e);if(t){var o=Wr(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Vr(this,r)}}function Vr(e,t){return!t||"object"!==$r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function Wr(e){return(Wr=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Yr(e){var r=e.DecoratedComponent,n=e.createHandler,o=e.createMonitor,i=e.createConnector,a=e.registerHandler,u=e.containerDisplayName,s=e.getType,f=e.collect,l=e.options.arePropsEqual,d=void 0===l?at:l,p=r,h=r.displayName||r.name||"Component",g=function(){var e=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Gr(e,t)}(y,e);var r,u,l,g=qr(y);function y(e){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,y),(r=g.call(this,e)).decoratedRef=t.createRef(),r.handleChange=function(){var e=r.getCurrentState();at(e,r.state)||r.setState(e)},r.disposable=new Ur,r.receiveProps(e),r.dispose(),r}return r=y,(u=[{key:"getHandlerId",value:function(){return this.handlerId}},{key:"getDecoratedComponentInstance",value:function(){return c(this.decoratedRef.current,"In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()"),this.decoratedRef.current}},{key:"shouldComponentUpdate",value:function(e,t){return!d(e,this.props)||!at(t,this.state)}},{key:"componentDidMount",value:function(){this.disposable=new Ur,this.currentType=void 0,this.receiveProps(this.props),this.handleChange()}},{key:"componentDidUpdate",value:function(e){d(this.props,e)||(this.receiveProps(this.props),this.handleChange())}},{key:"componentWillUnmount",value:function(){this.dispose()}},{key:"receiveProps",value:function(e){this.handler&&(this.handler.receiveProps(e),this.receiveType(s(e)))}},{key:"receiveType",value:function(e){if(this.handlerMonitor&&this.manager&&this.handlerConnector&&e!==this.currentType){this.currentType=e;var t=Fr(a(e,this.handler,this.manager),2),r=t[0],n=t[1];this.handlerId=r,this.handlerMonitor.receiveHandlerId(r),this.handlerConnector.receiveHandlerId(r);var o=this.manager.getMonitor().subscribeToStateChange(this.handleChange,{handlerIds:[r]});this.disposable.setDisposable(new Hr(new Nr(o),new Nr(n)))}}},{key:"dispose",value:function(){this.disposable.dispose(),this.handlerConnector&&this.handlerConnector.receiveHandlerId(null)}},{key:"getCurrentState",value:function(){return this.handlerConnector?f(this.handlerConnector.hooks,this.handlerMonitor,this.props):{}}},{key:"render",value:function(){var e=this;return t.createElement(Ke.Consumer,null,(function(r){var n=r.dragDropManager;return e.receiveDragDropManager(n),"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame((function(){var t;return null===(t=e.handlerConnector)||void 0===t?void 0:t.reconnect()})),t.createElement(p,Object.assign({},e.props,e.getCurrentState(),{ref:Kt(p)?e.decoratedRef:null}))}))}},{key:"receiveDragDropManager",value:function(e){void 0===this.manager&&(c(void 0!==e,"Could not find the drag and drop manager in the context of %s. Make sure to render a DndProvider component in your top-level component. Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context",h,h),void 0!==e&&(this.manager=e,this.handlerMonitor=o(e),this.handlerConnector=i(e.getBackend()),this.handler=n(this.handlerMonitor,this.decoratedRef)))}}])&&Br(r.prototype,u),l&&Br(r,l),y}(t.Component);return e.DecoratedComponent=r,e.displayName="".concat(u,"(").concat(h,")"),e}();return xr(g,r)}function zr(e){return(zr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Kr(e,t){return"string"==typeof e||"symbol"===zr(e)||!!t&&Array.isArray(e)&&e.every((function(e){return Kr(e,!1)}))}function Xr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var Jr=["canDrag","beginDrag","isDragging","endDrag"],Qr=["beginDrag"],Zr=function(){function e(t,r,n){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=null,this.beginDrag=function(){if(o.props)return o.spec.beginDrag(o.props,o.monitor,o.ref.current)},this.spec=t,this.monitor=r,this.ref=n}var t,r,n;return t=e,(r=[{key:"receiveProps",value:function(e){this.props=e}},{key:"canDrag",value:function(){return!!this.props&&(!this.spec.canDrag||this.spec.canDrag(this.props,this.monitor))}},{key:"isDragging",value:function(e,t){return!!this.props&&(this.spec.isDragging?this.spec.isDragging(this.props,this.monitor):t===e.getSourceId())}},{key:"endDrag",value:function(){this.props&&this.spec.endDrag&&this.spec.endDrag(this.props,this.monitor,zt(this.ref))}}])&&Xr(t.prototype,r),n&&Xr(t,n),e}();function en(e){return Object.keys(e).forEach((function(t){c(Jr.indexOf(t)>-1,'Expected the drag source specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',Jr.join(", "),t),c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),Qr.forEach((function(t){c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),function(t,r){return new Zr(e,t,r)}}function tn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var rn=["canDrop","hover","drop"],nn=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=null,this.spec=t,this.monitor=r,this.ref=n}var t,r,n;return t=e,(r=[{key:"receiveProps",value:function(e){this.props=e}},{key:"receiveMonitor",value:function(e){this.monitor=e}},{key:"canDrop",value:function(){return!this.spec.canDrop||this.spec.canDrop(this.props,this.monitor)}},{key:"hover",value:function(){this.spec.hover&&this.props&&this.spec.hover(this.props,this.monitor,zt(this.ref))}},{key:"drop",value:function(){if(this.spec.drop)return this.spec.drop(this.props,this.monitor,this.ref.current)}}])&&tn(t.prototype,r),n&&tn(t,n),e}();function on(e){return Object.keys(e).forEach((function(t){c(rn.indexOf(t)>-1,'Expected the drop target specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',rn.join(", "),t),c("function"==typeof e[t],"Expected %s in the drop target specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target",t,t,e[t])})),function(t,r){return new nn(e,t,r)}}function an(e){return(an="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function un(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cn(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function sn(e,t,r){return t&&cn(e.prototype,t),r&&cn(e,r),e}function fn(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ln(e,t)}function ln(e,t){return(ln=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function dn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=hn(e);if(t){var o=hn(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return pn(this,r)}}function pn(e,t){return!t||"object"!==an(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function hn(e){return(hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}e.DndContext=Ke,e.DndProvider=tt,e.DragLayer=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c("function"==typeof e,'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ',"Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer",e),c(Yt(r),'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer',r),function(n){var o=n,i=r.arePropsEqual,a=void 0===i?at:i,u=o.displayName||o.name||"Component",s=function(){var r=function(r){fn(i,r);var n=dn(i);function i(){var e;return un(this,i),(e=n.apply(this,arguments)).isCurrentlyMounted=!1,e.ref=t.createRef(),e.handleChange=function(){if(e.isCurrentlyMounted){var t=e.getCurrentState();at(t,e.state)||e.setState(t)}},e}return sn(i,[{key:"getDecoratedComponentInstance",value:function(){return c(this.ref.current,"In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()"),this.ref.current}},{key:"shouldComponentUpdate",value:function(e,t){return!a(e,this.props)||!at(t,this.state)}},{key:"componentDidMount",value:function(){this.isCurrentlyMounted=!0,this.handleChange()}},{key:"componentWillUnmount",value:function(){this.isCurrentlyMounted=!1,this.unsubscribeFromOffsetChange&&(this.unsubscribeFromOffsetChange(),this.unsubscribeFromOffsetChange=void 0),this.unsubscribeFromStateChange&&(this.unsubscribeFromStateChange(),this.unsubscribeFromStateChange=void 0)}},{key:"render",value:function(){var e=this;return t.createElement(Ke.Consumer,null,(function(r){var n=r.dragDropManager;return void 0===n?null:(e.receiveDragDropManager(n),e.isCurrentlyMounted?t.createElement(o,Object.assign({},e.props,e.state,{ref:Kt(o)?e.ref:null})):null)}))}},{key:"receiveDragDropManager",value:function(e){if(void 0===this.manager){this.manager=e,c("object"===an(e),"Could not find the drag and drop manager in the context of %s. Make sure to render a DndProvider component in your top-level component. Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context",u,u);var t=this.manager.getMonitor();this.unsubscribeFromOffsetChange=t.subscribeToOffsetChange(this.handleChange),this.unsubscribeFromStateChange=t.subscribeToStateChange(this.handleChange)}}},{key:"getCurrentState",value:function(){if(!this.manager)return{};var t=this.manager.getMonitor();return e(t,this.props)}}]),i}(t.Component);return r.displayName="DragLayer(".concat(u,")"),r.DecoratedComponent=n,r}();return xr(s,n)}},e.DragPreviewImage=ot,e.DragSource=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e;"function"!=typeof e&&(c(Kr(e),'Expected "type" provided as the first argument to DragSource to be a string, or a function that returns a string given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',e),o=function(){return e}),c(Yt(t),'Expected "spec" provided as the second argument to DragSource to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',t);var i=en(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DragSource to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),c(Yt(n),'Expected "options" provided as the fourth argument to DragSource to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),function(e){return Yr({containerDisplayName:"DragSource",createHandler:i,registerHandler:ht,createConnector:function(e){return new Tt(e)},createMonitor:function(e){return new mt(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.DropTarget=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=e;"function"!=typeof e&&(c(Kr(e,!0),'Expected "type" provided as the first argument to DropTarget to be a string, an array of strings, or a function that returns either given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',e),o=function(){return e}),c(Yt(t),'Expected "spec" provided as the second argument to DropTarget to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',t);var i=on(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DropTarget to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),c(Yt(n),'Expected "options" provided as the fourth argument to DropTarget to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),function(e){return Yr({containerDisplayName:"DropTarget",createHandler:i,registerHandler:pt,createMonitor:function(e){return new Ht(e)},createConnector:function(e){return new At(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.createDndContext=Xe,e.useDrag=function(e){var r=t.useRef(e);r.current=e,c(null!=e.item,"item must be defined"),c(null!=e.item.type,"item type must be defined");var n,o=Rt((n=gt(),[t.useMemo((function(){return new mt(n)}),[n]),t.useMemo((function(){return new Tt(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=gt(),i=t.useMemo((function(){return{beginDrag:function(){var t=e.current,n=t.begin,o=t.item;if(n){var i=n(r);return c(null==i||"object"===Et(i),"dragSpec.begin() must either return an object, undefined, or null"),i||o||{}}return o||{}},canDrag:function(){return"boolean"==typeof e.current.canDrag?e.current.canDrag:"function"!=typeof e.current.canDrag||e.current.canDrag(r)},isDragging:function(t,n){var o=e.current.isDragging;return o?o(r):n===t.getSourceId()},endDrag:function(){var t=e.current.end;t&&t(r.getItem(),r),n.reconnect()}}}),[]);it((function(){var t=Pt(ht(e.current.item.type,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[])}(r,i,a);var u=dt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dragSource()}),[a]),f=t.useMemo((function(){return a.hooks.dragPreview()}),[a]);return it((function(){a.dragSourceOptions=r.current.options||null,a.reconnect()}),[a]),it((function(){a.dragPreviewOptions=r.current.previewOptions||null,a.reconnect()}),[a]),[u,s,f]},e.useDragDropManager=gt,e.useDragLayer=function(e){var r=gt().getMonitor(),n=Bt(st(r,e),2),o=n[0],i=n[1];return t.useEffect((function(){return r.subscribeToOffsetChange(i)})),t.useEffect((function(){return r.subscribeToStateChange(i)})),o},e.useDrop=function(e){var r=t.useRef(e);r.current=e,c(null!=e.accept,"accept must be defined");var n,o=Ft((n=gt(),[t.useMemo((function(){return new Ht(n)}),[n]),t.useMemo((function(){return new At(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=gt(),i=t.useMemo((function(){return{canDrop:function(){var t=e.current.canDrop;return!t||t(r.getItem(),r)},hover:function(){var t=e.current.hover;t&&t(r.getItem(),r)},drop:function(){var t=e.current.drop;if(t)return t(r.getItem(),r)}}}),[r]);it((function(){var t=Ut(pt(e.current.accept,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[r,n])}(r,i,a);var u=dt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dropTarget()}),[a]);return it((function(){a.dropTargetOptions=e.options||null,a.reconnect()}),[e.options]),[u,s]},Object.defineProperty(e,"__esModule",{value:!0})})); dist/cjs/decorators/utils.js000064400000003570151676724530012156 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDecoratedComponent = getDecoratedComponent; exports.isClassComponent = isClassComponent; exports.isRefForwardingComponent = isRefForwardingComponent; exports.isRefable = isRefable; exports.checkDecoratorArguments = checkDecoratorArguments; function getDecoratedComponent(instanceRef) { var currentRef = instanceRef.current; if (currentRef == null) { return null; } else if (currentRef.decoratedRef) { // go through the private field in decorateHandler to avoid the invariant hit return currentRef.decoratedRef.current; } else { return currentRef; } } function isClassComponent(Component) { return Component && Component.prototype && typeof Component.prototype.render === 'function'; } function isRefForwardingComponent(C) { var _item$$$typeof; var item = C; return (item === null || item === void 0 ? void 0 : (_item$$$typeof = item.$$typeof) === null || _item$$$typeof === void 0 ? void 0 : _item$$$typeof.toString()) === 'Symbol(react.forward_ref)'; } function isRefable(C) { return isClassComponent(C) || isRefForwardingComponent(C); } function checkDecoratorArguments(functionName, signature) { if (process.env.NODE_ENV !== 'production') { for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) { var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2]; if (arg && arg.prototype && arg.prototype.render) { // eslint-disable-next-line no-console console.error('You seem to be applying the arguments in the wrong order. ' + "It should be ".concat(functionName, "(").concat(signature, ")(Component), not the other way around. ") + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order'); return; } } } }dist/cjs/decorators/DragLayer.js000064400000023630151676724530012667 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DragLayer = DragLayer; var React = _interopRequireWildcard(require("react")); var _shallowequal = require("@react-dnd/shallowequal"); var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); var _invariant = require("@react-dnd/invariant"); var _DndContext = require("../common/DndContext"); var _js_utils = require("../utils/js_utils"); var _utils = require("./utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function DragLayer(collect) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; (0, _utils.checkDecoratorArguments)('DragLayer', 'collect[, options]', collect, options); (0, _invariant.invariant)(typeof collect === 'function', 'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ', 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', collect); (0, _invariant.invariant)((0, _js_utils.isPlainObject)(options), 'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. ' + 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', options); return function decorateLayer(DecoratedComponent) { var Decorated = DecoratedComponent; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? _shallowequal.shallowEqual : _options$arePropsEqua; var displayName = Decorated.displayName || Decorated.name || 'Component'; var DragLayerContainer = /** @class */ function () { var DragLayerContainer = /*#__PURE__*/function (_React$Component) { _inherits(DragLayerContainer, _React$Component); var _super = _createSuper(DragLayerContainer); function DragLayerContainer() { var _this; _classCallCheck(this, DragLayerContainer); _this = _super.apply(this, arguments); _this.isCurrentlyMounted = false; _this.ref = React.createRef(); _this.handleChange = function () { if (!_this.isCurrentlyMounted) { return; } var nextState = _this.getCurrentState(); if (!(0, _shallowequal.shallowEqual)(nextState, _this.state)) { _this.setState(nextState); } }; return _this; } _createClass(DragLayerContainer, [{ key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { (0, _invariant.invariant)(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.ref.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !(0, _shallowequal.shallowEqual)(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.isCurrentlyMounted = true; this.handleChange(); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.isCurrentlyMounted = false; if (this.unsubscribeFromOffsetChange) { this.unsubscribeFromOffsetChange(); this.unsubscribeFromOffsetChange = undefined; } if (this.unsubscribeFromStateChange) { this.unsubscribeFromStateChange(); this.unsubscribeFromStateChange = undefined; } } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(_DndContext.DndContext.Consumer, null, function (_ref) { var dragDropManager = _ref.dragDropManager; if (dragDropManager === undefined) { return null; } _this2.receiveDragDropManager(dragDropManager); // Let componentDidMount fire to initialize the collected state if (!_this2.isCurrentlyMounted) { return null; } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.state, { ref: (0, _utils.isRefable)(Decorated) ? _this2.ref : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } this.manager = dragDropManager; (0, _invariant.invariant)(_typeof(dragDropManager) === 'object', 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); var monitor = this.manager.getMonitor(); this.unsubscribeFromOffsetChange = monitor.subscribeToOffsetChange(this.handleChange); this.unsubscribeFromStateChange = monitor.subscribeToStateChange(this.handleChange); } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.manager) { return {}; } var monitor = this.manager.getMonitor(); return collect(monitor, this.props); } }]); return DragLayerContainer; }(React.Component); DragLayerContainer.displayName = "DragLayer(".concat(displayName, ")"); DragLayerContainer.DecoratedComponent = DecoratedComponent; return DragLayerContainer; }(); return (0, _hoistNonReactStatics.default)(DragLayerContainer, DecoratedComponent); }; }dist/cjs/decorators/DropTarget.js000064400000005512151676724530013067 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropTarget = DropTarget; var _invariant = require("@react-dnd/invariant"); var _js_utils = require("../utils/js_utils"); var _registration = require("../common/registration"); var _isValidType = require("../utils/isValidType"); var _TargetConnector = require("../common/TargetConnector"); var _DropTargetMonitorImpl = require("../common/DropTargetMonitorImpl"); var _utils = require("./utils"); var _decorateHandler = require("./decorateHandler"); var _createTargetFactory = require("./createTargetFactory"); function DropTarget(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; (0, _utils.checkDecoratorArguments)('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { (0, _invariant.invariant)((0, _isValidType.isValidType)(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type); getType = function getType() { return type; }; } (0, _invariant.invariant)((0, _js_utils.isPlainObject)(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec); var createTarget = (0, _createTargetFactory.createTargetFactory)(spec); (0, _invariant.invariant)(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); (0, _invariant.invariant)((0, _js_utils.isPlainObject)(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); return function decorateTarget(DecoratedComponent) { return (0, _decorateHandler.decorateHandler)({ containerDisplayName: 'DropTarget', createHandler: createTarget, registerHandler: _registration.registerTarget, createMonitor: function createMonitor(manager) { return new _DropTargetMonitorImpl.DropTargetMonitorImpl(manager); }, createConnector: function createConnector(backend) { return new _TargetConnector.TargetConnector(backend); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; }dist/cjs/decorators/decorateHandler.js000064400000032332151676724530014100 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decorateHandler = decorateHandler; var React = _interopRequireWildcard(require("react")); var _shallowequal = require("@react-dnd/shallowequal"); var _invariant = require("@react-dnd/invariant"); var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics")); var _DndContext = require("../common/DndContext"); var _js_utils = require("../utils/js_utils"); var _disposables = require("./disposables"); var _utils = require("./utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function decorateHandler(_ref) { var DecoratedComponent = _ref.DecoratedComponent, createHandler = _ref.createHandler, createMonitor = _ref.createMonitor, createConnector = _ref.createConnector, registerHandler = _ref.registerHandler, containerDisplayName = _ref.containerDisplayName, getType = _ref.getType, collect = _ref.collect, options = _ref.options; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? _shallowequal.shallowEqual : _options$arePropsEqua; var Decorated = DecoratedComponent; var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component'; var DragDropContainer = /** @class */ function () { var DragDropContainer = /*#__PURE__*/function (_React$Component) { _inherits(DragDropContainer, _React$Component); var _super = _createSuper(DragDropContainer); function DragDropContainer(props) { var _this; _classCallCheck(this, DragDropContainer); _this = _super.call(this, props); _this.decoratedRef = React.createRef(); _this.handleChange = function () { var nextState = _this.getCurrentState(); if (!(0, _shallowequal.shallowEqual)(nextState, _this.state)) { _this.setState(nextState); } }; _this.disposable = new _disposables.SerialDisposable(); _this.receiveProps(props); _this.dispose(); return _this; } _createClass(DragDropContainer, [{ key: "getHandlerId", value: function getHandlerId() { return this.handlerId; } }, { key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { (0, _invariant.invariant)(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.decoratedRef.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !(0, _shallowequal.shallowEqual)(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.disposable = new _disposables.SerialDisposable(); this.currentType = undefined; this.receiveProps(this.props); this.handleChange(); } }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { if (!arePropsEqual(this.props, prevProps)) { this.receiveProps(this.props); this.handleChange(); } } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.dispose(); } }, { key: "receiveProps", value: function receiveProps(props) { if (!this.handler) { return; } this.handler.receiveProps(props); this.receiveType(getType(props)); } }, { key: "receiveType", value: function receiveType(type) { if (!this.handlerMonitor || !this.manager || !this.handlerConnector) { return; } if (type === this.currentType) { return; } this.currentType = type; var _registerHandler = registerHandler(type, this.handler, this.manager), _registerHandler2 = _slicedToArray(_registerHandler, 2), handlerId = _registerHandler2[0], unregister = _registerHandler2[1]; this.handlerId = handlerId; this.handlerMonitor.receiveHandlerId(handlerId); this.handlerConnector.receiveHandlerId(handlerId); var globalMonitor = this.manager.getMonitor(); var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, { handlerIds: [handlerId] }); this.disposable.setDisposable(new _disposables.CompositeDisposable(new _disposables.Disposable(unsubscribe), new _disposables.Disposable(unregister))); } }, { key: "dispose", value: function dispose() { this.disposable.dispose(); if (this.handlerConnector) { this.handlerConnector.receiveHandlerId(null); } } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.handlerConnector) { return {}; } var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props); if (process.env.NODE_ENV !== 'production') { (0, _invariant.invariant)((0, _js_utils.isPlainObject)(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState); } return nextState; } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(_DndContext.DndContext.Consumer, null, function (_ref2) { var dragDropManager = _ref2.dragDropManager; _this2.receiveDragDropManager(dragDropManager); if (typeof requestAnimationFrame !== 'undefined') { requestAnimationFrame(function () { var _this2$handlerConnect; return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect(); }); } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), { // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. ref: (0, _utils.isRefable)(Decorated) ? _this2.decoratedRef : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } (0, _invariant.invariant)(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); if (dragDropManager === undefined) { return; } this.manager = dragDropManager; this.handlerMonitor = createMonitor(dragDropManager); this.handlerConnector = createConnector(dragDropManager.getBackend()); this.handler = createHandler(this.handlerMonitor, this.decoratedRef); } }]); return DragDropContainer; }(React.Component); DragDropContainer.DecoratedComponent = DecoratedComponent; DragDropContainer.displayName = "".concat(containerDisplayName, "(").concat(displayName, ")"); return DragDropContainer; }(); return (0, _hoistNonReactStatics.default)(DragDropContainer, DecoratedComponent); }dist/cjs/decorators/index.js000064400000002307151676724530012122 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _DragSource = require("./DragSource"); Object.keys(_DragSource).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DragSource[key]; } }); }); var _DropTarget = require("./DropTarget"); Object.keys(_DropTarget).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DropTarget[key]; } }); }); var _DragLayer = require("./DragLayer"); Object.keys(_DragLayer).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DragLayer[key]; } }); }); var _interfaces = require("./interfaces"); Object.keys(_interfaces).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _interfaces[key]; } }); });dist/cjs/decorators/DragSource.js000064400000005777151676724530013067 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DragSource = DragSource; var _invariant = require("@react-dnd/invariant"); var _js_utils = require("../utils/js_utils"); var _utils = require("./utils"); var _decorateHandler = require("./decorateHandler"); var _registration = require("../common/registration"); var _DragSourceMonitorImpl = require("../common/DragSourceMonitorImpl"); var _SourceConnector = require("../common/SourceConnector"); var _isValidType = require("../utils/isValidType"); var _createSourceFactory = require("./createSourceFactory"); /** * Decorates a component as a dragsource * @param type The dragsource type * @param spec The drag source specification * @param collect The props collector function * @param options DnD options */ function DragSource(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; (0, _utils.checkDecoratorArguments)('DragSource', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { (0, _invariant.invariant)((0, _isValidType.isValidType)(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type); getType = function getType() { return type; }; } (0, _invariant.invariant)((0, _js_utils.isPlainObject)(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec); var createSource = (0, _createSourceFactory.createSourceFactory)(spec); (0, _invariant.invariant)(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); (0, _invariant.invariant)((0, _js_utils.isPlainObject)(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); return function decorateSource(DecoratedComponent) { return (0, _decorateHandler.decorateHandler)({ containerDisplayName: 'DragSource', createHandler: createSource, registerHandler: _registration.registerSource, createConnector: function createConnector(backend) { return new _SourceConnector.SourceConnector(backend); }, createMonitor: function createMonitor(manager) { return new _DragSourceMonitorImpl.DragSourceMonitorImpl(manager); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; }dist/cjs/decorators/createSourceFactory.js000064400000007572151676724530015000 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSourceFactory = createSourceFactory; var _invariant = require("@react-dnd/invariant"); var _js_utils = require("../utils/js_utils"); var _utils = require("./utils"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ALLOWED_SPEC_METHODS = ['canDrag', 'beginDrag', 'isDragging', 'endDrag']; var REQUIRED_SPEC_METHODS = ['beginDrag']; var SourceImpl = /*#__PURE__*/function () { function SourceImpl(spec, monitor, ref) { var _this = this; _classCallCheck(this, SourceImpl); this.props = null; this.beginDrag = function () { if (!_this.props) { return; } var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current); if (process.env.NODE_ENV !== 'production') { (0, _invariant.invariant)((0, _js_utils.isPlainObject)(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item); } return item; }; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass(SourceImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "canDrag", value: function canDrag() { if (!this.props) { return false; } if (!this.spec.canDrag) { return true; } return this.spec.canDrag(this.props, this.monitor); } }, { key: "isDragging", value: function isDragging(globalMonitor, sourceId) { if (!this.props) { return false; } if (!this.spec.isDragging) { return sourceId === globalMonitor.getSourceId(); } return this.spec.isDragging(this.props, this.monitor); } }, { key: "endDrag", value: function endDrag() { if (!this.props) { return; } if (!this.spec.endDrag) { return; } this.spec.endDrag(this.props, this.monitor, (0, _utils.getDecoratedComponent)(this.ref)); } }]); return SourceImpl; }(); function createSourceFactory(spec) { Object.keys(spec).forEach(function (key) { (0, _invariant.invariant)(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS.join(', '), key); (0, _invariant.invariant)(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); REQUIRED_SPEC_METHODS.forEach(function (key) { (0, _invariant.invariant)(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); return function createSource(monitor, ref) { return new SourceImpl(spec, monitor, ref); }; }dist/cjs/decorators/createTargetFactory.js000064400000006413151676724530014757 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTargetFactory = createTargetFactory; var _invariant = require("@react-dnd/invariant"); var _js_utils = require("../utils/js_utils"); var _utils = require("./utils"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop']; var TargetImpl = /*#__PURE__*/function () { function TargetImpl(spec, monitor, ref) { _classCallCheck(this, TargetImpl); this.props = null; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass(TargetImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "receiveMonitor", value: function receiveMonitor(monitor) { this.monitor = monitor; } }, { key: "canDrop", value: function canDrop() { if (!this.spec.canDrop) { return true; } return this.spec.canDrop(this.props, this.monitor); } }, { key: "hover", value: function hover() { if (!this.spec.hover || !this.props) { return; } this.spec.hover(this.props, this.monitor, (0, _utils.getDecoratedComponent)(this.ref)); } }, { key: "drop", value: function drop() { if (!this.spec.drop) { return undefined; } var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current); if (process.env.NODE_ENV !== 'production') { (0, _invariant.invariant)(typeof dropResult === 'undefined' || (0, _js_utils.isPlainObject)(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult); } return dropResult; } }]); return TargetImpl; }(); function createTargetFactory(spec) { Object.keys(spec).forEach(function (key) { (0, _invariant.invariant)(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS.join(', '), key); (0, _invariant.invariant)(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]); }); return function createTarget(monitor, ref) { return new TargetImpl(spec, monitor, ref); }; }dist/cjs/decorators/disposables.js000064400000015272151676724530013330 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SerialDisposable = exports.CompositeDisposable = exports.Disposable = void 0; var _js_utils = require("../utils/js_utils"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Provides a set of static methods for creating Disposables. * @param {Function} action Action to run during the first call to dispose. * The action is guaranteed to be run at most once. */ var Disposable = /** @class */ function () { var Disposable = /*#__PURE__*/function () { function Disposable(action) { _classCallCheck(this, Disposable); this.isDisposed = false; this.action = (0, _js_utils.isFunction)(action) ? action : _js_utils.noop; } /** * Validates whether the given object is a disposable * @param {Object} Object to test whether it has a dispose method * @returns {Boolean} true if a disposable object, else false. */ _createClass(Disposable, [{ key: "dispose", /** Performs the task of cleaning up resources. */ value: function dispose() { if (!this.isDisposed) { this.action(); this.isDisposed = true; } } }], [{ key: "isDisposable", value: function isDisposable(d) { return Boolean(d && (0, _js_utils.isFunction)(d.dispose)); } }, { key: "_fixup", value: function _fixup(result) { return Disposable.isDisposable(result) ? result : Disposable.empty; } /** * Creates a disposable object that invokes the specified action when disposed. * @param {Function} dispose Action to run during the first call to dispose. * The action is guaranteed to be run at most once. * @return {Disposable} The disposable object that runs the given action upon disposal. */ }, { key: "create", value: function create(action) { return new Disposable(action); } }]); return Disposable; }(); /** * Gets the disposable that does nothing when disposed. */ Disposable.empty = { dispose: _js_utils.noop }; return Disposable; }(); exports.Disposable = Disposable; /** * Represents a group of disposable resources that are disposed together. * @constructor */ var CompositeDisposable = /*#__PURE__*/function () { function CompositeDisposable() { _classCallCheck(this, CompositeDisposable); this.isDisposed = false; for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) { disposables[_key] = arguments[_key]; } this.disposables = disposables; } /** * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. * @param {Any} item Disposable to add. */ _createClass(CompositeDisposable, [{ key: "add", value: function add(item) { if (this.isDisposed) { item.dispose(); } else { this.disposables.push(item); } } /** * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. * @param {Any} item Disposable to remove. * @returns {Boolean} true if found; false otherwise. */ }, { key: "remove", value: function remove(item) { var shouldDispose = false; if (!this.isDisposed) { var idx = this.disposables.indexOf(item); if (idx !== -1) { shouldDispose = true; this.disposables.splice(idx, 1); item.dispose(); } } return shouldDispose; } /** * Disposes all disposables in the group and removes them from the group but * does not dispose the CompositeDisposable. */ }, { key: "clear", value: function clear() { if (!this.isDisposed) { var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i = 0; _i < len; _i++) { currentDisposables[_i].dispose(); } } } /** * Disposes all disposables in the group and removes them from the group. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i2 = 0; _i2 < len; _i2++) { currentDisposables[_i2].dispose(); } } } }]); return CompositeDisposable; }(); /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ exports.CompositeDisposable = CompositeDisposable; var SerialDisposable = /*#__PURE__*/function () { function SerialDisposable() { _classCallCheck(this, SerialDisposable); this.isDisposed = false; } /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ _createClass(SerialDisposable, [{ key: "getDisposable", value: function getDisposable() { return this.current; } }, { key: "setDisposable", value: function setDisposable(value) { var shouldDispose = this.isDisposed; if (!shouldDispose) { var old = this.current; this.current = value; if (old) { old.dispose(); } } if (shouldDispose && value) { value.dispose(); } } /** Performs the task of cleaning up resources. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var old = this.current; this.current = undefined; if (old) { old.dispose(); } } } }]); return SerialDisposable; }(); exports.SerialDisposable = SerialDisposable;dist/cjs/decorators/interfaces.js000064400000000015151676724530013130 0ustar00"use strict";dist/cjs/utils/isRef.js000064400000001242151676724530011053 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isRef = isRef; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function isRef(obj) { return (// eslint-disable-next-line no-prototype-builtins obj !== null && _typeof(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current') ); }dist/cjs/utils/cloneWithRef.js000064400000002045151676724530012376 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cloneWithRef = cloneWithRef; var _react = require("react"); var _invariant = require("@react-dnd/invariant"); function setRef(ref, node) { if (typeof ref === 'function') { ref(node); } else { ref.current = node; } } function cloneWithRef(element, newRef) { var previousRef = element.ref; (0, _invariant.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://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute'); if (!previousRef) { // When there is no ref on the element, use the new ref directly return (0, _react.cloneElement)(element, { ref: newRef }); } else { return (0, _react.cloneElement)(element, { ref: function ref(node) { setRef(previousRef, node); setRef(newRef, node); } }); } }dist/cjs/utils/js_utils.js000064400000002106151676724530011637 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFunction = isFunction; exports.noop = noop; exports.isPlainObject = isPlainObject; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } // cheap lodash replacements function isFunction(input) { return typeof input === 'function'; } function noop() {// noop } function isObjectLike(input) { return _typeof(input) === 'object' && input !== null; } function isPlainObject(input) { if (!isObjectLike(input)) { return false; } if (Object.getPrototypeOf(input) === null) { return true; } var proto = input; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(input) === proto; }dist/cjs/utils/isValidType.js000064400000001306151676724530012241 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidType = isValidType; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function isValidType(type, allowArray) { return typeof type === 'string' || _typeof(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) { return isValidType(t, false); }); }dist/cjs/index.js000064400000002247151676724530007760 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _common = require("./common"); Object.keys(_common).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _common[key]; } }); }); var _interfaces = require("./interfaces"); Object.keys(_interfaces).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _interfaces[key]; } }); }); var _hooks = require("./hooks"); Object.keys(_hooks).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _hooks[key]; } }); }); var _decorators = require("./decorators"); Object.keys(_decorators).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _decorators[key]; } }); });dist/cjs/interfaces/hooksApi.js000064400000000015151676724530012540 0ustar00"use strict";dist/cjs/interfaces/monitors.js000064400000000015151676724530012635 0ustar00"use strict";dist/cjs/interfaces/index.js000064400000002257151676724530012104 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _monitors = require("./monitors"); Object.keys(_monitors).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _monitors[key]; } }); }); var _hooksApi = require("./hooksApi"); Object.keys(_hooksApi).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _hooksApi[key]; } }); }); var _options = require("./options"); Object.keys(_options).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _options[key]; } }); }); var _connectors = require("./connectors"); Object.keys(_connectors).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _connectors[key]; } }); });dist/cjs/interfaces/connectors.js000064400000000015151676724530013140 0ustar00"use strict";dist/cjs/interfaces/options.js000064400000000015151676724530012456 0ustar00"use strict";dist/cjs/hooks/useDrop.js000064400000005603151676724530011414 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDrop = useDrop; var _react = require("react"); var _invariant = require("@react-dnd/invariant"); var _useMonitorOutput = require("./internal/useMonitorOutput"); var _useIsomorphicLayoutEffect = require("./internal/useIsomorphicLayoutEffect"); var _drop = require("./internal/drop"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /** * useDropTarget Hook * @param spec The drop target specification */ function useDrop(spec) { var specRef = (0, _react.useRef)(spec); specRef.current = spec; (0, _invariant.invariant)(spec.accept != null, 'accept must be defined'); var _useDropTargetMonitor = (0, _drop.useDropTargetMonitor)(), _useDropTargetMonitor2 = _slicedToArray(_useDropTargetMonitor, 2), monitor = _useDropTargetMonitor2[0], connector = _useDropTargetMonitor2[1]; (0, _drop.useDropHandler)(specRef, monitor, connector); var result = (0, _useMonitorOutput.useMonitorOutput)(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDropTarget = (0, _react.useMemo)(function () { return connector.hooks.dropTarget(); }, [connector]); (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () { connector.dropTargetOptions = spec.options || null; connector.reconnect(); }, [spec.options]); return [result, connectDropTarget]; }dist/cjs/hooks/internal/drag.js000064400000011202151676724530012514 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDragSourceMonitor = useDragSourceMonitor; exports.useDragHandler = useDragHandler; var _react = require("react"); var _invariant = require("@react-dnd/invariant"); var _registration = require("../../common/registration"); var _useDragDropManager = require("../useDragDropManager"); var _DragSourceMonitorImpl = require("../../common/DragSourceMonitorImpl"); var _SourceConnector = require("../../common/SourceConnector"); var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function useDragSourceMonitor() { var manager = (0, _useDragDropManager.useDragDropManager)(); var monitor = (0, _react.useMemo)(function () { return new _DragSourceMonitorImpl.DragSourceMonitorImpl(manager); }, [manager]); var connector = (0, _react.useMemo)(function () { return new _SourceConnector.SourceConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } function useDragHandler(spec, monitor, connector) { var manager = (0, _useDragDropManager.useDragDropManager)(); var handler = (0, _react.useMemo)(function () { return { beginDrag: function beginDrag() { var _spec$current = spec.current, begin = _spec$current.begin, item = _spec$current.item; if (begin) { var beginResult = begin(monitor); (0, _invariant.invariant)(beginResult == null || _typeof(beginResult) === 'object', 'dragSpec.begin() must either return an object, undefined, or null'); return beginResult || item || {}; } return item || {}; }, canDrag: function canDrag() { if (typeof spec.current.canDrag === 'boolean') { return spec.current.canDrag; } else if (typeof spec.current.canDrag === 'function') { return spec.current.canDrag(monitor); } else { return true; } }, isDragging: function isDragging(globalMonitor, target) { var isDragging = spec.current.isDragging; return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId(); }, endDrag: function endDrag() { var end = spec.current.end; if (end) { end(monitor.getItem(), monitor); } connector.reconnect(); } }; }, []); (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function registerHandler() { var _registerSource = (0, _registration.registerSource)(spec.current.item.type, handler, manager), _registerSource2 = _slicedToArray(_registerSource, 2), handlerId = _registerSource2[0], unregister = _registerSource2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, []); }dist/cjs/hooks/internal/useIsomorphicLayoutEffect.js000064400000000576151676724530016757 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useIsomorphicLayoutEffect = void 0; var _react = require("react"); // suppress the useLayoutEffect warning on server side. var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect; exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;dist/cjs/hooks/internal/useMonitorOutput.js000064400000004553151676724530015177 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useMonitorOutput = useMonitorOutput; var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect"); var _useCollector3 = require("./useCollector"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function useMonitorOutput(monitor, collect, onCollect) { var _useCollector = (0, _useCollector3.useCollector)(monitor, collect, onCollect), _useCollector2 = _slicedToArray(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function subscribeToMonitorStateChange() { var handlerId = monitor.getHandlerId(); if (handlerId == null) { return undefined; } return monitor.subscribeToStateChange(updateCollected, { handlerIds: [handlerId] }); }, [monitor, updateCollected]); return collected; }dist/cjs/hooks/internal/drop.js000064400000007043151676724530012553 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDropTargetMonitor = useDropTargetMonitor; exports.useDropHandler = useDropHandler; var _react = require("react"); var _registration = require("../../common/registration"); var _useDragDropManager = require("../useDragDropManager"); var _TargetConnector = require("../../common/TargetConnector"); var _DropTargetMonitorImpl = require("../../common/DropTargetMonitorImpl"); var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function useDropTargetMonitor() { var manager = (0, _useDragDropManager.useDragDropManager)(); var monitor = (0, _react.useMemo)(function () { return new _DropTargetMonitorImpl.DropTargetMonitorImpl(manager); }, [manager]); var connector = (0, _react.useMemo)(function () { return new _TargetConnector.TargetConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } function useDropHandler(spec, monitor, connector) { var manager = (0, _useDragDropManager.useDragDropManager)(); var handler = (0, _react.useMemo)(function () { return { canDrop: function canDrop() { var canDrop = spec.current.canDrop; return canDrop ? canDrop(monitor.getItem(), monitor) : true; }, hover: function hover() { var hover = spec.current.hover; if (hover) { hover(monitor.getItem(), monitor); } }, drop: function drop() { var drop = spec.current.drop; if (drop) { return drop(monitor.getItem(), monitor); } } }; }, [monitor]); (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function registerHandler() { var _registerTarget = (0, _registration.registerTarget)(spec.current.accept, handler, manager), _registerTarget2 = _slicedToArray(_registerTarget, 2), handlerId = _registerTarget2[0], unregister = _registerTarget2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, [monitor, connector]); }dist/cjs/hooks/internal/useCollector.js000064400000005271151676724530014253 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useCollector = useCollector; var _shallowequal = require("@react-dnd/shallowequal"); var _react = require("react"); var _useIsomorphicLayoutEffect = require("./useIsomorphicLayoutEffect"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /** * * @param monitor The monitor to collect state from * @param collect The collecting function * @param onUpdate A method to invoke when updates occur */ function useCollector(monitor, collect, onUpdate) { var _useState = (0, _react.useState)(function () { return collect(monitor); }), _useState2 = _slicedToArray(_useState, 2), collected = _useState2[0], setCollected = _useState2[1]; var updateCollected = (0, _react.useCallback)(function () { var nextValue = collect(monitor); if (!(0, _shallowequal.shallowEqual)(collected, nextValue)) { setCollected(nextValue); if (onUpdate) { onUpdate(); } } }, [collected, monitor, onUpdate]); // update the collected properties after the first render // and the components are attached to dnd-core (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(updateCollected, []); return [collected, updateCollected]; }dist/cjs/hooks/index.js000064400000002333151676724530011077 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _useDrag = require("./useDrag"); Object.keys(_useDrag).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _useDrag[key]; } }); }); var _useDrop = require("./useDrop"); Object.keys(_useDrop).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _useDrop[key]; } }); }); var _useDragLayer = require("./useDragLayer"); Object.keys(_useDragLayer).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _useDragLayer[key]; } }); }); var _useDragDropManager = require("./useDragDropManager"); Object.keys(_useDragDropManager).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _useDragDropManager[key]; } }); });dist/cjs/hooks/useDrag.js000064400000006544151676724530011372 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDrag = useDrag; var _react = require("react"); var _invariant = require("@react-dnd/invariant"); var _useMonitorOutput = require("./internal/useMonitorOutput"); var _useIsomorphicLayoutEffect = require("./internal/useIsomorphicLayoutEffect"); var _drag = require("./internal/drag"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /** * useDragSource hook * @param sourceSpec The drag source specification * */ function useDrag(spec) { var specRef = (0, _react.useRef)(spec); specRef.current = spec; // TODO: wire options into createSourceConnector (0, _invariant.invariant)(spec.item != null, 'item must be defined'); (0, _invariant.invariant)(spec.item.type != null, 'item type must be defined'); var _useDragSourceMonitor = (0, _drag.useDragSourceMonitor)(), _useDragSourceMonitor2 = _slicedToArray(_useDragSourceMonitor, 2), monitor = _useDragSourceMonitor2[0], connector = _useDragSourceMonitor2[1]; (0, _drag.useDragHandler)(specRef, monitor, connector); var result = (0, _useMonitorOutput.useMonitorOutput)(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDragSource = (0, _react.useMemo)(function () { return connector.hooks.dragSource(); }, [connector]); var connectDragPreview = (0, _react.useMemo)(function () { return connector.hooks.dragPreview(); }, [connector]); (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () { connector.dragSourceOptions = specRef.current.options || null; connector.reconnect(); }, [connector]); (0, _useIsomorphicLayoutEffect.useIsomorphicLayoutEffect)(function () { connector.dragPreviewOptions = specRef.current.previewOptions || null; connector.reconnect(); }, [connector]); return [result, connectDragSource, connectDragPreview]; }dist/cjs/hooks/useDragLayer.js000064400000004625151676724530012365 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDragLayer = useDragLayer; var _react = require("react"); var _useDragDropManager = require("./useDragDropManager"); var _useCollector3 = require("./internal/useCollector"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /** * useDragLayer Hook * @param collector The property collector */ function useDragLayer(collect) { var dragDropManager = (0, _useDragDropManager.useDragDropManager)(); var monitor = dragDropManager.getMonitor(); var _useCollector = (0, _useCollector3.useCollector)(monitor, collect), _useCollector2 = _slicedToArray(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; (0, _react.useEffect)(function () { return monitor.subscribeToOffsetChange(updateCollected); }); (0, _react.useEffect)(function () { return monitor.subscribeToStateChange(updateCollected); }); return collected; }dist/cjs/hooks/useDragDropManager.js000064400000001121151676724530013474 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useDragDropManager = useDragDropManager; var _react = require("react"); var _invariant = require("@react-dnd/invariant"); var _DndContext = require("../common/DndContext"); /** * A hook to retrieve the DragDropManager from Context */ function useDragDropManager() { var _useContext = (0, _react.useContext)(_DndContext.DndContext), dragDropManager = _useContext.dragDropManager; (0, _invariant.invariant)(dragDropManager != null, 'Expected drag drop context'); return dragDropManager; }dist/cjs/common/SourceConnector.js000064400000016017151676724530013254 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SourceConnector = void 0; var _wrapConnectorHooks = require("./wrapConnectorHooks"); var _isRef = require("../utils/isRef"); var _shallowequal = require("@react-dnd/shallowequal"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var SourceConnector = /*#__PURE__*/function () { function SourceConnector(backend) { var _this = this; _classCallCheck(this, SourceConnector); this.hooks = (0, _wrapConnectorHooks.wrapConnectorHooks)({ dragSource: function dragSource(node, options) { _this.clearDragSource(); _this.dragSourceOptions = options || null; if ((0, _isRef.isRef)(node)) { _this.dragSourceRef = node; } else { _this.dragSourceNode = node; } _this.reconnectDragSource(); }, dragPreview: function dragPreview(node, options) { _this.clearDragPreview(); _this.dragPreviewOptions = options || null; if ((0, _isRef.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; } _createClass(SourceConnector, [{ key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (this.handlerId === newHandlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "reconnect", value: function reconnect() { this.reconnectDragSource(); this.reconnectDragPreview(); } }, { key: "reconnectDragSource", value: function reconnectDragSource() { var dragSource = this.dragSource; // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange(); if (didChange) { this.disconnectDragSource(); } if (!this.handlerId) { return; } if (!dragSource) { this.lastConnectedDragSource = dragSource; return; } if (didChange) { this.lastConnectedHandlerId = this.handlerId; this.lastConnectedDragSource = dragSource; this.lastConnectedDragSourceOptions = this.dragSourceOptions; this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions); } } }, { key: "reconnectDragPreview", value: function reconnectDragPreview() { var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe var didChange = 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); } } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didConnectedDragSourceChange", value: function didConnectedDragSourceChange() { return this.lastConnectedDragSource !== this.dragSource; } }, { key: "didConnectedDragPreviewChange", value: function didConnectedDragPreviewChange() { return this.lastConnectedDragPreview !== this.dragPreview; } }, { key: "didDragSourceOptionsChange", value: function didDragSourceOptionsChange() { return !(0, _shallowequal.shallowEqual)(this.lastConnectedDragSourceOptions, this.dragSourceOptions); } }, { key: "didDragPreviewOptionsChange", value: function didDragPreviewOptionsChange() { return !(0, _shallowequal.shallowEqual)(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions); } }, { key: "disconnectDragSource", value: function disconnectDragSource() { if (this.dragSourceUnsubscribe) { this.dragSourceUnsubscribe(); this.dragSourceUnsubscribe = undefined; } } }, { key: "disconnectDragPreview", value: function disconnectDragPreview() { if (this.dragPreviewUnsubscribe) { this.dragPreviewUnsubscribe(); this.dragPreviewUnsubscribe = undefined; this.dragPreviewNode = null; this.dragPreviewRef = null; } } }, { key: "clearDragSource", value: function clearDragSource() { this.dragSourceNode = null; this.dragSourceRef = null; } }, { key: "clearDragPreview", value: function clearDragPreview() { this.dragPreviewNode = null; this.dragPreviewRef = null; } }, { key: "connectTarget", get: function get() { return this.dragSource; } }, { key: "dragSourceOptions", get: function get() { return this.dragSourceOptionsInternal; }, set: function set(options) { this.dragSourceOptionsInternal = options; } }, { key: "dragPreviewOptions", get: function get() { return this.dragPreviewOptionsInternal; }, set: function set(options) { this.dragPreviewOptionsInternal = options; } }, { key: "dragSource", get: function get() { return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current; } }, { key: "dragPreview", get: function get() { return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current; } }]); return SourceConnector; }(); exports.SourceConnector = SourceConnector;dist/cjs/common/DropTargetMonitorImpl.js000064400000007417151676724530014412 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DropTargetMonitorImpl = void 0; var _invariant = require("@react-dnd/invariant"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var isCallingCanDrop = false; var DropTargetMonitorImpl = /*#__PURE__*/function () { function DropTargetMonitorImpl(manager) { _classCallCheck(this, DropTargetMonitorImpl); this.targetId = null; this.internalMonitor = manager.getMonitor(); } _createClass(DropTargetMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(targetId) { this.targetId = targetId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.targetId; } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "canDrop", value: function 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; } (0, _invariant.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; } } }, { key: "isOver", value: function isOver(options) { if (!this.targetId) { return false; } return this.internalMonitor.isOverTarget(this.targetId, options); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DropTargetMonitorImpl; }(); exports.DropTargetMonitorImpl = DropTargetMonitorImpl;dist/cjs/common/DndProvider.js000064400000013541151676724530012360 0ustar00"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.DndProvider = void 0; var React = _interopRequireWildcard(require("react")); var _DndContext = require("./DndContext"); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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; } var refCount = 0; /** * A React component that provides the React-DnD context */ var DndProvider = (0, React.memo)(function (_ref) { var children = _ref.children, props = _objectWithoutProperties(_ref, ["children"]); var _getDndContextValue = getDndContextValue(props), _getDndContextValue2 = _slicedToArray(_getDndContextValue, 2), manager = _getDndContextValue2[0], isGlobalInstance = _getDndContextValue2[1]; // 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 */ React.useEffect(function () { if (isGlobalInstance) { refCount++; } return function () { if (isGlobalInstance) { refCount--; if (refCount === 0) { var context = getGlobalContext(); context[instanceSymbol] = null; } } }; }, []); return React.createElement(_DndContext.DndContext.Provider, { value: manager }, children); }); exports.DndProvider = DndProvider; DndProvider.displayName = 'DndProvider'; function getDndContextValue(props) { if ('manager' in props) { var _manager = { dragDropManager: props.manager }; return [_manager, false]; } var manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode); var isGlobalInstance = !props.context; return [manager, isGlobalInstance]; } var instanceSymbol = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__'); function createSingletonDndContext(backend) { var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getGlobalContext(); var options = arguments.length > 2 ? arguments[2] : undefined; var debugMode = arguments.length > 3 ? arguments[3] : undefined; var ctx = context; if (!ctx[instanceSymbol]) { ctx[instanceSymbol] = (0, _DndContext.createDndContext)(backend, context, options, debugMode); } return ctx[instanceSymbol]; } function getGlobalContext() { return typeof global !== 'undefined' ? global : window; }dist/cjs/common/wrapConnectorHooks.js000064400000004410151676724530013763 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.wrapConnectorHooks = wrapConnectorHooks; var _react = require("react"); var _cloneWithRef = require("../utils/cloneWithRef"); 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; } var 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 ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.'); } function wrapHookToRecognizeElement(hook) { return function () { var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; // When passed a node, call the hook straight away. if (!(0, _react.isValidElement)(elementOrNode)) { var 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. var element = elementOrNode; throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly var ref = options ? function (node) { return hook(node, options); } : hook; return (0, _cloneWithRef.cloneWithRef)(element, ref); }; } function wrapConnectorHooks(hooks) { var wrappedHooks = {}; Object.keys(hooks).forEach(function (key) { var hook = hooks[key]; // ref objects should be passed straight through without wrapping if (key.endsWith('Ref')) { wrappedHooks[key] = hooks[key]; } else { var wrappedHook = wrapHookToRecognizeElement(hook); wrappedHooks[key] = function () { return wrappedHook; }; } }); return wrappedHooks; }dist/cjs/common/index.js000064400000001710151676724530011242 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _DndContext = require("./DndContext"); Object.keys(_DndContext).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DndContext[key]; } }); }); var _DndProvider = require("./DndProvider"); Object.keys(_DndProvider).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DndProvider[key]; } }); }); var _DragPreviewImage = require("./DragPreviewImage"); Object.keys(_DragPreviewImage).forEach(function (key) { if (key === "default" || key === "__esModule") return; Object.defineProperty(exports, key, { enumerable: true, get: function get() { return _DragPreviewImage[key]; } }); });dist/cjs/common/TargetConnector.js000064400000010320151676724530013231 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TargetConnector = void 0; var _shallowequal = require("@react-dnd/shallowequal"); var _wrapConnectorHooks = require("./wrapConnectorHooks"); var _isRef = require("../utils/isRef"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var TargetConnector = /*#__PURE__*/function () { function TargetConnector(backend) { var _this = this; _classCallCheck(this, TargetConnector); this.hooks = (0, _wrapConnectorHooks.wrapConnectorHooks)({ dropTarget: function dropTarget(node, options) { _this.clearDropTarget(); _this.dropTargetOptions = options; if ((0, _isRef.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; } _createClass(TargetConnector, [{ key: "reconnect", value: function reconnect() { // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange(); if (didChange) { this.disconnectDropTarget(); } var 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); } } }, { key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (newHandlerId === this.handlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didDropTargetChange", value: function didDropTargetChange() { return this.lastConnectedDropTarget !== this.dropTarget; } }, { key: "didOptionsChange", value: function didOptionsChange() { return !(0, _shallowequal.shallowEqual)(this.lastConnectedDropTargetOptions, this.dropTargetOptions); } }, { key: "disconnectDropTarget", value: function disconnectDropTarget() { if (this.unsubscribeDropTarget) { this.unsubscribeDropTarget(); this.unsubscribeDropTarget = undefined; } } }, { key: "clearDropTarget", value: function clearDropTarget() { this.dropTargetRef = null; this.dropTargetNode = null; } }, { key: "connectTarget", get: function get() { return this.dropTarget; } }, { key: "dropTargetOptions", get: function get() { return this.dropTargetOptionsInternal; }, set: function set(options) { this.dropTargetOptionsInternal = options; } }, { key: "dropTarget", get: function get() { return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current; } }]); return TargetConnector; }(); exports.TargetConnector = TargetConnector;dist/cjs/common/DndContext.js000064400000003716151676724530012215 0ustar00"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.createDndContext = createDndContext; exports.DndContext = void 0; var React = _interopRequireWildcard(require("react")); var _dndCore = require("dnd-core"); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /** * Create the React Context */ var DndContext = React.createContext({ dragDropManager: undefined }); /** * Creates the context object we're providing * @param backend * @param context */ exports.DndContext = DndContext; function createDndContext(backend, context, options, debugMode) { return { dragDropManager: (0, _dndCore.createDragDropManager)(backend, context, options, debugMode) }; }dist/cjs/common/DragPreviewImage.js000064400000004077151676724530013326 0ustar00"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.DragPreviewImage = void 0; var React = _interopRequireWildcard(require("react")); function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /* * A utility for rendering a drag preview image */ var DragPreviewImage = React.memo(function (_ref) { var connect = _ref.connect, src = _ref.src; React.useEffect(function () { if (typeof Image === 'undefined') return; var connected = false; var img = new Image(); img.src = src; img.onload = function () { connect(img); connected = true; }; return function () { if (connected) { connect(null); } }; }); return null; }); exports.DragPreviewImage = DragPreviewImage; DragPreviewImage.displayName = 'DragPreviewImage';dist/cjs/common/DragSourceMonitorImpl.js000064400000011760151676724530014371 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DragSourceMonitorImpl = void 0; var _invariant = require("@react-dnd/invariant"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var isCallingCanDrag = false; var isCallingIsDragging = false; var DragSourceMonitorImpl = /*#__PURE__*/function () { function DragSourceMonitorImpl(manager) { _classCallCheck(this, DragSourceMonitorImpl); this.sourceId = null; this.internalMonitor = manager.getMonitor(); } _createClass(DragSourceMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(sourceId) { this.sourceId = sourceId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.sourceId; } }, { key: "canDrag", value: function canDrag() { (0, _invariant.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; } } }, { key: "isDragging", value: function isDragging() { if (!this.sourceId) { return false; } (0, _invariant.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; } } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "isDraggingSource", value: function isDraggingSource(sourceId) { return this.internalMonitor.isDraggingSource(sourceId); } }, { key: "isOverTarget", value: function isOverTarget(targetId, options) { return this.internalMonitor.isOverTarget(targetId, options); } }, { key: "getTargetIds", value: function getTargetIds() { return this.internalMonitor.getTargetIds(); } }, { key: "isSourcePublic", value: function isSourcePublic() { return this.internalMonitor.isSourcePublic(); } }, { key: "getSourceId", value: function getSourceId() { return this.internalMonitor.getSourceId(); } }, { key: "subscribeToOffsetChange", value: function subscribeToOffsetChange(listener) { return this.internalMonitor.subscribeToOffsetChange(listener); } }, { key: "canDragSource", value: function canDragSource(sourceId) { return this.internalMonitor.canDragSource(sourceId); } }, { key: "canDropOnTarget", value: function canDropOnTarget(targetId) { return this.internalMonitor.canDropOnTarget(targetId); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DragSourceMonitorImpl; }(); exports.DragSourceMonitorImpl = DragSourceMonitorImpl;dist/cjs/common/registration.js000064400000001147151676724530012651 0ustar00"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerTarget = registerTarget; exports.registerSource = registerSource; function registerTarget(type, target, manager) { var registry = manager.getRegistry(); var targetId = registry.addTarget(type, target); return [targetId, function () { return registry.removeTarget(targetId); }]; } function registerSource(type, source, manager) { var registry = manager.getRegistry(); var sourceId = registry.addSource(type, source); return [sourceId, function () { return registry.removeSource(sourceId); }]; }dist/esm/decorators/utils.js000064400000003113151676724530012154 0ustar00export function getDecoratedComponent(instanceRef) { var currentRef = instanceRef.current; if (currentRef == null) { return null; } else if (currentRef.decoratedRef) { // go through the private field in decorateHandler to avoid the invariant hit return currentRef.decoratedRef.current; } else { return currentRef; } } export function isClassComponent(Component) { return Component && Component.prototype && typeof Component.prototype.render === 'function'; } export function isRefForwardingComponent(C) { var _item$$$typeof; var item = C; return (item === null || item === void 0 ? void 0 : (_item$$$typeof = item.$$typeof) === null || _item$$$typeof === void 0 ? void 0 : _item$$$typeof.toString()) === 'Symbol(react.forward_ref)'; } export function isRefable(C) { return isClassComponent(C) || isRefForwardingComponent(C); } export function checkDecoratorArguments(functionName, signature) { if (process.env.NODE_ENV !== 'production') { for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) { var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2]; if (arg && arg.prototype && arg.prototype.render) { // eslint-disable-next-line no-console console.error('You seem to be applying the arguments in the wrong order. ' + "It should be ".concat(functionName, "(").concat(signature, ")(Component), not the other way around. ") + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order'); return; } } } }dist/esm/decorators/DragLayer.js000064400000021062151676724530012671 0ustar00function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } import * as React from 'react'; import { shallowEqual } from '@react-dnd/shallowequal'; import hoistStatics from 'hoist-non-react-statics'; import { invariant } from '@react-dnd/invariant'; import { DndContext } from '../common/DndContext'; import { isPlainObject } from '../utils/js_utils'; import { isRefable, checkDecoratorArguments } from './utils'; export function DragLayer(collect) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; checkDecoratorArguments('DragLayer', 'collect[, options]', collect, options); invariant(typeof collect === 'function', 'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ', 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', collect); invariant(isPlainObject(options), 'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. ' + 'Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer', options); return function decorateLayer(DecoratedComponent) { var Decorated = DecoratedComponent; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua; var displayName = Decorated.displayName || Decorated.name || 'Component'; var DragLayerContainer = /** @class */ function () { var DragLayerContainer = /*#__PURE__*/function (_React$Component) { _inherits(DragLayerContainer, _React$Component); var _super = _createSuper(DragLayerContainer); function DragLayerContainer() { var _this; _classCallCheck(this, DragLayerContainer); _this = _super.apply(this, arguments); _this.isCurrentlyMounted = false; _this.ref = React.createRef(); _this.handleChange = function () { if (!_this.isCurrentlyMounted) { return; } var nextState = _this.getCurrentState(); if (!shallowEqual(nextState, _this.state)) { _this.setState(nextState); } }; return _this; } _createClass(DragLayerContainer, [{ key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { invariant(this.ref.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.ref.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.isCurrentlyMounted = true; this.handleChange(); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.isCurrentlyMounted = false; if (this.unsubscribeFromOffsetChange) { this.unsubscribeFromOffsetChange(); this.unsubscribeFromOffsetChange = undefined; } if (this.unsubscribeFromStateChange) { this.unsubscribeFromStateChange(); this.unsubscribeFromStateChange = undefined; } } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(DndContext.Consumer, null, function (_ref) { var dragDropManager = _ref.dragDropManager; if (dragDropManager === undefined) { return null; } _this2.receiveDragDropManager(dragDropManager); // Let componentDidMount fire to initialize the collected state if (!_this2.isCurrentlyMounted) { return null; } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.state, { ref: isRefable(Decorated) ? _this2.ref : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } this.manager = dragDropManager; invariant(_typeof(dragDropManager) === 'object', 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); var monitor = this.manager.getMonitor(); this.unsubscribeFromOffsetChange = monitor.subscribeToOffsetChange(this.handleChange); this.unsubscribeFromStateChange = monitor.subscribeToStateChange(this.handleChange); } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.manager) { return {}; } var monitor = this.manager.getMonitor(); return collect(monitor, this.props); } }]); return DragLayerContainer; }(React.Component); DragLayerContainer.displayName = "DragLayer(".concat(displayName, ")"); DragLayerContainer.DecoratedComponent = DecoratedComponent; return DragLayerContainer; }(); return hoistStatics(DragLayerContainer, DecoratedComponent); }; }dist/esm/decorators/DropTarget.js000064400000005015151676724530013072 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { registerTarget } from '../common/registration'; import { isValidType } from '../utils/isValidType'; import { TargetConnector } from '../common/TargetConnector'; import { DropTargetMonitorImpl } from '../common/DropTargetMonitorImpl'; import { checkDecoratorArguments } from './utils'; import { decorateHandler } from './decorateHandler'; import { createTargetFactory } from './createTargetFactory'; export function DropTarget(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { invariant(isValidType(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type); getType = function getType() { return type; }; } invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec); var createTarget = createTargetFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect); return function decorateTarget(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DropTarget', createHandler: createTarget, registerHandler: registerTarget, createMonitor: function createMonitor(manager) { return new DropTargetMonitorImpl(manager); }, createConnector: function createConnector(backend) { return new TargetConnector(backend); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; }dist/esm/decorators/decorateHandler.js000064400000027517151676724530014116 0ustar00function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } import * as React from 'react'; import { shallowEqual } from '@react-dnd/shallowequal'; import { invariant } from '@react-dnd/invariant'; import hoistStatics from 'hoist-non-react-statics'; import { DndContext } from '../common/DndContext'; import { isPlainObject } from '../utils/js_utils'; import { Disposable, CompositeDisposable, SerialDisposable } from './disposables'; import { isRefable } from './utils'; export function decorateHandler(_ref) { var DecoratedComponent = _ref.DecoratedComponent, createHandler = _ref.createHandler, createMonitor = _ref.createMonitor, createConnector = _ref.createConnector, registerHandler = _ref.registerHandler, containerDisplayName = _ref.containerDisplayName, getType = _ref.getType, collect = _ref.collect, options = _ref.options; var _options$arePropsEqua = options.arePropsEqual, arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua; var Decorated = DecoratedComponent; var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component'; var DragDropContainer = /** @class */ function () { var DragDropContainer = /*#__PURE__*/function (_React$Component) { _inherits(DragDropContainer, _React$Component); var _super = _createSuper(DragDropContainer); function DragDropContainer(props) { var _this; _classCallCheck(this, DragDropContainer); _this = _super.call(this, props); _this.decoratedRef = React.createRef(); _this.handleChange = function () { var nextState = _this.getCurrentState(); if (!shallowEqual(nextState, _this.state)) { _this.setState(nextState); } }; _this.disposable = new SerialDisposable(); _this.receiveProps(props); _this.dispose(); return _this; } _createClass(DragDropContainer, [{ key: "getHandlerId", value: function getHandlerId() { return this.handlerId; } }, { key: "getDecoratedComponentInstance", value: function getDecoratedComponentInstance() { invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()'); return this.decoratedRef.current; } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState) { return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state); } }, { key: "componentDidMount", value: function componentDidMount() { this.disposable = new SerialDisposable(); this.currentType = undefined; this.receiveProps(this.props); this.handleChange(); } }, { key: "componentDidUpdate", value: function componentDidUpdate(prevProps) { if (!arePropsEqual(this.props, prevProps)) { this.receiveProps(this.props); this.handleChange(); } } }, { key: "componentWillUnmount", value: function componentWillUnmount() { this.dispose(); } }, { key: "receiveProps", value: function receiveProps(props) { if (!this.handler) { return; } this.handler.receiveProps(props); this.receiveType(getType(props)); } }, { key: "receiveType", value: function receiveType(type) { if (!this.handlerMonitor || !this.manager || !this.handlerConnector) { return; } if (type === this.currentType) { return; } this.currentType = type; var _registerHandler = registerHandler(type, this.handler, this.manager), _registerHandler2 = _slicedToArray(_registerHandler, 2), handlerId = _registerHandler2[0], unregister = _registerHandler2[1]; this.handlerId = handlerId; this.handlerMonitor.receiveHandlerId(handlerId); this.handlerConnector.receiveHandlerId(handlerId); var globalMonitor = this.manager.getMonitor(); var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, { handlerIds: [handlerId] }); this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister))); } }, { key: "dispose", value: function dispose() { this.disposable.dispose(); if (this.handlerConnector) { this.handlerConnector.receiveHandlerId(null); } } }, { key: "getCurrentState", value: function getCurrentState() { if (!this.handlerConnector) { return {}; } var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props); if (process.env.NODE_ENV !== 'production') { invariant(isPlainObject(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState); } return nextState; } }, { key: "render", value: function render() { var _this2 = this; return React.createElement(DndContext.Consumer, null, function (_ref2) { var dragDropManager = _ref2.dragDropManager; _this2.receiveDragDropManager(dragDropManager); if (typeof requestAnimationFrame !== 'undefined') { requestAnimationFrame(function () { var _this2$handlerConnect; return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect(); }); } return React.createElement(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), { // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component. ref: isRefable(Decorated) ? _this2.decoratedRef : null })); }); } }, { key: "receiveDragDropManager", value: function receiveDragDropManager(dragDropManager) { if (this.manager !== undefined) { return; } invariant(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName); if (dragDropManager === undefined) { return; } this.manager = dragDropManager; this.handlerMonitor = createMonitor(dragDropManager); this.handlerConnector = createConnector(dragDropManager.getBackend()); this.handler = createHandler(this.handlerMonitor, this.decoratedRef); } }]); return DragDropContainer; }(React.Component); DragDropContainer.DecoratedComponent = DecoratedComponent; DragDropContainer.displayName = "".concat(containerDisplayName, "(").concat(displayName, ")"); return DragDropContainer; }(); return hoistStatics(DragDropContainer, DecoratedComponent); }dist/esm/decorators/index.js000064400000000166151676724530012130 0ustar00export * from './DragSource'; export * from './DropTarget'; export * from './DragLayer'; export * from './interfaces';dist/esm/decorators/DragSource.js000064400000005303151676724530013055 0ustar00import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { checkDecoratorArguments } from './utils'; import { decorateHandler } from './decorateHandler'; import { registerSource } from '../common/registration'; import { DragSourceMonitorImpl } from '../common/DragSourceMonitorImpl'; import { SourceConnector } from '../common/SourceConnector'; import { isValidType } from '../utils/isValidType'; import { createSourceFactory } from './createSourceFactory'; /** * Decorates a component as a dragsource * @param type The dragsource type * @param spec The drag source specification * @param collect The props collector function * @param options DnD options */ export function DragSource(type, spec, collect) { var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options); var getType = type; if (typeof type !== 'function') { invariant(isValidType(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type); getType = function getType() { return type; }; } invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec); var createSource = createSourceFactory(spec); invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect); return function decorateSource(DecoratedComponent) { return decorateHandler({ containerDisplayName: 'DragSource', createHandler: createSource, registerHandler: registerSource, createConnector: function createConnector(backend) { return new SourceConnector(backend); }, createMonitor: function createMonitor(manager) { return new DragSourceMonitorImpl(manager); }, DecoratedComponent: DecoratedComponent, getType: getType, collect: collect, options: options }); }; }dist/esm/decorators/createSourceFactory.js000064400000007264151676724530015003 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { getDecoratedComponent } from './utils'; var ALLOWED_SPEC_METHODS = ['canDrag', 'beginDrag', 'isDragging', 'endDrag']; var REQUIRED_SPEC_METHODS = ['beginDrag']; var SourceImpl = /*#__PURE__*/function () { function SourceImpl(spec, monitor, ref) { var _this = this; _classCallCheck(this, SourceImpl); this.props = null; this.beginDrag = function () { if (!_this.props) { return; } var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current); if (process.env.NODE_ENV !== 'production') { invariant(isPlainObject(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item); } return item; }; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass(SourceImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "canDrag", value: function canDrag() { if (!this.props) { return false; } if (!this.spec.canDrag) { return true; } return this.spec.canDrag(this.props, this.monitor); } }, { key: "isDragging", value: function isDragging(globalMonitor, sourceId) { if (!this.props) { return false; } if (!this.spec.isDragging) { return sourceId === globalMonitor.getSourceId(); } return this.spec.isDragging(this.props, this.monitor); } }, { key: "endDrag", value: function endDrag() { if (!this.props) { return; } if (!this.spec.endDrag) { return; } this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref)); } }]); return SourceImpl; }(); export function createSourceFactory(spec) { Object.keys(spec).forEach(function (key) { invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); REQUIRED_SPEC_METHODS.forEach(function (key) { invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]); }); return function createSource(monitor, ref) { return new SourceImpl(spec, monitor, ref); }; }dist/esm/decorators/createTargetFactory.js000064400000006125151676724530014764 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { invariant } from '@react-dnd/invariant'; import { isPlainObject } from '../utils/js_utils'; import { getDecoratedComponent } from './utils'; var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop']; var TargetImpl = /*#__PURE__*/function () { function TargetImpl(spec, monitor, ref) { _classCallCheck(this, TargetImpl); this.props = null; this.spec = spec; this.monitor = monitor; this.ref = ref; } _createClass(TargetImpl, [{ key: "receiveProps", value: function receiveProps(props) { this.props = props; } }, { key: "receiveMonitor", value: function receiveMonitor(monitor) { this.monitor = monitor; } }, { key: "canDrop", value: function canDrop() { if (!this.spec.canDrop) { return true; } return this.spec.canDrop(this.props, this.monitor); } }, { key: "hover", value: function hover() { if (!this.spec.hover || !this.props) { return; } this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref)); } }, { key: "drop", value: function drop() { if (!this.spec.drop) { return undefined; } var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current); if (process.env.NODE_ENV !== 'production') { invariant(typeof dropResult === 'undefined' || isPlainObject(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult); } return dropResult; } }]); return TargetImpl; }(); export function createTargetFactory(spec) { Object.keys(spec).forEach(function (key) { invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS.join(', '), key); invariant(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]); }); return function createTarget(monitor, ref) { return new TargetImpl(spec, monitor, ref); }; }dist/esm/decorators/disposables.js000064400000014612151676724530013332 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { isFunction, noop } from '../utils/js_utils'; /** * Provides a set of static methods for creating Disposables. * @param {Function} action Action to run during the first call to dispose. * The action is guaranteed to be run at most once. */ var Disposable = /** @class */ function () { var Disposable = /*#__PURE__*/function () { function Disposable(action) { _classCallCheck(this, Disposable); this.isDisposed = false; this.action = isFunction(action) ? action : noop; } /** * Validates whether the given object is a disposable * @param {Object} Object to test whether it has a dispose method * @returns {Boolean} true if a disposable object, else false. */ _createClass(Disposable, [{ key: "dispose", /** Performs the task of cleaning up resources. */ value: function dispose() { if (!this.isDisposed) { this.action(); this.isDisposed = true; } } }], [{ key: "isDisposable", value: function isDisposable(d) { return Boolean(d && isFunction(d.dispose)); } }, { key: "_fixup", value: function _fixup(result) { return Disposable.isDisposable(result) ? result : Disposable.empty; } /** * Creates a disposable object that invokes the specified action when disposed. * @param {Function} dispose Action to run during the first call to dispose. * The action is guaranteed to be run at most once. * @return {Disposable} The disposable object that runs the given action upon disposal. */ }, { key: "create", value: function create(action) { return new Disposable(action); } }]); return Disposable; }(); /** * Gets the disposable that does nothing when disposed. */ Disposable.empty = { dispose: noop }; return Disposable; }(); export { Disposable }; /** * Represents a group of disposable resources that are disposed together. * @constructor */ export var CompositeDisposable = /*#__PURE__*/function () { function CompositeDisposable() { _classCallCheck(this, CompositeDisposable); this.isDisposed = false; for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) { disposables[_key] = arguments[_key]; } this.disposables = disposables; } /** * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. * @param {Any} item Disposable to add. */ _createClass(CompositeDisposable, [{ key: "add", value: function add(item) { if (this.isDisposed) { item.dispose(); } else { this.disposables.push(item); } } /** * Removes and disposes the first occurrence of a disposable from the CompositeDisposable. * @param {Any} item Disposable to remove. * @returns {Boolean} true if found; false otherwise. */ }, { key: "remove", value: function remove(item) { var shouldDispose = false; if (!this.isDisposed) { var idx = this.disposables.indexOf(item); if (idx !== -1) { shouldDispose = true; this.disposables.splice(idx, 1); item.dispose(); } } return shouldDispose; } /** * Disposes all disposables in the group and removes them from the group but * does not dispose the CompositeDisposable. */ }, { key: "clear", value: function clear() { if (!this.isDisposed) { var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i = 0; _i < len; _i++) { currentDisposables[_i].dispose(); } } } /** * Disposes all disposables in the group and removes them from the group. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var len = this.disposables.length; var currentDisposables = new Array(len); for (var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; } this.disposables = []; for (var _i2 = 0; _i2 < len; _i2++) { currentDisposables[_i2].dispose(); } } } }]); return CompositeDisposable; }(); /** * Represents a disposable resource whose underlying disposable resource can * be replaced by another disposable resource, causing automatic disposal of * the previous underlying disposable resource. */ export var SerialDisposable = /*#__PURE__*/function () { function SerialDisposable() { _classCallCheck(this, SerialDisposable); this.isDisposed = false; } /** * Gets the underlying disposable. * @returns {Any} the underlying disposable. */ _createClass(SerialDisposable, [{ key: "getDisposable", value: function getDisposable() { return this.current; } }, { key: "setDisposable", value: function setDisposable(value) { var shouldDispose = this.isDisposed; if (!shouldDispose) { var old = this.current; this.current = value; if (old) { old.dispose(); } } if (shouldDispose && value) { value.dispose(); } } /** Performs the task of cleaning up resources. */ }, { key: "dispose", value: function dispose() { if (!this.isDisposed) { this.isDisposed = true; var old = this.current; this.current = undefined; if (old) { old.dispose(); } } } }]); return SerialDisposable; }();dist/esm/decorators/interfaces.js000064400000000000151676724530013127 0ustar00dist/esm/utils/isRef.js000064400000001101151676724530011052 0ustar00function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } export function isRef(obj) { return (// eslint-disable-next-line no-prototype-builtins obj !== null && _typeof(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current') ); }dist/esm/utils/cloneWithRef.js000064400000001624151676724530012405 0ustar00import { cloneElement } from 'react'; import { invariant } from '@react-dnd/invariant'; function setRef(ref, node) { if (typeof ref === 'function') { ref(node); } else { ref.current = node; } } export function cloneWithRef(element, newRef) { var 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://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute'); 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: function ref(node) { setRef(previousRef, node); setRef(newRef, node); } }); } }dist/esm/utils/js_utils.js000064400000001654151676724530011653 0ustar00function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } // cheap lodash replacements export function isFunction(input) { return typeof input === 'function'; } export function noop() {// noop } function isObjectLike(input) { return _typeof(input) === 'object' && input !== null; } export function isPlainObject(input) { if (!isObjectLike(input)) { return false; } if (Object.getPrototypeOf(input) === null) { return true; } var proto = input; while (Object.getPrototypeOf(proto) !== null) { proto = Object.getPrototypeOf(proto); } return Object.getPrototypeOf(input) === proto; }dist/esm/utils/isValidType.js000064400000001131151676724530012242 0ustar00function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } export function isValidType(type, allowArray) { return typeof type === 'string' || _typeof(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) { return isValidType(t, false); }); }dist/esm/index.js000064400000000156151676724530007762 0ustar00export * from './common'; export * from './interfaces'; export * from './hooks'; export * from './decorators';dist/esm/interfaces/hooksApi.js000064400000000000151676724530012537 0ustar00dist/esm/interfaces/monitors.js000064400000000000151676724530012634 0ustar00dist/esm/interfaces/index.js000064400000000160151676724530012100 0ustar00export * from './monitors'; export * from './hooksApi'; export * from './options'; export * from './connectors';dist/esm/interfaces/connectors.js000064400000000000151676724530013137 0ustar00dist/esm/interfaces/options.js000064400000000000151676724530012455 0ustar00dist/esm/hooks/useDrop.js000064400000005317151676724530011423 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { useRef, useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { useMonitorOutput } from './internal/useMonitorOutput'; import { useIsomorphicLayoutEffect } from './internal/useIsomorphicLayoutEffect'; import { useDropHandler, useDropTargetMonitor } from './internal/drop'; /** * useDropTarget Hook * @param spec The drop target specification */ export function useDrop(spec) { var specRef = useRef(spec); specRef.current = spec; invariant(spec.accept != null, 'accept must be defined'); var _useDropTargetMonitor = useDropTargetMonitor(), _useDropTargetMonitor2 = _slicedToArray(_useDropTargetMonitor, 2), monitor = _useDropTargetMonitor2[0], connector = _useDropTargetMonitor2[1]; useDropHandler(specRef, monitor, connector); var result = useMonitorOutput(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDropTarget = useMemo(function () { return connector.hooks.dropTarget(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dropTargetOptions = spec.options || null; connector.reconnect(); }, [spec.options]); return [result, connectDropTarget]; }dist/esm/hooks/internal/drag.js000064400000010434151676724530012527 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } import { useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { registerSource } from '../../common/registration'; import { useDragDropManager } from '../useDragDropManager'; import { DragSourceMonitorImpl } from '../../common/DragSourceMonitorImpl'; import { SourceConnector } from '../../common/SourceConnector'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; export function useDragSourceMonitor() { var manager = useDragDropManager(); var monitor = useMemo(function () { return new DragSourceMonitorImpl(manager); }, [manager]); var connector = useMemo(function () { return new SourceConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } export function useDragHandler(spec, monitor, connector) { var manager = useDragDropManager(); var handler = useMemo(function () { return { beginDrag: function beginDrag() { var _spec$current = spec.current, begin = _spec$current.begin, item = _spec$current.item; if (begin) { var beginResult = begin(monitor); invariant(beginResult == null || _typeof(beginResult) === 'object', 'dragSpec.begin() must either return an object, undefined, or null'); return beginResult || item || {}; } return item || {}; }, canDrag: function canDrag() { if (typeof spec.current.canDrag === 'boolean') { return spec.current.canDrag; } else if (typeof spec.current.canDrag === 'function') { return spec.current.canDrag(monitor); } else { return true; } }, isDragging: function isDragging(globalMonitor, target) { var isDragging = spec.current.isDragging; return isDragging ? isDragging(monitor) : target === globalMonitor.getSourceId(); }, endDrag: function endDrag() { var end = spec.current.end; if (end) { end(monitor.getItem(), monitor); } connector.reconnect(); } }; }, []); useIsomorphicLayoutEffect(function registerHandler() { var _registerSource = registerSource(spec.current.item.type, handler, manager), _registerSource2 = _slicedToArray(_registerSource, 2), handlerId = _registerSource2[0], unregister = _registerSource2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, []); }dist/esm/hooks/internal/useIsomorphicLayoutEffect.js000064400000000320151676724530016747 0ustar00import { useLayoutEffect, useEffect } from 'react'; // suppress the useLayoutEffect warning on server side. export var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;dist/esm/hooks/internal/useMonitorOutput.js000064400000004275151676724530015205 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; import { useCollector } from './useCollector'; export function useMonitorOutput(monitor, collect, onCollect) { var _useCollector = useCollector(monitor, collect, onCollect), _useCollector2 = _slicedToArray(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; useIsomorphicLayoutEffect(function subscribeToMonitorStateChange() { var handlerId = monitor.getHandlerId(); if (handlerId == null) { return undefined; } return monitor.subscribeToStateChange(updateCollected, { handlerIds: [handlerId] }); }, [monitor, updateCollected]); return collected; }dist/esm/hooks/internal/drop.js000064400000006316151676724530012562 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { useMemo } from 'react'; import { registerTarget } from '../../common/registration'; import { useDragDropManager } from '../useDragDropManager'; import { TargetConnector } from '../../common/TargetConnector'; import { DropTargetMonitorImpl } from '../../common/DropTargetMonitorImpl'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; export function useDropTargetMonitor() { var manager = useDragDropManager(); var monitor = useMemo(function () { return new DropTargetMonitorImpl(manager); }, [manager]); var connector = useMemo(function () { return new TargetConnector(manager.getBackend()); }, [manager]); return [monitor, connector]; } export function useDropHandler(spec, monitor, connector) { var manager = useDragDropManager(); var handler = useMemo(function () { return { canDrop: function canDrop() { var canDrop = spec.current.canDrop; return canDrop ? canDrop(monitor.getItem(), monitor) : true; }, hover: function hover() { var hover = spec.current.hover; if (hover) { hover(monitor.getItem(), monitor); } }, drop: function drop() { var drop = spec.current.drop; if (drop) { return drop(monitor.getItem(), monitor); } } }; }, [monitor]); useIsomorphicLayoutEffect(function registerHandler() { var _registerTarget = registerTarget(spec.current.accept, handler, manager), _registerTarget2 = _slicedToArray(_registerTarget, 2), handlerId = _registerTarget2[0], unregister = _registerTarget2[1]; monitor.receiveHandlerId(handlerId); connector.receiveHandlerId(handlerId); return unregister; }, [monitor, connector]); }dist/esm/hooks/internal/useCollector.js000064400000005015151676724530014254 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { shallowEqual } from '@react-dnd/shallowequal'; import { useState, useCallback } from 'react'; import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'; /** * * @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) { var _useState = useState(function () { return collect(monitor); }), _useState2 = _slicedToArray(_useState, 2), collected = _useState2[0], setCollected = _useState2[1]; var updateCollected = useCallback(function () { var nextValue = collect(monitor); if (!shallowEqual(collected, nextValue)) { setCollected(nextValue); if (onUpdate) { onUpdate(); } } }, [collected, monitor, onUpdate]); // update the collected properties after the first render // and the components are attached to dnd-core useIsomorphicLayoutEffect(updateCollected, []); return [collected, updateCollected]; }dist/esm/hooks/index.js000064400000000173151676724530011104 0ustar00export * from './useDrag'; export * from './useDrop'; export * from './useDragLayer'; export * from './useDragDropManager';dist/esm/hooks/useDrag.js000064400000006164151676724530011375 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { useRef, useMemo } from 'react'; import { invariant } from '@react-dnd/invariant'; import { useMonitorOutput } from './internal/useMonitorOutput'; import { useIsomorphicLayoutEffect } from './internal/useIsomorphicLayoutEffect'; import { useDragSourceMonitor, useDragHandler } from './internal/drag'; /** * useDragSource hook * @param sourceSpec The drag source specification * */ export function useDrag(spec) { var specRef = useRef(spec); specRef.current = spec; // TODO: wire options into createSourceConnector invariant(spec.item != null, 'item must be defined'); invariant(spec.item.type != null, 'item type must be defined'); var _useDragSourceMonitor = useDragSourceMonitor(), _useDragSourceMonitor2 = _slicedToArray(_useDragSourceMonitor, 2), monitor = _useDragSourceMonitor2[0], connector = _useDragSourceMonitor2[1]; useDragHandler(specRef, monitor, connector); var result = useMonitorOutput(monitor, specRef.current.collect || function () { return {}; }, function () { return connector.reconnect(); }); var connectDragSource = useMemo(function () { return connector.hooks.dragSource(); }, [connector]); var connectDragPreview = useMemo(function () { return connector.hooks.dragPreview(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dragSourceOptions = specRef.current.options || null; connector.reconnect(); }, [connector]); useIsomorphicLayoutEffect(function () { connector.dragPreviewOptions = specRef.current.previewOptions || null; connector.reconnect(); }, [connector]); return [result, connectDragSource, connectDragPreview]; }dist/esm/hooks/useDragLayer.js000064400000004342151676724530012366 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } import { useEffect } from 'react'; import { useDragDropManager } from './useDragDropManager'; import { useCollector } from './internal/useCollector'; /** * useDragLayer Hook * @param collector The property collector */ export function useDragLayer(collect) { var dragDropManager = useDragDropManager(); var monitor = dragDropManager.getMonitor(); var _useCollector = useCollector(monitor, collect), _useCollector2 = _slicedToArray(_useCollector, 2), collected = _useCollector2[0], updateCollected = _useCollector2[1]; useEffect(function () { return monitor.subscribeToOffsetChange(updateCollected); }); useEffect(function () { return monitor.subscribeToStateChange(updateCollected); }); return collected; }dist/esm/hooks/useDragDropManager.js000064400000000661151676724530013511 0ustar00import { useContext } from 'react'; import { invariant } from '@react-dnd/invariant'; import { DndContext } from '../common/DndContext'; /** * A hook to retrieve the DragDropManager from Context */ export function useDragDropManager() { var _useContext = useContext(DndContext), dragDropManager = _useContext.dragDropManager; invariant(dragDropManager != null, 'Expected drag drop context'); return dragDropManager; }dist/esm/common/SourceConnector.js000064400000015435151676724530013264 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { wrapConnectorHooks } from './wrapConnectorHooks'; import { isRef } from '../utils/isRef'; import { shallowEqual } from '@react-dnd/shallowequal'; export var SourceConnector = /*#__PURE__*/function () { function SourceConnector(backend) { var _this = this; _classCallCheck(this, SourceConnector); this.hooks = wrapConnectorHooks({ dragSource: function dragSource(node, options) { _this.clearDragSource(); _this.dragSourceOptions = options || null; if (isRef(node)) { _this.dragSourceRef = node; } else { _this.dragSourceNode = node; } _this.reconnectDragSource(); }, dragPreview: function 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; } _createClass(SourceConnector, [{ key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (this.handlerId === newHandlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "reconnect", value: function reconnect() { this.reconnectDragSource(); this.reconnectDragPreview(); } }, { key: "reconnectDragSource", value: function reconnectDragSource() { var dragSource = this.dragSource; // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange(); if (didChange) { this.disconnectDragSource(); } if (!this.handlerId) { return; } if (!dragSource) { this.lastConnectedDragSource = dragSource; return; } if (didChange) { this.lastConnectedHandlerId = this.handlerId; this.lastConnectedDragSource = dragSource; this.lastConnectedDragSourceOptions = this.dragSourceOptions; this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions); } } }, { key: "reconnectDragPreview", value: function reconnectDragPreview() { var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe var didChange = 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); } } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didConnectedDragSourceChange", value: function didConnectedDragSourceChange() { return this.lastConnectedDragSource !== this.dragSource; } }, { key: "didConnectedDragPreviewChange", value: function didConnectedDragPreviewChange() { return this.lastConnectedDragPreview !== this.dragPreview; } }, { key: "didDragSourceOptionsChange", value: function didDragSourceOptionsChange() { return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions); } }, { key: "didDragPreviewOptionsChange", value: function didDragPreviewOptionsChange() { return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions); } }, { key: "disconnectDragSource", value: function disconnectDragSource() { if (this.dragSourceUnsubscribe) { this.dragSourceUnsubscribe(); this.dragSourceUnsubscribe = undefined; } } }, { key: "disconnectDragPreview", value: function disconnectDragPreview() { if (this.dragPreviewUnsubscribe) { this.dragPreviewUnsubscribe(); this.dragPreviewUnsubscribe = undefined; this.dragPreviewNode = null; this.dragPreviewRef = null; } } }, { key: "clearDragSource", value: function clearDragSource() { this.dragSourceNode = null; this.dragSourceRef = null; } }, { key: "clearDragPreview", value: function clearDragPreview() { this.dragPreviewNode = null; this.dragPreviewRef = null; } }, { key: "connectTarget", get: function get() { return this.dragSource; } }, { key: "dragSourceOptions", get: function get() { return this.dragSourceOptionsInternal; }, set: function set(options) { this.dragSourceOptionsInternal = options; } }, { key: "dragPreviewOptions", get: function get() { return this.dragPreviewOptionsInternal; }, set: function set(options) { this.dragPreviewOptionsInternal = options; } }, { key: "dragSource", get: function get() { return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current; } }, { key: "dragPreview", get: function get() { return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current; } }]); return SourceConnector; }();dist/esm/common/DropTargetMonitorImpl.js000064400000007123151676724530014411 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { invariant } from '@react-dnd/invariant'; var isCallingCanDrop = false; export var DropTargetMonitorImpl = /*#__PURE__*/function () { function DropTargetMonitorImpl(manager) { _classCallCheck(this, DropTargetMonitorImpl); this.targetId = null; this.internalMonitor = manager.getMonitor(); } _createClass(DropTargetMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(targetId) { this.targetId = targetId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.targetId; } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "canDrop", value: function 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; } } }, { key: "isOver", value: function isOver(options) { if (!this.targetId) { return false; } return this.internalMonitor.isOverTarget(this.targetId, options); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DropTargetMonitorImpl; }();dist/esm/common/DndProvider.js000064400000010612151676724530012361 0ustar00function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 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 * as React from 'react'; import { memo } from 'react'; import { DndContext, createDndContext } from './DndContext'; var refCount = 0; /** * A React component that provides the React-DnD context */ export var DndProvider = memo(function (_ref) { var children = _ref.children, props = _objectWithoutProperties(_ref, ["children"]); var _getDndContextValue = getDndContextValue(props), _getDndContextValue2 = _slicedToArray(_getDndContextValue, 2), manager = _getDndContextValue2[0], isGlobalInstance = _getDndContextValue2[1]; // 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 */ React.useEffect(function () { if (isGlobalInstance) { refCount++; } return function () { if (isGlobalInstance) { refCount--; if (refCount === 0) { var context = getGlobalContext(); context[instanceSymbol] = null; } } }; }, []); return React.createElement(DndContext.Provider, { value: manager }, children); }); DndProvider.displayName = 'DndProvider'; function getDndContextValue(props) { if ('manager' in props) { var _manager = { dragDropManager: props.manager }; return [_manager, false]; } var manager = createSingletonDndContext(props.backend, props.context, props.options, props.debugMode); var isGlobalInstance = !props.context; return [manager, isGlobalInstance]; } var instanceSymbol = Symbol.for('__REACT_DND_CONTEXT_INSTANCE__'); function createSingletonDndContext(backend) { var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getGlobalContext(); var options = arguments.length > 2 ? arguments[2] : undefined; var debugMode = arguments.length > 3 ? arguments[3] : undefined; var ctx = context; if (!ctx[instanceSymbol]) { ctx[instanceSymbol] = createDndContext(backend, context, options, debugMode); } return ctx[instanceSymbol]; } function getGlobalContext() { return typeof global !== 'undefined' ? global : window; }dist/esm/common/wrapConnectorHooks.js000064400000004166151676724530014000 0ustar00import { isValidElement } from 'react'; import { cloneWithRef } from '../utils/cloneWithRef'; 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; } var 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 ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.'); } function wrapHookToRecognizeElement(hook) { return function () { var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; // When passed a node, call the hook straight away. if (!isValidElement(elementOrNode)) { var 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. var element = elementOrNode; throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly var ref = options ? function (node) { return hook(node, options); } : hook; return cloneWithRef(element, ref); }; } export function wrapConnectorHooks(hooks) { var wrappedHooks = {}; Object.keys(hooks).forEach(function (key) { var hook = hooks[key]; // ref objects should be passed straight through without wrapping if (key.endsWith('Ref')) { wrappedHooks[key] = hooks[key]; } else { var wrappedHook = wrapHookToRecognizeElement(hook); wrappedHooks[key] = function () { return wrappedHook; }; } }); return wrappedHooks; }dist/esm/common/index.js000064400000000140151676724530011243 0ustar00export * from './DndContext'; export * from './DndProvider'; export * from './DragPreviewImage';dist/esm/common/TargetConnector.js000064400000007775151676724530013262 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { shallowEqual } from '@react-dnd/shallowequal'; import { wrapConnectorHooks } from './wrapConnectorHooks'; import { isRef } from '../utils/isRef'; export var TargetConnector = /*#__PURE__*/function () { function TargetConnector(backend) { var _this = this; _classCallCheck(this, TargetConnector); this.hooks = wrapConnectorHooks({ dropTarget: function 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; } _createClass(TargetConnector, [{ key: "reconnect", value: function reconnect() { // if nothing has changed then don't resubscribe var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange(); if (didChange) { this.disconnectDropTarget(); } var 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); } } }, { key: "receiveHandlerId", value: function receiveHandlerId(newHandlerId) { if (newHandlerId === this.handlerId) { return; } this.handlerId = newHandlerId; this.reconnect(); } }, { key: "didHandlerIdChange", value: function didHandlerIdChange() { return this.lastConnectedHandlerId !== this.handlerId; } }, { key: "didDropTargetChange", value: function didDropTargetChange() { return this.lastConnectedDropTarget !== this.dropTarget; } }, { key: "didOptionsChange", value: function didOptionsChange() { return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions); } }, { key: "disconnectDropTarget", value: function disconnectDropTarget() { if (this.unsubscribeDropTarget) { this.unsubscribeDropTarget(); this.unsubscribeDropTarget = undefined; } } }, { key: "clearDropTarget", value: function clearDropTarget() { this.dropTargetRef = null; this.dropTargetNode = null; } }, { key: "connectTarget", get: function get() { return this.dropTarget; } }, { key: "dropTargetOptions", get: function get() { return this.dropTargetOptionsInternal; }, set: function set(options) { this.dropTargetOptionsInternal = options; } }, { key: "dropTarget", get: function get() { return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current; } }]); return TargetConnector; }();dist/esm/common/DndContext.js000064400000000714151676724530012215 0ustar00import * as React from 'react'; import { createDragDropManager } from 'dnd-core'; /** * Create the React Context */ export var DndContext = React.createContext({ dragDropManager: undefined }); /** * Creates the context object we're providing * @param backend * @param context */ export function createDndContext(backend, context, options, debugMode) { return { dragDropManager: createDragDropManager(backend, context, options, debugMode) }; }dist/esm/common/DragPreviewImage.js000064400000001123151676724530013320 0ustar00import * as React from 'react'; /* * A utility for rendering a drag preview image */ export var DragPreviewImage = React.memo(function (_ref) { var connect = _ref.connect, src = _ref.src; React.useEffect(function () { if (typeof Image === 'undefined') return; var connected = false; var img = new Image(); img.src = src; img.onload = function () { connect(img); connected = true; }; return function () { if (connected) { connect(null); } }; }); return null; }); DragPreviewImage.displayName = 'DragPreviewImage';dist/esm/common/DragSourceMonitorImpl.js000064400000011444151676724530014375 0ustar00function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } import { invariant } from '@react-dnd/invariant'; var isCallingCanDrag = false; var isCallingIsDragging = false; export var DragSourceMonitorImpl = /*#__PURE__*/function () { function DragSourceMonitorImpl(manager) { _classCallCheck(this, DragSourceMonitorImpl); this.sourceId = null; this.internalMonitor = manager.getMonitor(); } _createClass(DragSourceMonitorImpl, [{ key: "receiveHandlerId", value: function receiveHandlerId(sourceId) { this.sourceId = sourceId; } }, { key: "getHandlerId", value: function getHandlerId() { return this.sourceId; } }, { key: "canDrag", value: function 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; } } }, { key: "isDragging", value: function 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; } } }, { key: "subscribeToStateChange", value: function subscribeToStateChange(listener, options) { return this.internalMonitor.subscribeToStateChange(listener, options); } }, { key: "isDraggingSource", value: function isDraggingSource(sourceId) { return this.internalMonitor.isDraggingSource(sourceId); } }, { key: "isOverTarget", value: function isOverTarget(targetId, options) { return this.internalMonitor.isOverTarget(targetId, options); } }, { key: "getTargetIds", value: function getTargetIds() { return this.internalMonitor.getTargetIds(); } }, { key: "isSourcePublic", value: function isSourcePublic() { return this.internalMonitor.isSourcePublic(); } }, { key: "getSourceId", value: function getSourceId() { return this.internalMonitor.getSourceId(); } }, { key: "subscribeToOffsetChange", value: function subscribeToOffsetChange(listener) { return this.internalMonitor.subscribeToOffsetChange(listener); } }, { key: "canDragSource", value: function canDragSource(sourceId) { return this.internalMonitor.canDragSource(sourceId); } }, { key: "canDropOnTarget", value: function canDropOnTarget(targetId) { return this.internalMonitor.canDropOnTarget(targetId); } }, { key: "getItemType", value: function getItemType() { return this.internalMonitor.getItemType(); } }, { key: "getItem", value: function getItem() { return this.internalMonitor.getItem(); } }, { key: "getDropResult", value: function getDropResult() { return this.internalMonitor.getDropResult(); } }, { key: "didDrop", value: function didDrop() { return this.internalMonitor.didDrop(); } }, { key: "getInitialClientOffset", value: function getInitialClientOffset() { return this.internalMonitor.getInitialClientOffset(); } }, { key: "getInitialSourceClientOffset", value: function getInitialSourceClientOffset() { return this.internalMonitor.getInitialSourceClientOffset(); } }, { key: "getSourceClientOffset", value: function getSourceClientOffset() { return this.internalMonitor.getSourceClientOffset(); } }, { key: "getClientOffset", value: function getClientOffset() { return this.internalMonitor.getClientOffset(); } }, { key: "getDifferenceFromInitialOffset", value: function getDifferenceFromInitialOffset() { return this.internalMonitor.getDifferenceFromInitialOffset(); } }]); return DragSourceMonitorImpl; }();dist/esm/common/registration.js000064400000000721151676724530012653 0ustar00export function registerTarget(type, target, manager) { var registry = manager.getRegistry(); var targetId = registry.addTarget(type, target); return [targetId, function () { return registry.removeTarget(targetId); }]; } export function registerSource(type, source, manager) { var registry = manager.getRegistry(); var sourceId = registry.addSource(type, source); return [sourceId, function () { return registry.removeSource(sourceId); }]; }README.md000064400000001320151676724530006037 0ustar00[](https://www.npmjs.com/package/react-dnd) [](https://www.npmjs.com/package/react-dnd) [](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.
/home/emeraadmin/.htpasswds/../www/8aabc/../src/../4d695/react-dnd.tar