@mk-drag-and-drop/dom 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +460 -0
- package/dist/controller/controller-internals.d.ts +5 -0
- package/dist/controller/controller-internals.js +11 -0
- package/dist/controller/create-drag-controller.d.ts +36 -0
- package/dist/controller/create-drag-controller.js +232 -0
- package/dist/draggable/create-draggable-binding.d.ts +8 -0
- package/dist/draggable/create-draggable-binding.js +52 -0
- package/dist/draggable/create-draggable.d.ts +46 -0
- package/dist/draggable/create-draggable.js +57 -0
- package/dist/droppable/create-drop-container-binding.d.ts +8 -0
- package/dist/droppable/create-drop-container-binding.js +28 -0
- package/dist/droppable/create-drop-container.d.ts +18 -0
- package/dist/droppable/create-drop-container.js +36 -0
- package/dist/droppable/create-droppable-binding.d.ts +9 -0
- package/dist/droppable/create-droppable-binding.js +29 -0
- package/dist/droppable/create-droppable.d.ts +17 -0
- package/dist/droppable/create-droppable.js +31 -0
- package/dist/geometry/measurement.d.ts +4 -0
- package/dist/geometry/measurement.js +33 -0
- package/dist/geometry/overlay.d.ts +19 -0
- package/dist/geometry/overlay.js +32 -0
- package/dist/geometry/rects.d.ts +17 -0
- package/dist/geometry/rects.js +34 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +9 -0
- package/dist/input/config.d.ts +35 -0
- package/dist/input/config.js +56 -0
- package/dist/input/create-drag-handle.d.ts +4 -0
- package/dist/input/create-drag-handle.js +4 -0
- package/dist/input/drag-handle.d.ts +10 -0
- package/dist/input/drag-handle.js +74 -0
- package/dist/input/keyboard-drag.d.ts +28 -0
- package/dist/input/keyboard-drag.js +77 -0
- package/dist/input/pointer-activation.d.ts +31 -0
- package/dist/input/pointer-activation.js +97 -0
- package/dist/integration/index.d.ts +10 -0
- package/dist/integration/index.js +6 -0
- package/dist/modifiers/built-ins.d.ts +6 -0
- package/dist/modifiers/built-ins.js +62 -0
- package/dist/modifiers/pipeline.d.ts +18 -0
- package/dist/modifiers/pipeline.js +34 -0
- package/dist/modifiers/types.d.ts +32 -0
- package/dist/modifiers/types.js +1 -0
- package/dist/runtime/drag-runtime-handle.d.ts +22 -0
- package/dist/runtime/drag-runtime-handle.js +33 -0
- package/dist/runtime/drag-runtime.d.ts +96 -0
- package/dist/runtime/drag-runtime.js +798 -0
- package/dist/runtime/drop-target-registry.d.ts +101 -0
- package/dist/runtime/drop-target-registry.js +855 -0
- package/dist/runtime/lifecycle.d.ts +44 -0
- package/dist/runtime/lifecycle.js +1 -0
- package/dist/runtime/types.d.ts +65 -0
- package/dist/runtime/types.js +1 -0
- package/dist/sortable/create-sortable-binding.d.ts +10 -0
- package/dist/sortable/create-sortable-binding.js +58 -0
- package/dist/sortable/create-sortable.d.ts +19 -0
- package/dist/sortable/create-sortable.js +55 -0
- package/dist/sortable/sortable-options.d.ts +17 -0
- package/dist/sortable/sortable-options.js +20 -0
- package/dist/sortable/sortable-preview.d.ts +79 -0
- package/dist/sortable/sortable-preview.js +357 -0
- package/dist/sortable/sortable-registry.d.ts +113 -0
- package/dist/sortable/sortable-registry.js +145 -0
- package/dist/targeting/algorithms.d.ts +6 -0
- package/dist/targeting/algorithms.js +56 -0
- package/dist/targeting/constraints.d.ts +15 -0
- package/dist/targeting/constraints.js +58 -0
- package/dist/targeting/types.d.ts +23 -0
- package/dist/targeting/types.js +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DragPoint, DragRect } from "../geometry/rects.js";
|
|
2
|
+
export type DragModifierSetupInput = {
|
|
3
|
+
draggableId: string;
|
|
4
|
+
group: string;
|
|
5
|
+
sourceRect: DragRect;
|
|
6
|
+
initialPointerPosition: DragPoint;
|
|
7
|
+
};
|
|
8
|
+
export type DragModifierTransformInput<State = unknown> = {
|
|
9
|
+
draggableId: string;
|
|
10
|
+
group: string;
|
|
11
|
+
sourceRect: DragRect;
|
|
12
|
+
initialPointerPosition: DragPoint;
|
|
13
|
+
rawPointerPosition: DragPoint;
|
|
14
|
+
pointerPosition: DragPoint;
|
|
15
|
+
overlayRect: DragRect;
|
|
16
|
+
state: State;
|
|
17
|
+
};
|
|
18
|
+
export type DragModifier<State = unknown> = {
|
|
19
|
+
setup?: (input: DragModifierSetupInput) => State;
|
|
20
|
+
transform: (input: DragModifierTransformInput<State>) => DragPoint;
|
|
21
|
+
};
|
|
22
|
+
type DragModifierInputTransform = {
|
|
23
|
+
bivarianceHack(input: DragModifierTransformInput<unknown>): DragPoint;
|
|
24
|
+
}["bivarianceHack"];
|
|
25
|
+
export type DragModifierInput = {
|
|
26
|
+
setup?: (input: DragModifierSetupInput) => unknown;
|
|
27
|
+
transform: DragModifierInputTransform;
|
|
28
|
+
};
|
|
29
|
+
export type ActiveDragModifier = {
|
|
30
|
+
transform: (input: Omit<DragModifierTransformInput<unknown>, "state">) => DragPoint;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DragRect } from "../geometry/rects.js";
|
|
2
|
+
import type { DomDraggableRuntime } from "../draggable/create-draggable.js";
|
|
3
|
+
import type { DomDropContainerRuntime } from "../droppable/create-drop-container.js";
|
|
4
|
+
import type { DomDroppableRuntime } from "../droppable/create-droppable.js";
|
|
5
|
+
import type { DomSortableRuntime } from "../sortable/sortable-registry.js";
|
|
6
|
+
import { type BindingCleanupRecord } from "./drag-runtime.js";
|
|
7
|
+
import type { DragRuntimeConfigureInput, DragRuntimeOptions } from "./types.js";
|
|
8
|
+
export type DragRuntimeHandleOptions = DragRuntimeOptions;
|
|
9
|
+
export type DragRuntimeHandleConfigureInput = DragRuntimeConfigureInput;
|
|
10
|
+
export type DragRuntimeHandle = DomDraggableRuntime & DomDroppableRuntime & DomDropContainerRuntime & DomSortableRuntime & {
|
|
11
|
+
configure: (input: DragRuntimeHandleConfigureInput) => void;
|
|
12
|
+
cleanup: () => void;
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
onDispose: (callback: () => void) => () => void;
|
|
15
|
+
setOverlayRect: (overlayRect: DragRect | null) => void;
|
|
16
|
+
};
|
|
17
|
+
export type InternalBindingCleanupRuntime = {
|
|
18
|
+
registerBindingCleanup: (record: BindingCleanupRecord) => () => void;
|
|
19
|
+
pruneDisconnectedBindingCleanups: () => void;
|
|
20
|
+
getBindingCleanupRecordCount: () => number;
|
|
21
|
+
};
|
|
22
|
+
export declare function createDragRuntimeHandle(options?: DragRuntimeHandleOptions): DragRuntimeHandle;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DragRuntime } from "./drag-runtime.js";
|
|
2
|
+
export function createDragRuntimeHandle(options) {
|
|
3
|
+
const runtime = new DragRuntime(options);
|
|
4
|
+
const handle = {
|
|
5
|
+
configure: (input) => runtime.configure(input),
|
|
6
|
+
cleanup: () => runtime.cleanup(),
|
|
7
|
+
dispose: () => runtime.dispose(),
|
|
8
|
+
setOverlayRect: (overlayRect) => runtime.setOverlayRect(overlayRect),
|
|
9
|
+
requestDragStart: (input) => runtime.requestDragStart(input),
|
|
10
|
+
isKeyboardDragEnabled: () => runtime.isKeyboardDragEnabled(),
|
|
11
|
+
handleSourceKeyboardKeyDown: (input) => runtime.handleSourceKeyboardKeyDown(input),
|
|
12
|
+
registerDropTarget: (dropTargetId, element, group, options) => {
|
|
13
|
+
runtime.registerDropTarget(dropTargetId, element, group, options);
|
|
14
|
+
},
|
|
15
|
+
unregisterDropTarget: (dropTargetId, element) => {
|
|
16
|
+
runtime.unregisterDropTarget(dropTargetId, element);
|
|
17
|
+
},
|
|
18
|
+
registerDropContainer: (containerId, element, group) => {
|
|
19
|
+
runtime.registerDropContainer(containerId, element, group);
|
|
20
|
+
},
|
|
21
|
+
unregisterDropContainer: (containerId, element) => {
|
|
22
|
+
runtime.unregisterDropContainer(containerId, element);
|
|
23
|
+
},
|
|
24
|
+
getDropTargetRegistration: (dropTargetId, group) => runtime.getDropTargetRegistration(dropTargetId, group),
|
|
25
|
+
subscribe: (subscription) => runtime.subscribe(subscription),
|
|
26
|
+
onDispose: (callback) => runtime.onDispose(callback),
|
|
27
|
+
remeasureDropTargets: (input) => runtime.remeasureDropTargets(input),
|
|
28
|
+
registerBindingCleanup: (record) => runtime.registerBindingCleanup(record),
|
|
29
|
+
pruneDisconnectedBindingCleanups: () => runtime.pruneDisconnectedBindingCleanups(),
|
|
30
|
+
getBindingCleanupRecordCount: () => runtime.getBindingCleanupRecordCount(),
|
|
31
|
+
};
|
|
32
|
+
return handle;
|
|
33
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { DragRect } from "../geometry/rects.js";
|
|
2
|
+
import { type KeyboardMoveDirection, type SourceKeyboardDragKeyDownInput as KeyboardSourceKeyDownInput } from "../input/keyboard-drag.js";
|
|
3
|
+
import { type DragGroup, type RegisterDropTargetOptions, type RemeasureDropTargetsInput } from "./drop-target-registry.js";
|
|
4
|
+
import type { DragRuntimeSubscription } from "./lifecycle.js";
|
|
5
|
+
import type { DragRuntimeConfigureInput, DragRuntimeOptions, Point, RequestDragStartInput, RequestKeyboardDragStartInput } from "./types.js";
|
|
6
|
+
export type BindingCleanupRecord = {
|
|
7
|
+
cleanup: () => void;
|
|
8
|
+
isConnected: () => boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class DragRuntime {
|
|
11
|
+
isDragging: boolean;
|
|
12
|
+
draggedId: string | null;
|
|
13
|
+
draggedGroup: DragGroup | null;
|
|
14
|
+
pointerPosition: Point | null;
|
|
15
|
+
activeDropTargetId: string | null;
|
|
16
|
+
private session;
|
|
17
|
+
private modifiers;
|
|
18
|
+
private activeDragModifiers;
|
|
19
|
+
private cleanupWindowListeners;
|
|
20
|
+
private cleanupTextSelectionSuppression;
|
|
21
|
+
private queuedPointerPosition;
|
|
22
|
+
private pointerFrameId;
|
|
23
|
+
private subscriptions;
|
|
24
|
+
private disposeCallbacks;
|
|
25
|
+
private bindingCleanupRecords;
|
|
26
|
+
private lifecycleCallbacks;
|
|
27
|
+
private lifecycleHelpers;
|
|
28
|
+
private lifecycleDropTargetRectSnapshot;
|
|
29
|
+
private dropTargetRegistry;
|
|
30
|
+
private pointerConfiguration;
|
|
31
|
+
private keyboardConfiguration;
|
|
32
|
+
private updateOverlayHost;
|
|
33
|
+
private targetingAlgorithm;
|
|
34
|
+
private hasDragOverlay;
|
|
35
|
+
private keepOverlayOnDrop;
|
|
36
|
+
private targetingConstraint;
|
|
37
|
+
private pointerActivation;
|
|
38
|
+
private keyboardDrag;
|
|
39
|
+
constructor(options?: DragRuntimeOptions);
|
|
40
|
+
configure(input: DragRuntimeConfigureInput): void;
|
|
41
|
+
requestDragStart(input: RequestDragStartInput): void;
|
|
42
|
+
isKeyboardDragEnabled(): boolean;
|
|
43
|
+
handleSourceKeyboardKeyDown(input: KeyboardSourceKeyDownInput): boolean;
|
|
44
|
+
requestKeyboardDragStart(input: RequestKeyboardDragStartInput): void;
|
|
45
|
+
moveKeyboardDrag(direction: KeyboardMoveDirection): void;
|
|
46
|
+
updatePointer(rawPointerPosition: Point): void;
|
|
47
|
+
private updatePointerNow;
|
|
48
|
+
endDrag(): void;
|
|
49
|
+
cancelDrag(): void;
|
|
50
|
+
registerDropTarget(dropTargetId: string, element: HTMLElement, group: DragGroup, options?: RegisterDropTargetOptions): void;
|
|
51
|
+
unregisterDropTarget(dropTargetId: string, element?: HTMLElement): void;
|
|
52
|
+
registerDropContainer(containerId: string, element: HTMLElement, group: DragGroup): void;
|
|
53
|
+
unregisterDropContainer(containerId: string, element?: HTMLElement): void;
|
|
54
|
+
cleanup(): void;
|
|
55
|
+
getDropTargetRect(dropTargetId: string): DragRect | null;
|
|
56
|
+
getDropTargetRegistration(dropTargetId: string, group?: DragGroup): import("./drop-target-registry.js").DropTargetRegistration | null;
|
|
57
|
+
getCurrentDragRect(): DragRect | null;
|
|
58
|
+
setOverlayRect(overlayRect: DragRect | null): void;
|
|
59
|
+
remeasureDropTargets(input?: RemeasureDropTargetsInput): void;
|
|
60
|
+
subscribe(subscription: DragRuntimeSubscription): () => void;
|
|
61
|
+
onDispose(callback: () => void): () => void;
|
|
62
|
+
registerBindingCleanup(record: BindingCleanupRecord): () => void;
|
|
63
|
+
pruneDisconnectedBindingCleanups(): void;
|
|
64
|
+
getBindingCleanupRecordCount(): number;
|
|
65
|
+
dispose(): void;
|
|
66
|
+
private startDragNow;
|
|
67
|
+
private finishDrag;
|
|
68
|
+
private bindPointerWindowListeners;
|
|
69
|
+
private bindKeyboardWindowListeners;
|
|
70
|
+
private suppressTextSelection;
|
|
71
|
+
private resetActiveDragState;
|
|
72
|
+
private cleanupActiveDragResources;
|
|
73
|
+
private flushQueuedPointerUpdate;
|
|
74
|
+
private cancelQueuedPointerUpdate;
|
|
75
|
+
private setSession;
|
|
76
|
+
private syncPublicDragFields;
|
|
77
|
+
private getActiveInput;
|
|
78
|
+
private getDraggingSession;
|
|
79
|
+
private getDropEventSortablePlacement;
|
|
80
|
+
private createDragState;
|
|
81
|
+
private getLifecycleDropTargetRect;
|
|
82
|
+
private createLifecycleDropTargetRectSnapshot;
|
|
83
|
+
private getActiveDropTargetId;
|
|
84
|
+
private getSortablePlacementPosition;
|
|
85
|
+
private getAvailableDropTargets;
|
|
86
|
+
private getCurrentDragRectAt;
|
|
87
|
+
private removeDisconnectedDropTargets;
|
|
88
|
+
private pruneDisconnectedBindingCleanupRecords;
|
|
89
|
+
private disposeBindingCleanupRecords;
|
|
90
|
+
private clearActiveDropTargetIdIfRemoved;
|
|
91
|
+
private notifyDragStart;
|
|
92
|
+
private notifyDragUpdate;
|
|
93
|
+
private notifyDragEnd;
|
|
94
|
+
private notifyDrop;
|
|
95
|
+
}
|
|
96
|
+
export declare function createDragRuntime(options?: DragRuntimeOptions): DragRuntime;
|