dnd-core

  • Version 16.0.1
  • Published
  • 194 kB
  • 3 dependencies
  • MIT license

Install

npm i dnd-core
yarn add dnd-core
pnpm add dnd-core

Overview

Drag and drop sans the GUI

Index

Functions

function createDragDropManager

createDragDropManager: (
backendFactory: BackendFactory,
globalContext?: unknown,
backendOptions?: unknown,
debugMode?: boolean
) => DragDropManager;

    Interfaces

    interface Action

    interface Action<Payload> {}

      property payload

      payload: Payload;

        property type

        type: Identifier;

          interface Backend

          interface Backend {}

            method connectDragPreview

            connectDragPreview: (sourceId: any, node?: any, options?: any) => Unsubscribe;

              method connectDragSource

              connectDragSource: (sourceId: any, node?: any, options?: any) => Unsubscribe;

                method connectDropTarget

                connectDropTarget: (targetId: any, node?: any, options?: any) => Unsubscribe;

                  method profile

                  profile: () => Record<string, number>;

                    method setup

                    setup: () => void;

                      method teardown

                      teardown: () => void;

                        interface BeginDragOptions

                        interface BeginDragOptions {}

                          property clientOffset

                          clientOffset?: XYCoord;

                            property getSourceClientOffset

                            getSourceClientOffset?: (sourceId: Identifier | undefined) => XYCoord;

                              property publishSource

                              publishSource?: boolean;

                                interface BeginDragPayload

                                interface BeginDragPayload {}

                                  property clientOffset

                                  clientOffset: XYCoord | null;

                                    property isSourcePublic

                                    isSourcePublic: boolean;

                                      property item

                                      item: any;

                                        property itemType

                                        itemType: Identifier;

                                          property sourceClientOffset

                                          sourceClientOffset: XYCoord | null;

                                            property sourceId

                                            sourceId: Identifier;

                                              interface DragDropActions

                                              interface DragDropActions {}

                                                method beginDrag

                                                beginDrag: (
                                                sourceIds?: Identifier[],
                                                options?: any
                                                ) => Action<BeginDragPayload> | undefined;

                                                  method drop

                                                  drop: (options?: any) => void;

                                                    method endDrag

                                                    endDrag: () => SentinelAction;

                                                      method hover

                                                      hover: (targetIds: Identifier[], options?: any) => Action<HoverPayload>;

                                                        method publishDragSource

                                                        publishDragSource: () => SentinelAction | undefined;

                                                          interface DragDropManager

                                                          interface DragDropManager {}

                                                            method dispatch

                                                            dispatch: (action: any) => void;

                                                              method getActions

                                                              getActions: () => DragDropActions;

                                                                method getBackend

                                                                getBackend: () => Backend;

                                                                  method getMonitor

                                                                  getMonitor: () => DragDropMonitor;

                                                                    method getRegistry

                                                                    getRegistry: () => HandlerRegistry;

                                                                      interface DragDropMonitor

                                                                      interface DragDropMonitor {}

                                                                        method canDragSource

                                                                        canDragSource: (sourceId: Identifier | undefined) => boolean;

                                                                          method canDropOnTarget

                                                                          canDropOnTarget: (targetId: Identifier | undefined) => boolean;

                                                                            method didDrop

                                                                            didDrop: () => boolean;
                                                                            • 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().

                                                                            method getClientOffset

                                                                            getClientOffset: () => 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.

                                                                            method getDifferenceFromInitialOffset

                                                                            getDifferenceFromInitialOffset: () => 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.

                                                                            method getDropResult

                                                                            getDropResult: () => 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().

                                                                            method getInitialClientOffset

                                                                            getInitialClientOffset: () => XYCoord | null;
                                                                            • 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.

                                                                            method getInitialSourceClientOffset

                                                                            getInitialSourceClientOffset: () => 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.

                                                                            method getItem

                                                                            getItem: () => any;
                                                                            • 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.

                                                                            method getItemType

                                                                            getItemType: () => Identifier | null;
                                                                            • Returns a string or a symbol identifying the type of the current dragged item. Returns null if no item is being dragged.

                                                                            method getSourceClientOffset

                                                                            getSourceClientOffset: () => 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.

                                                                            method getSourceId

                                                                            getSourceId: () => Identifier | null;

                                                                              method getTargetIds

                                                                              getTargetIds: () => Identifier[];

                                                                                method isDragging

                                                                                isDragging: () => 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.

                                                                                method isDraggingSource

                                                                                isDraggingSource: (sourceId: Identifier | undefined) => boolean;

                                                                                  method isOverTarget

                                                                                  isOverTarget: (
                                                                                  targetId: Identifier | undefined,
                                                                                  options?: { shallow?: boolean }
                                                                                  ) => boolean;

                                                                                    method isSourcePublic

                                                                                    isSourcePublic: () => boolean | null;

                                                                                      method subscribeToOffsetChange

                                                                                      subscribeToOffsetChange: (listener: Listener) => Unsubscribe;

                                                                                        method subscribeToStateChange

                                                                                        subscribeToStateChange: (
                                                                                        listener: Listener,
                                                                                        options?: { handlerIds?: Identifier[] }
                                                                                        ) => Unsubscribe;

                                                                                          interface DragSource

                                                                                          interface DragSource {}

                                                                                            method beginDrag

                                                                                            beginDrag: (monitor: DragDropMonitor, targetId: Identifier) => void;

                                                                                              method canDrag

                                                                                              canDrag: (monitor: DragDropMonitor, targetId: Identifier) => boolean;

                                                                                                method endDrag

                                                                                                endDrag: (monitor: DragDropMonitor, targetId: Identifier) => void;

                                                                                                  method isDragging

                                                                                                  isDragging: (monitor: DragDropMonitor, targetId: Identifier) => boolean;

                                                                                                    interface DropPayload

                                                                                                    interface DropPayload {}

                                                                                                      property dropResult

                                                                                                      dropResult: any;

                                                                                                        interface DropTarget

                                                                                                        interface DropTarget {}

                                                                                                          method canDrop

                                                                                                          canDrop: (monitor: DragDropMonitor, targetId: Identifier) => boolean;

                                                                                                            method drop

                                                                                                            drop: (monitor: DragDropMonitor, targetId: Identifier) => any;

                                                                                                              method hover

                                                                                                              hover: (monitor: DragDropMonitor, targetId: Identifier) => void;

                                                                                                                interface HandlerRegistry

                                                                                                                interface HandlerRegistry {}

                                                                                                                  method addSource

                                                                                                                  addSource: (type: SourceType, source: DragSource) => Identifier;

                                                                                                                    method addTarget

                                                                                                                    addTarget: (type: TargetType, target: DropTarget) => Identifier;

                                                                                                                      method containsHandler

                                                                                                                      containsHandler: (handler: DragSource | DropTarget) => boolean;

                                                                                                                        method getSource

                                                                                                                        getSource: (sourceId: Identifier, includePinned?: boolean) => DragSource;

                                                                                                                          method getSourceType

                                                                                                                          getSourceType: (sourceId: Identifier) => SourceType;

                                                                                                                            method getTarget

                                                                                                                            getTarget: (targetId: Identifier) => DropTarget;

                                                                                                                              method getTargetType

                                                                                                                              getTargetType: (targetId: Identifier) => TargetType;

                                                                                                                                method isSourceId

                                                                                                                                isSourceId: (handlerId: Identifier) => boolean;

                                                                                                                                  method isTargetId

                                                                                                                                  isTargetId: (handlerId: Identifier) => boolean;

                                                                                                                                    method pinSource

                                                                                                                                    pinSource: (sourceId: Identifier) => void;

                                                                                                                                      method removeSource

                                                                                                                                      removeSource: (sourceId: Identifier) => void;

                                                                                                                                        method removeTarget

                                                                                                                                        removeTarget: (targetId: Identifier) => void;

                                                                                                                                          method unpinSource

                                                                                                                                          unpinSource: () => void;

                                                                                                                                            interface HoverOptions

                                                                                                                                            interface HoverOptions {}

                                                                                                                                              property clientOffset

                                                                                                                                              clientOffset?: XYCoord;

                                                                                                                                                interface HoverPayload

                                                                                                                                                interface HoverPayload {}

                                                                                                                                                  property clientOffset

                                                                                                                                                  clientOffset: XYCoord | null;

                                                                                                                                                    property targetIds

                                                                                                                                                    targetIds: Identifier[];

                                                                                                                                                      interface InitCoordsPayload

                                                                                                                                                      interface InitCoordsPayload {}

                                                                                                                                                        property clientOffset

                                                                                                                                                        clientOffset: XYCoord | null;

                                                                                                                                                          property sourceClientOffset

                                                                                                                                                          sourceClientOffset: XYCoord | null;

                                                                                                                                                            interface SentinelAction

                                                                                                                                                            interface SentinelAction {}

                                                                                                                                                              property type

                                                                                                                                                              type: Identifier;

                                                                                                                                                                interface SourceIdPayload

                                                                                                                                                                interface SourceIdPayload {}

                                                                                                                                                                  property sourceId

                                                                                                                                                                  sourceId: Identifier;

                                                                                                                                                                    interface TargetIdPayload

                                                                                                                                                                    interface TargetIdPayload {}

                                                                                                                                                                      property targetId

                                                                                                                                                                      targetId: Identifier;

                                                                                                                                                                        interface XYCoord

                                                                                                                                                                        interface XYCoord {}

                                                                                                                                                                          property x

                                                                                                                                                                          x: number;

                                                                                                                                                                            property y

                                                                                                                                                                            y: number;

                                                                                                                                                                              Enums

                                                                                                                                                                              enum HandlerRole

                                                                                                                                                                              enum HandlerRole {
                                                                                                                                                                              SOURCE = 'SOURCE',
                                                                                                                                                                              TARGET = 'TARGET',
                                                                                                                                                                              }

                                                                                                                                                                                member SOURCE

                                                                                                                                                                                SOURCE = 'SOURCE'

                                                                                                                                                                                  member TARGET

                                                                                                                                                                                  TARGET = 'TARGET'

                                                                                                                                                                                    Type Aliases

                                                                                                                                                                                    type ActionCreator

                                                                                                                                                                                    type ActionCreator<Payload> = (args: any[]) => Action<Payload>;

                                                                                                                                                                                      type BackendFactory

                                                                                                                                                                                      type BackendFactory = (
                                                                                                                                                                                      manager: DragDropManager,
                                                                                                                                                                                      globalContext?: any,
                                                                                                                                                                                      configuration?: any
                                                                                                                                                                                      ) => Backend;

                                                                                                                                                                                        type Identifier

                                                                                                                                                                                        type Identifier = string | symbol;

                                                                                                                                                                                          type Listener

                                                                                                                                                                                          type Listener = () => void;

                                                                                                                                                                                            type SourceType

                                                                                                                                                                                            type SourceType = Identifier;

                                                                                                                                                                                              type TargetType

                                                                                                                                                                                              type TargetType = Identifier | Identifier[];

                                                                                                                                                                                                type Unsubscribe

                                                                                                                                                                                                type Unsubscribe = () => void;

                                                                                                                                                                                                  Package Files (3)

                                                                                                                                                                                                  Dependencies (3)

                                                                                                                                                                                                  Dev Dependencies (10)

                                                                                                                                                                                                  Peer Dependencies (0)

                                                                                                                                                                                                  No peer dependencies.

                                                                                                                                                                                                  Badge

                                                                                                                                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/dnd-core.

                                                                                                                                                                                                  • Markdown
                                                                                                                                                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/dnd-core)
                                                                                                                                                                                                  • HTML
                                                                                                                                                                                                    <a href="https://www.jsdocs.io/package/dnd-core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>