@mk-drag-and-drop/dom 0.4.6 → 0.5.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.
@@ -33,6 +33,7 @@ export type DragControllerOptions = {
33
33
  targetingConstraint?: TargetingConstraint;
34
34
  } & DragLifecycleCallbacks;
35
35
  export type DragController = {
36
+ cancelDrag: () => void;
36
37
  remeasureDropTargets: (input?: RemeasureDropTargetsInput) => void;
37
38
  remeasureOverlay: () => void;
38
39
  recomputeActiveDrag: () => void;
@@ -19,6 +19,9 @@ export function createDragController(options = {}) {
19
19
  configureRuntime(options);
20
20
  syncLiveRegion();
21
21
  const controller = {
22
+ cancelDrag: () => {
23
+ runtime.cancelDrag();
24
+ },
22
25
  remeasureDropTargets: (input) => {
23
26
  runtime.remeasureDropTargets(input);
24
27
  },
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { createDropContainer, type CreateDropContainerInput, } from "./droppable
5
5
  export { createSortable, type CreateSortableInput, } from "./sortable/create-sortable-binding.js";
6
6
  export type { SortableAxis, SortablePlacementBoundary, } from "./sortable/sortable-options.js";
7
7
  export { createDragHandle, type CreateDragHandleInput, } from "./input/create-drag-handle.js";
8
- export type { DragEndResult, DragEndEvent, DragLifecycleCallbacks, DragLifecycleHelpers, DragSource, DragStartEvent, DragUpdateEvent, DropEvent, } from "./runtime/lifecycle.js";
8
+ export type { DragEndResult, DragEndEvent, DragLifecycleCallbacks, DragLifecycleHelpers, DragSource, DragStartEvent, DragUpdateEvent, DropEvent, ActiveDragResetEvent, SortablePreview, } from "./runtime/lifecycle.js";
9
9
  export type { RemeasureDropTargetsInput, SortableDropPlacement, } from "./runtime/drop-target-registry.js";
10
10
  export type { OverlayReleaseMode } from "./runtime/types.js";
11
11
  export { centerToCenter, pointerToCenter, pointerToRectDistance, } from "./targeting/algorithms.js";
@@ -1,6 +1,6 @@
1
1
  export { createDragRuntimeScope, type DragRuntimeScope, type DragRuntimeScopeConfigureInput, type DragRuntimeScopeOptions, } from "../runtime/drag-runtime-scope.js";
2
2
  export type { DragOverlayHostUpdate, DragOverlayPhase, DragOverlayRenderState, DragState, OverlayReleaseMode, } from "../runtime/types.js";
3
- export type { DragRuntimeSubscription } from "../runtime/lifecycle.js";
3
+ export type { ActiveDragResetEvent, DragRuntimeSubscription, SortablePreview, } from "../runtime/lifecycle.js";
4
4
  export { createDomDraggable, type CreateDomDraggableInput, type DomDraggableBehavior, type DomDraggableKeyDownEvent, type DomDraggablePointerDownEvent, type DomDraggableRuntime, } from "../draggable/create-draggable.js";
5
5
  export { createDomDroppable, type CreateDomDroppableInput, type DomDroppableBehavior, type DomDroppableRuntime, } from "../droppable/create-droppable.js";
6
6
  export { createDomDropContainer, type CreateDomDropContainerInput, type DomDropContainerBehavior, type DomDropContainerRuntime, } from "../droppable/create-drop-container.js";
@@ -4,6 +4,7 @@ import type { DomDropContainerRuntime } from "../droppable/create-drop-container
4
4
  import type { DomDroppableRuntime } from "../droppable/create-droppable.js";
5
5
  import type { DomSortableRuntime } from "../sortable/sortable-registry.js";
6
6
  import { type StaleDomBindingRecord } from "./drag-runtime.js";
7
+ import type { DragRuntimeSubscription } from "./lifecycle.js";
7
8
  import type { DragRuntimeConfigureInput, DragRuntimeOptions } from "./types.js";
8
9
  export type DragRuntimeScopeOptions = DragRuntimeOptions;
9
10
  export type DragRuntimeScopeConfigureInput = DragRuntimeConfigureInput;
@@ -13,6 +14,7 @@ export type DragRuntimeScope = DomDraggableRuntime & DomDroppableRuntime & DomDr
13
14
  releaseActiveDragResources: () => void;
14
15
  recomputeActiveDrag: () => void;
15
16
  setOverlayRect: (overlayRect: DragRect | null) => void;
17
+ subscribe: (subscription: DragRuntimeSubscription) => () => void;
16
18
  };
17
19
  export type InternalStaleDomBindingRuntime = {
18
20
  registerStaleDomBinding: (record: StaleDomBindingRecord) => () => void;
@@ -1,4 +1,5 @@
1
1
  import { DragRuntime } from "./drag-runtime.js";
2
+ import { linkSortableCoordinatorHost } from "./sortable-coordinator.js";
2
3
  export function createDragRuntimeScope(options) {
3
4
  const runtime = new DragRuntime(options);
4
5
  const scope = {
@@ -29,5 +30,6 @@ export function createDragRuntimeScope(options) {
29
30
  pruneDisconnectedDomBindings: () => runtime.pruneDisconnectedDomBindings(),
30
31
  getStaleDomBindingRecordCount: () => runtime.getStaleDomBindingRecordCount(),
31
32
  };
33
+ linkSortableCoordinatorHost(scope, runtime);
32
34
  return scope;
33
35
  }
@@ -18,6 +18,7 @@ export declare class DragRuntime {
18
18
  private activeDragModifiers;
19
19
  private releaseActiveInputListeners;
20
20
  private restoreTextSelectionSuppression;
21
+ private releasePostDragClickSuppression;
21
22
  private queuedPointerPosition;
22
23
  private pointerFrameId;
23
24
  private subscriptions;
@@ -70,6 +71,8 @@ export declare class DragRuntime {
70
71
  private releaseOverlayAfterDrag;
71
72
  private bindPointerWindowListeners;
72
73
  private bindKeyboardWindowListeners;
74
+ private suppressNextRelatedClick;
75
+ private clearPostDragClickSuppression;
73
76
  private suppressTextSelection;
74
77
  private resetActiveDragState;
75
78
  private releaseActiveInputResources;
@@ -81,6 +84,7 @@ export declare class DragRuntime {
81
84
  private getActiveInput;
82
85
  private getDraggingSession;
83
86
  private getDropEventSortablePlacement;
87
+ private getSortablePreview;
84
88
  private createDragState;
85
89
  private getLifecycleDropTargetRect;
86
90
  private createLifecycleDropTargetRectSnapshot;
@@ -90,7 +94,6 @@ export declare class DragRuntime {
90
94
  private getCurrentDragRectAt;
91
95
  private removeDisconnectedDropTargets;
92
96
  private pruneDisconnectedDomBindingRecords;
93
- private clearActiveDropTargetIdIfRemoved;
94
97
  private notifyDragStartSubscriptions;
95
98
  private notifyDragStartLifecycle;
96
99
  private notifyDragUpdate;
@@ -7,6 +7,7 @@ import { PointerActivationController } from "../input/pointer-activation.js";
7
7
  import { applyDragModifiers, createActiveDragModifiers, } from "../modifiers/pipeline.js";
8
8
  import { getBuiltInTargetingAlgorithmKind, pointerToCenter, } from "../targeting/algorithms.js";
9
9
  import { DropTargetRegistry, } from "./drop-target-registry.js";
10
+ import { getSortableCoordinator } from "./sortable-coordinator.js";
10
11
  const noopUpdateOverlayHost = () => { };
11
12
  export class DragRuntime {
12
13
  isDragging = false;
@@ -19,6 +20,7 @@ export class DragRuntime {
19
20
  activeDragModifiers = [];
20
21
  releaseActiveInputListeners = null;
21
22
  restoreTextSelectionSuppression = null;
23
+ releasePostDragClickSuppression = null;
22
24
  queuedPointerPosition = null;
23
25
  pointerFrameId = null;
24
26
  subscriptions = new Set();
@@ -51,6 +53,7 @@ export class DragRuntime {
51
53
  group: request.group,
52
54
  inputType: "pointer",
53
55
  pointerId: request.pointerId,
56
+ element: request.element,
54
57
  pointerPosition: request.pointerPosition,
55
58
  sourceRect: measureDomElement(request.element),
56
59
  });
@@ -64,6 +67,7 @@ export class DragRuntime {
64
67
  group: activation.group,
65
68
  inputType: "pointer",
66
69
  pointerId: activation.pointerId,
70
+ element: activation.element,
67
71
  pointerPosition: activation.initialPointerPosition,
68
72
  sourceRect: measureDomElement(activation.element),
69
73
  });
@@ -110,6 +114,7 @@ export class DragRuntime {
110
114
  this.pointerConfiguration = normalizePointerConfiguration(input.pointerConfiguration);
111
115
  }
112
116
  requestDragStart(input) {
117
+ this.clearPostDragClickSuppression();
113
118
  this.pruneDisconnectedDomBindings();
114
119
  this.pointerActivation.request(input);
115
120
  }
@@ -219,25 +224,39 @@ export class DragRuntime {
219
224
  rawPointerPosition,
220
225
  pointerPosition,
221
226
  activeDropTargetId,
227
+ sortablePreview: session.sortablePreview,
222
228
  };
223
229
  this.setSession(nextSession);
224
230
  this.updateOverlayHost({
225
231
  type: "move",
226
232
  dragState: this.createDragState(nextSession),
227
233
  });
228
- const updateEvent = {
234
+ getSortableCoordinator(this)?.update({
229
235
  draggableId: nextSession.draggableId,
236
+ group: nextSession.group,
230
237
  source: nextSession.source,
231
238
  pointerPosition,
232
- overlayRect,
233
239
  activeDropTargetId: nextSession.activeDropTargetId,
234
- previousDropTargetId,
235
- };
236
- this.notifyDragUpdate(updateEvent, {
237
- ...updateEvent,
238
240
  placementPosition: sortablePlacementPosition,
239
241
  movementPosition: rawPointerPosition,
240
242
  });
243
+ const sortablePreview = this.getSortablePreview(nextSession);
244
+ const completedSession = {
245
+ ...nextSession,
246
+ sortablePreview,
247
+ };
248
+ this.setSession(completedSession);
249
+ const updateEvent = {
250
+ draggableId: completedSession.draggableId,
251
+ group: completedSession.group,
252
+ source: completedSession.source,
253
+ pointerPosition,
254
+ overlayRect,
255
+ activeDropTargetId: completedSession.activeDropTargetId,
256
+ previousDropTargetId,
257
+ sortablePreview,
258
+ };
259
+ this.notifyDragUpdate(updateEvent);
241
260
  }
242
261
  updatePointerNowOrRelease(rawPointerPosition) {
243
262
  try {
@@ -263,7 +282,8 @@ export class DragRuntime {
263
282
  });
264
283
  }
265
284
  cancelDrag() {
266
- this.finishDragAfterQueuedPointerUpdate({
285
+ this.cancelQueuedPointerUpdate();
286
+ this.finishDrag({
267
287
  reason: "cancel",
268
288
  overlayRelease: this.overlayRelease,
269
289
  });
@@ -272,23 +292,19 @@ export class DragRuntime {
272
292
  this.pointerActivation.cancelPendingActivation();
273
293
  }
274
294
  registerDropTarget(dropTargetId, element, group, options) {
275
- const removedTargets = this.dropTargetRegistry.register(dropTargetId, element, group, options);
276
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
295
+ this.dropTargetRegistry.register(dropTargetId, element, group, options);
277
296
  }
278
297
  unregisterDropTarget(dropTargetId, element) {
279
- const removedTargets = this.dropTargetRegistry.unregister(dropTargetId, element);
280
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
298
+ this.dropTargetRegistry.unregister(dropTargetId, element);
281
299
  }
282
300
  registerDropContainer(containerId, element, group) {
283
- const removedTargets = this.dropTargetRegistry.register(containerId, element, group, {
301
+ this.dropTargetRegistry.register(containerId, element, group, {
284
302
  containerId,
285
303
  container: true,
286
304
  });
287
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
288
305
  }
289
306
  unregisterDropContainer(containerId, element) {
290
- const removedTargets = this.dropTargetRegistry.unregister(containerId, element);
291
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
307
+ this.dropTargetRegistry.unregister(containerId, element);
292
308
  }
293
309
  releaseActiveDragResources() {
294
310
  const activeSession = this.getDraggingSession();
@@ -297,15 +313,28 @@ export class DragRuntime {
297
313
  let hasReleaseError = false;
298
314
  if (activeSession) {
299
315
  try {
300
- this.notifyActiveDragReset({
316
+ getSortableCoordinator(this)?.release({
301
317
  draggableId: activeSession.draggableId,
302
- source: activeSession.source,
318
+ group: activeSession.group,
303
319
  });
304
320
  }
305
321
  catch (error) {
306
322
  firstReleaseError = error;
307
323
  hasReleaseError = true;
308
324
  }
325
+ try {
326
+ this.notifyActiveDragReset({
327
+ draggableId: activeSession.draggableId,
328
+ group: activeSession.group,
329
+ source: activeSession.source,
330
+ });
331
+ }
332
+ catch (error) {
333
+ if (!hasReleaseError) {
334
+ firstReleaseError = error;
335
+ hasReleaseError = true;
336
+ }
337
+ }
309
338
  }
310
339
  this.resetActiveDragState();
311
340
  try {
@@ -324,6 +353,7 @@ export class DragRuntime {
324
353
  hasReleaseError = true;
325
354
  }
326
355
  }
356
+ this.clearPostDragClickSuppression();
327
357
  if (hasReleaseError) {
328
358
  throw firstReleaseError;
329
359
  }
@@ -346,9 +376,7 @@ export class DragRuntime {
346
376
  }
347
377
  getCurrentDragRect() {
348
378
  const session = this.getDraggingSession();
349
- return session
350
- ? this.getCurrentDragRectAt(session.pointerPosition)
351
- : null;
379
+ return session ? this.getCurrentDragRectAt(session.pointerPosition) : null;
352
380
  }
353
381
  setOverlayRect(overlayRect) {
354
382
  const session = this.getDraggingSession();
@@ -436,6 +464,11 @@ export class DragRuntime {
436
464
  });
437
465
  const sourceContainerId = this.dropTargetRegistry.getDropTargetRegistration(input.draggableId, input.group)?.containerId ?? null;
438
466
  const sourceSortablePlacement = this.dropTargetRegistry.getSortableItemPlacement(input.draggableId, input.group);
467
+ const sourceSortableRegistration = this.dropTargetRegistry.getDropTargetRegistration(input.draggableId, input.group);
468
+ const sourceSortableElement = sourceSortablePlacement &&
469
+ sourceSortableRegistration?.capabilities.sortable
470
+ ? sourceSortableRegistration.element
471
+ : null;
439
472
  const nextSession = {
440
473
  status: "dragging",
441
474
  source: input.inputType,
@@ -444,16 +477,19 @@ export class DragRuntime {
444
477
  sourceRect: input.sourceRect,
445
478
  sourceContainerId,
446
479
  sourceSortablePlacement,
480
+ sourceSortableElement,
447
481
  overlayMeasurement: null,
448
482
  startPointerPosition: rawPointerPosition,
449
483
  rawPointerPosition,
450
484
  pointerPosition: effectivePointerPosition,
451
485
  activeDropTargetId: null,
486
+ sortablePreview: { status: "inactive" },
452
487
  };
453
488
  this.setSession(nextSession);
454
489
  this.remeasureDropTargets({ group: input.group });
455
490
  const dragStartEvent = {
456
491
  draggableId: input.draggableId,
492
+ group: input.group,
457
493
  source: input.inputType,
458
494
  pointerPosition: effectivePointerPosition,
459
495
  sourceRect: input.sourceRect,
@@ -461,15 +497,16 @@ export class DragRuntime {
461
497
  const startOverlayRect = this.hasDragOverlay
462
498
  ? this.getCurrentDragRectAt(effectivePointerPosition)
463
499
  : null;
464
- const dragStartSubscriptionEvent = {
500
+ const placementPosition = this.getSortablePlacementPosition({
501
+ pointerPosition: effectivePointerPosition,
502
+ overlayRect: startOverlayRect,
503
+ });
504
+ getSortableCoordinator(this)?.start({
465
505
  ...dragStartEvent,
466
- placementPosition: this.getSortablePlacementPosition({
467
- pointerPosition: effectivePointerPosition,
468
- overlayRect: startOverlayRect,
469
- }),
506
+ placementPosition,
470
507
  movementPosition: rawPointerPosition,
471
- };
472
- this.notifyDragStartSubscriptions(dragStartSubscriptionEvent);
508
+ });
509
+ this.notifyDragStartSubscriptions(dragStartEvent);
473
510
  this.updateOverlayHost({
474
511
  type: "mount",
475
512
  state: {
@@ -479,7 +516,7 @@ export class DragRuntime {
479
516
  });
480
517
  this.suppressTextSelection();
481
518
  if (input.inputType === "pointer") {
482
- this.bindPointerWindowListeners(input.pointerId);
519
+ this.bindPointerWindowListeners(input.pointerId, input.element);
483
520
  }
484
521
  else {
485
522
  this.bindKeyboardWindowListeners();
@@ -493,9 +530,7 @@ export class DragRuntime {
493
530
  finishDrag(input) {
494
531
  this.cancelPendingActivation();
495
532
  const session = this.getDraggingSession();
496
- const releasedDragState = session
497
- ? this.createDragState(session)
498
- : null;
533
+ const releasedDragState = session ? this.createDragState(session) : null;
499
534
  const activeDropTargetId = input.reason === "drop" ? session?.activeDropTargetId ?? null : null;
500
535
  const validDropTarget = session && activeDropTargetId
501
536
  ? this.dropTargetRegistry.getDropTargetRegistration(activeDropTargetId, session.group)
@@ -514,7 +549,7 @@ export class DragRuntime {
514
549
  ? this.getCurrentDragRectAt(session.pointerPosition)
515
550
  : null;
516
551
  const sortablePlacement = session && dropTargetId
517
- ? this.getDropEventSortablePlacement(session, dropTargetId)
552
+ ? this.getDropEventSortablePlacement(session)
518
553
  : undefined;
519
554
  const lifecycleDropTargetRectSnapshot = session
520
555
  ? this.createLifecycleDropTargetRectSnapshot({
@@ -532,11 +567,26 @@ export class DragRuntime {
532
567
  finishError = error;
533
568
  hasFinishError = true;
534
569
  }
535
- if (session && result) {
570
+ if (session) {
571
+ try {
572
+ getSortableCoordinator(this)?.release({
573
+ draggableId: session.draggableId,
574
+ group: session.group,
575
+ });
576
+ }
577
+ catch (error) {
578
+ if (!hasFinishError) {
579
+ finishError = error;
580
+ hasFinishError = true;
581
+ }
582
+ }
583
+ }
584
+ if (session && result && !hasFinishError) {
536
585
  this.lifecycleDropTargetRectSnapshot = lifecycleDropTargetRectSnapshot;
537
586
  try {
538
587
  this.notifyDragEnd({
539
588
  draggableId: session.draggableId,
589
+ group: session.group,
540
590
  source: session.source,
541
591
  result,
542
592
  overlayRect,
@@ -545,6 +595,7 @@ export class DragRuntime {
545
595
  if (result === "dropped" && dropTargetId) {
546
596
  this.notifyDrop({
547
597
  draggableId: session.draggableId,
598
+ group: session.group,
548
599
  source: session.source,
549
600
  dropTargetId,
550
601
  ...(sortablePlacement ? { sortablePlacement } : {}),
@@ -602,7 +653,7 @@ export class DragRuntime {
602
653
  }
603
654
  this.clearOverlayHost();
604
655
  }
605
- bindPointerWindowListeners(pointerId) {
656
+ bindPointerWindowListeners(pointerId, initiatingElement) {
606
657
  this.releaseActiveInputListeners?.();
607
658
  let listenersReleased = false;
608
659
  const handlePointerMove = (event) => {
@@ -618,12 +669,20 @@ export class DragRuntime {
618
669
  if (event.pointerId !== pointerId) {
619
670
  return;
620
671
  }
621
- this.endDrag();
672
+ try {
673
+ this.endDrag();
674
+ this.suppressNextRelatedClick(initiatingElement);
675
+ }
676
+ catch (error) {
677
+ this.clearPostDragClickSuppression();
678
+ throw error;
679
+ }
622
680
  };
623
681
  const handlePointerCancel = (event) => {
624
682
  if (event.pointerId !== pointerId) {
625
683
  return;
626
684
  }
685
+ this.clearPostDragClickSuppression();
627
686
  this.cancelDrag();
628
687
  };
629
688
  window.addEventListener("pointermove", handlePointerMove, globalPointerListenerCapture);
@@ -643,6 +702,38 @@ export class DragRuntime {
643
702
  this.releaseActiveInputListeners?.();
644
703
  this.releaseActiveInputListeners = this.keyboardDrag.bindWindowListeners();
645
704
  }
705
+ suppressNextRelatedClick(initiatingElement) {
706
+ this.clearPostDragClickSuppression();
707
+ let timeoutId = null;
708
+ const handleClick = (event) => {
709
+ if (event.detail === 0 ||
710
+ !(event.target instanceof Node) ||
711
+ !initiatingElement.contains(event.target)) {
712
+ return;
713
+ }
714
+ this.clearPostDragClickSuppression();
715
+ event.preventDefault();
716
+ event.stopImmediatePropagation();
717
+ };
718
+ const release = () => {
719
+ window.removeEventListener("click", handleClick, true);
720
+ if (timeoutId !== null) {
721
+ window.clearTimeout(timeoutId);
722
+ timeoutId = null;
723
+ }
724
+ if (this.releasePostDragClickSuppression === release) {
725
+ this.releasePostDragClickSuppression = null;
726
+ }
727
+ };
728
+ window.addEventListener("click", handleClick, true);
729
+ this.releasePostDragClickSuppression = release;
730
+ timeoutId = window.setTimeout(release, 0);
731
+ }
732
+ clearPostDragClickSuppression() {
733
+ const release = this.releasePostDragClickSuppression;
734
+ this.releasePostDragClickSuppression = null;
735
+ release?.();
736
+ }
646
737
  suppressTextSelection() {
647
738
  this.restoreTextSelectionSuppression?.();
648
739
  const root = document.documentElement;
@@ -734,18 +825,41 @@ export class DragRuntime {
734
825
  getDraggingSession() {
735
826
  return this.session.status === "dragging" ? this.session : null;
736
827
  }
737
- getDropEventSortablePlacement(session, dropTargetId) {
738
- const placement = this.dropTargetRegistry.getSortableDropPlacement({
828
+ getDropEventSortablePlacement(session) {
829
+ const preview = this.getSortablePreview(session);
830
+ return preview.status === "projected" ? preview.placement : undefined;
831
+ }
832
+ getSortablePreview(session) {
833
+ const currentRegistration = this.dropTargetRegistry.getDropTargetRegistration(session.draggableId, session.group);
834
+ if (!session.sourceSortablePlacement ||
835
+ !session.sourceSortableElement ||
836
+ !currentRegistration?.capabilities.sortable ||
837
+ currentRegistration.element !== session.sourceSortableElement) {
838
+ return { status: "inactive" };
839
+ }
840
+ const placement = this.dropTargetRegistry.normalizeSortablePlacement({
739
841
  draggableId: session.draggableId,
740
- dropTargetId,
842
+ activeDropTargetId: session.activeDropTargetId,
741
843
  group: session.group,
742
844
  sourceContainerId: session.sourceContainerId,
743
845
  });
744
- if (!placement ||
745
- isSameSortablePlacement(placement, session.sourceSortablePlacement)) {
746
- return undefined;
846
+ if (!placement) {
847
+ return { status: "inactive" };
848
+ }
849
+ if (isSameSortableLocation(placement, session.sourceSortablePlacement)) {
850
+ return {
851
+ status: "source",
852
+ placement: {
853
+ sourceContainerId: session.sourceContainerId,
854
+ containerId: session.sourceContainerId,
855
+ previousDraggableId: session.sourceSortablePlacement.previousDraggableId,
856
+ nextDraggableId: session.sourceSortablePlacement.nextDraggableId,
857
+ targetDraggableId: null,
858
+ side: null,
859
+ },
860
+ };
747
861
  }
748
- return placement;
862
+ return { status: "projected", placement };
749
863
  }
750
864
  createDragState(session) {
751
865
  return {
@@ -827,8 +941,7 @@ export class DragRuntime {
827
941
  });
828
942
  }
829
943
  removeDisconnectedDropTargets(group) {
830
- const removedTargets = this.dropTargetRegistry.pruneDisconnected(group);
831
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
944
+ this.dropTargetRegistry.pruneDisconnected(group);
832
945
  }
833
946
  pruneDisconnectedDomBindingRecords(skipRecord) {
834
947
  for (const storedRecord of Array.from(this.staleDomBindingRecords)) {
@@ -846,21 +959,6 @@ export class DragRuntime {
846
959
  storedRecord.record.release();
847
960
  }
848
961
  }
849
- clearActiveDropTargetIdIfRemoved(removedTargets) {
850
- if (this.session.status !== "dragging") {
851
- return;
852
- }
853
- const session = this.session;
854
- const removedActiveTarget = removedTargets.some((removedTarget) => removedTarget.id === session.activeDropTargetId &&
855
- removedTarget.group === session.group);
856
- if (!removedActiveTarget) {
857
- return;
858
- }
859
- this.setSession({
860
- ...session,
861
- activeDropTargetId: null,
862
- });
863
- }
864
962
  notifyDragStartSubscriptions(subscriptionEvent) {
865
963
  for (const subscription of Array.from(this.subscriptions)) {
866
964
  subscription.onDragStart?.(subscriptionEvent);
@@ -869,9 +967,9 @@ export class DragRuntime {
869
967
  notifyDragStartLifecycle(event) {
870
968
  this.lifecycleCallbacks.onDragStart?.(event, this.lifecycleHelpers);
871
969
  }
872
- notifyDragUpdate(event, subscriptionEvent) {
970
+ notifyDragUpdate(event) {
873
971
  for (const subscription of Array.from(this.subscriptions)) {
874
- subscription.onDragUpdate?.(subscriptionEvent);
972
+ subscription.onDragUpdate?.(event);
875
973
  }
876
974
  this.lifecycleCallbacks.onDragUpdate?.(event, this.lifecycleHelpers);
877
975
  }
@@ -917,16 +1015,9 @@ function getRectCenter(rect) {
917
1015
  export function createDragRuntime(options) {
918
1016
  return new DragRuntime(options);
919
1017
  }
920
- function isSameSortablePlacement(placement, sourcePlacement) {
921
- if (sourcePlacement === null ||
1018
+ function isSameSortableLocation(placement, sourcePlacement) {
1019
+ return !(sourcePlacement === null ||
922
1020
  placement.containerId !== sourcePlacement.containerId ||
923
1021
  placement.previousDraggableId !== sourcePlacement.previousDraggableId ||
924
- placement.nextDraggableId !== sourcePlacement.nextDraggableId) {
925
- return false;
926
- }
927
- if (placement.targetDraggableId === null || placement.side === null) {
928
- return true;
929
- }
930
- return sourcePlacement.exactAnchors.some((anchor) => anchor.targetDraggableId === placement.targetDraggableId &&
931
- anchor.side === placement.side);
1022
+ placement.nextDraggableId !== sourcePlacement.nextDraggableId);
932
1023
  }
@@ -41,13 +41,8 @@ export type SortableItemPlacement = {
41
41
  containerId: string | null;
42
42
  previousDraggableId: string | null;
43
43
  nextDraggableId: string | null;
44
- exactAnchors: readonly SortablePlacementAnchor[];
45
44
  };
46
45
  export type SortablePlacementSide = "before" | "after";
47
- export type SortablePlacementAnchor = {
48
- targetDraggableId: string;
49
- side: SortablePlacementSide;
50
- };
51
46
  export type SortableDropPlacement = {
52
47
  sourceContainerId: string | null;
53
48
  containerId: string | null;
@@ -69,9 +64,9 @@ export declare class DropTargetRegistry {
69
64
  getDropTargetRegistration(id: string, group?: DragGroup): DropTargetRegistration | null;
70
65
  getAvailableDropTargets(input: GetAvailableDropTargetsInput): DropTarget[];
71
66
  private getAvailableDropTargetsFromEntries;
72
- getSortableDropPlacement(input: {
67
+ normalizeSortablePlacement(input: {
73
68
  draggableId: string;
74
- dropTargetId: string | null;
69
+ activeDropTargetId: string | null;
75
70
  group: DragGroup | null;
76
71
  sourceContainerId: string | null;
77
72
  }): SortableDropPlacement | null;
@@ -91,9 +86,7 @@ export declare class DropTargetRegistry {
91
86
  private syncSortableAxisIndexAfterRegister;
92
87
  private addSortableDomNeighborCandidates;
93
88
  private findContainerRegistrationForElement;
94
- private getSiblingPlacement;
95
- private getTargetPlacement;
96
- private getExactSortableItemAnchors;
89
+ private getNormalizedTargetPlacement;
97
90
  private getPreviewDomTargetPlacement;
98
91
  private isSkippedSortableSibling;
99
92
  private getNearestSortableSiblingDraggableId;