@mk-drag-and-drop/dom 0.4.6 → 0.5.1

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.
@@ -4,9 +4,11 @@ import { defaultKeyboardConfiguration, normalizeKeyboardConfiguration, normalize
4
4
  import { KeyboardDragController, } from "../input/keyboard-drag.js";
5
5
  import { globalPointerListenerCapture } from "../input/global-pointer-listeners.js";
6
6
  import { PointerActivationController } from "../input/pointer-activation.js";
7
+ import { acquireDocumentPointerDragState } from "../input/pointer-drag-state.js";
7
8
  import { applyDragModifiers, createActiveDragModifiers, } from "../modifiers/pipeline.js";
8
9
  import { getBuiltInTargetingAlgorithmKind, pointerToCenter, } from "../targeting/algorithms.js";
9
10
  import { DropTargetRegistry, } from "./drop-target-registry.js";
11
+ import { getSortableCoordinator } from "./sortable-coordinator.js";
10
12
  const noopUpdateOverlayHost = () => { };
11
13
  export class DragRuntime {
12
14
  isDragging = false;
@@ -19,8 +21,12 @@ export class DragRuntime {
19
21
  activeDragModifiers = [];
20
22
  releaseActiveInputListeners = null;
21
23
  restoreTextSelectionSuppression = null;
24
+ releasePointerDragState = null;
25
+ releasePostDragClickSuppression = null;
22
26
  queuedPointerPosition = null;
23
27
  pointerFrameId = null;
28
+ pointerFrameWindow = null;
29
+ activeDragWindow = null;
24
30
  subscriptions = new Set();
25
31
  staleDomBindingRecords = new Set();
26
32
  lifecycleCallbacks = {};
@@ -51,6 +57,7 @@ export class DragRuntime {
51
57
  group: request.group,
52
58
  inputType: "pointer",
53
59
  pointerId: request.pointerId,
60
+ element: request.element,
54
61
  pointerPosition: request.pointerPosition,
55
62
  sourceRect: measureDomElement(request.element),
56
63
  });
@@ -64,6 +71,7 @@ export class DragRuntime {
64
71
  group: activation.group,
65
72
  inputType: "pointer",
66
73
  pointerId: activation.pointerId,
74
+ element: activation.element,
67
75
  pointerPosition: activation.initialPointerPosition,
68
76
  sourceRect: measureDomElement(activation.element),
69
77
  });
@@ -110,6 +118,7 @@ export class DragRuntime {
110
118
  this.pointerConfiguration = normalizePointerConfiguration(input.pointerConfiguration);
111
119
  }
112
120
  requestDragStart(input) {
121
+ this.clearPostDragClickSuppression();
113
122
  this.pruneDisconnectedDomBindings();
114
123
  this.pointerActivation.request(input);
115
124
  }
@@ -136,6 +145,7 @@ export class DragRuntime {
136
145
  draggableId: input.draggableId,
137
146
  group: input.group,
138
147
  inputType: "keyboard",
148
+ element: input.element,
139
149
  pointerPosition,
140
150
  sourceRect,
141
151
  });
@@ -172,8 +182,11 @@ export class DragRuntime {
172
182
  if (this.pointerFrameId !== null) {
173
183
  return;
174
184
  }
175
- this.pointerFrameId = window.requestAnimationFrame(() => {
185
+ const targetWindow = this.activeDragWindow ?? window;
186
+ this.pointerFrameWindow = targetWindow;
187
+ this.pointerFrameId = targetWindow.requestAnimationFrame(() => {
176
188
  this.pointerFrameId = null;
189
+ this.pointerFrameWindow = null;
177
190
  const nextPointerPosition = this.queuedPointerPosition;
178
191
  this.queuedPointerPosition = null;
179
192
  if (nextPointerPosition) {
@@ -219,25 +232,39 @@ export class DragRuntime {
219
232
  rawPointerPosition,
220
233
  pointerPosition,
221
234
  activeDropTargetId,
235
+ sortablePreview: session.sortablePreview,
222
236
  };
223
237
  this.setSession(nextSession);
224
238
  this.updateOverlayHost({
225
239
  type: "move",
226
240
  dragState: this.createDragState(nextSession),
227
241
  });
228
- const updateEvent = {
242
+ getSortableCoordinator(this)?.update({
229
243
  draggableId: nextSession.draggableId,
244
+ group: nextSession.group,
230
245
  source: nextSession.source,
231
246
  pointerPosition,
232
- overlayRect,
233
247
  activeDropTargetId: nextSession.activeDropTargetId,
234
- previousDropTargetId,
235
- };
236
- this.notifyDragUpdate(updateEvent, {
237
- ...updateEvent,
238
248
  placementPosition: sortablePlacementPosition,
239
249
  movementPosition: rawPointerPosition,
240
250
  });
251
+ const sortablePreview = this.getSortablePreview(nextSession);
252
+ const completedSession = {
253
+ ...nextSession,
254
+ sortablePreview,
255
+ };
256
+ this.setSession(completedSession);
257
+ const updateEvent = {
258
+ draggableId: completedSession.draggableId,
259
+ group: completedSession.group,
260
+ source: completedSession.source,
261
+ pointerPosition,
262
+ overlayRect,
263
+ activeDropTargetId: completedSession.activeDropTargetId,
264
+ previousDropTargetId,
265
+ sortablePreview,
266
+ };
267
+ this.notifyDragUpdate(updateEvent);
241
268
  }
242
269
  updatePointerNowOrRelease(rawPointerPosition) {
243
270
  try {
@@ -263,7 +290,8 @@ export class DragRuntime {
263
290
  });
264
291
  }
265
292
  cancelDrag() {
266
- this.finishDragAfterQueuedPointerUpdate({
293
+ this.cancelQueuedPointerUpdate();
294
+ this.finishDrag({
267
295
  reason: "cancel",
268
296
  overlayRelease: this.overlayRelease,
269
297
  });
@@ -272,23 +300,19 @@ export class DragRuntime {
272
300
  this.pointerActivation.cancelPendingActivation();
273
301
  }
274
302
  registerDropTarget(dropTargetId, element, group, options) {
275
- const removedTargets = this.dropTargetRegistry.register(dropTargetId, element, group, options);
276
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
303
+ this.dropTargetRegistry.register(dropTargetId, element, group, options);
277
304
  }
278
305
  unregisterDropTarget(dropTargetId, element) {
279
- const removedTargets = this.dropTargetRegistry.unregister(dropTargetId, element);
280
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
306
+ this.dropTargetRegistry.unregister(dropTargetId, element);
281
307
  }
282
308
  registerDropContainer(containerId, element, group) {
283
- const removedTargets = this.dropTargetRegistry.register(containerId, element, group, {
309
+ this.dropTargetRegistry.register(containerId, element, group, {
284
310
  containerId,
285
311
  container: true,
286
312
  });
287
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
288
313
  }
289
314
  unregisterDropContainer(containerId, element) {
290
- const removedTargets = this.dropTargetRegistry.unregister(containerId, element);
291
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
315
+ this.dropTargetRegistry.unregister(containerId, element);
292
316
  }
293
317
  releaseActiveDragResources() {
294
318
  const activeSession = this.getDraggingSession();
@@ -297,15 +321,28 @@ export class DragRuntime {
297
321
  let hasReleaseError = false;
298
322
  if (activeSession) {
299
323
  try {
300
- this.notifyActiveDragReset({
324
+ getSortableCoordinator(this)?.release({
301
325
  draggableId: activeSession.draggableId,
302
- source: activeSession.source,
326
+ group: activeSession.group,
303
327
  });
304
328
  }
305
329
  catch (error) {
306
330
  firstReleaseError = error;
307
331
  hasReleaseError = true;
308
332
  }
333
+ try {
334
+ this.notifyActiveDragReset({
335
+ draggableId: activeSession.draggableId,
336
+ group: activeSession.group,
337
+ source: activeSession.source,
338
+ });
339
+ }
340
+ catch (error) {
341
+ if (!hasReleaseError) {
342
+ firstReleaseError = error;
343
+ hasReleaseError = true;
344
+ }
345
+ }
309
346
  }
310
347
  this.resetActiveDragState();
311
348
  try {
@@ -324,6 +361,7 @@ export class DragRuntime {
324
361
  hasReleaseError = true;
325
362
  }
326
363
  }
364
+ this.clearPostDragClickSuppression();
327
365
  if (hasReleaseError) {
328
366
  throw firstReleaseError;
329
367
  }
@@ -346,9 +384,7 @@ export class DragRuntime {
346
384
  }
347
385
  getCurrentDragRect() {
348
386
  const session = this.getDraggingSession();
349
- return session
350
- ? this.getCurrentDragRectAt(session.pointerPosition)
351
- : null;
387
+ return session ? this.getCurrentDragRectAt(session.pointerPosition) : null;
352
388
  }
353
389
  setOverlayRect(overlayRect) {
354
390
  const session = this.getDraggingSession();
@@ -436,6 +472,11 @@ export class DragRuntime {
436
472
  });
437
473
  const sourceContainerId = this.dropTargetRegistry.getDropTargetRegistration(input.draggableId, input.group)?.containerId ?? null;
438
474
  const sourceSortablePlacement = this.dropTargetRegistry.getSortableItemPlacement(input.draggableId, input.group);
475
+ const sourceSortableRegistration = this.dropTargetRegistry.getDropTargetRegistration(input.draggableId, input.group);
476
+ const sourceSortableElement = sourceSortablePlacement &&
477
+ sourceSortableRegistration?.capabilities.sortable
478
+ ? sourceSortableRegistration.element
479
+ : null;
439
480
  const nextSession = {
440
481
  status: "dragging",
441
482
  source: input.inputType,
@@ -444,16 +485,23 @@ export class DragRuntime {
444
485
  sourceRect: input.sourceRect,
445
486
  sourceContainerId,
446
487
  sourceSortablePlacement,
488
+ sourceSortableElement,
447
489
  overlayMeasurement: null,
448
490
  startPointerPosition: rawPointerPosition,
449
491
  rawPointerPosition,
450
492
  pointerPosition: effectivePointerPosition,
451
493
  activeDropTargetId: null,
494
+ sortablePreview: { status: "inactive" },
452
495
  };
453
496
  this.setSession(nextSession);
497
+ this.activeDragWindow = input.element.ownerDocument.defaultView ?? window;
498
+ if (input.inputType === "pointer") {
499
+ this.releasePointerDragState = acquireDocumentPointerDragState(input.element.ownerDocument);
500
+ }
454
501
  this.remeasureDropTargets({ group: input.group });
455
502
  const dragStartEvent = {
456
503
  draggableId: input.draggableId,
504
+ group: input.group,
457
505
  source: input.inputType,
458
506
  pointerPosition: effectivePointerPosition,
459
507
  sourceRect: input.sourceRect,
@@ -461,15 +509,16 @@ export class DragRuntime {
461
509
  const startOverlayRect = this.hasDragOverlay
462
510
  ? this.getCurrentDragRectAt(effectivePointerPosition)
463
511
  : null;
464
- const dragStartSubscriptionEvent = {
512
+ const placementPosition = this.getSortablePlacementPosition({
513
+ pointerPosition: effectivePointerPosition,
514
+ overlayRect: startOverlayRect,
515
+ });
516
+ getSortableCoordinator(this)?.start({
465
517
  ...dragStartEvent,
466
- placementPosition: this.getSortablePlacementPosition({
467
- pointerPosition: effectivePointerPosition,
468
- overlayRect: startOverlayRect,
469
- }),
518
+ placementPosition,
470
519
  movementPosition: rawPointerPosition,
471
- };
472
- this.notifyDragStartSubscriptions(dragStartSubscriptionEvent);
520
+ });
521
+ this.notifyDragStartSubscriptions(dragStartEvent);
473
522
  this.updateOverlayHost({
474
523
  type: "mount",
475
524
  state: {
@@ -477,12 +526,12 @@ export class DragRuntime {
477
526
  phase: "dragging",
478
527
  },
479
528
  });
480
- this.suppressTextSelection();
529
+ this.suppressTextSelection(input.element.ownerDocument);
481
530
  if (input.inputType === "pointer") {
482
- this.bindPointerWindowListeners(input.pointerId);
531
+ this.bindPointerWindowListeners(input.pointerId, input.element);
483
532
  }
484
533
  else {
485
- this.bindKeyboardWindowListeners();
534
+ this.bindKeyboardWindowListeners(this.activeDragWindow);
486
535
  }
487
536
  this.notifyDragStartLifecycle(dragStartEvent);
488
537
  }
@@ -493,9 +542,7 @@ export class DragRuntime {
493
542
  finishDrag(input) {
494
543
  this.cancelPendingActivation();
495
544
  const session = this.getDraggingSession();
496
- const releasedDragState = session
497
- ? this.createDragState(session)
498
- : null;
545
+ const releasedDragState = session ? this.createDragState(session) : null;
499
546
  const activeDropTargetId = input.reason === "drop" ? session?.activeDropTargetId ?? null : null;
500
547
  const validDropTarget = session && activeDropTargetId
501
548
  ? this.dropTargetRegistry.getDropTargetRegistration(activeDropTargetId, session.group)
@@ -514,7 +561,7 @@ export class DragRuntime {
514
561
  ? this.getCurrentDragRectAt(session.pointerPosition)
515
562
  : null;
516
563
  const sortablePlacement = session && dropTargetId
517
- ? this.getDropEventSortablePlacement(session, dropTargetId)
564
+ ? this.getDropEventSortablePlacement(session)
518
565
  : undefined;
519
566
  const lifecycleDropTargetRectSnapshot = session
520
567
  ? this.createLifecycleDropTargetRectSnapshot({
@@ -532,11 +579,26 @@ export class DragRuntime {
532
579
  finishError = error;
533
580
  hasFinishError = true;
534
581
  }
535
- if (session && result) {
582
+ if (session) {
583
+ try {
584
+ getSortableCoordinator(this)?.release({
585
+ draggableId: session.draggableId,
586
+ group: session.group,
587
+ });
588
+ }
589
+ catch (error) {
590
+ if (!hasFinishError) {
591
+ finishError = error;
592
+ hasFinishError = true;
593
+ }
594
+ }
595
+ }
596
+ if (session && result && !hasFinishError) {
536
597
  this.lifecycleDropTargetRectSnapshot = lifecycleDropTargetRectSnapshot;
537
598
  try {
538
599
  this.notifyDragEnd({
539
600
  draggableId: session.draggableId,
601
+ group: session.group,
540
602
  source: session.source,
541
603
  result,
542
604
  overlayRect,
@@ -545,6 +607,7 @@ export class DragRuntime {
545
607
  if (result === "dropped" && dropTargetId) {
546
608
  this.notifyDrop({
547
609
  draggableId: session.draggableId,
610
+ group: session.group,
548
611
  source: session.source,
549
612
  dropTargetId,
550
613
  ...(sortablePlacement ? { sortablePlacement } : {}),
@@ -602,8 +665,9 @@ export class DragRuntime {
602
665
  }
603
666
  this.clearOverlayHost();
604
667
  }
605
- bindPointerWindowListeners(pointerId) {
668
+ bindPointerWindowListeners(pointerId, initiatingElement) {
606
669
  this.releaseActiveInputListeners?.();
670
+ const targetWindow = initiatingElement.ownerDocument.defaultView ?? window;
607
671
  let listenersReleased = false;
608
672
  const handlePointerMove = (event) => {
609
673
  if (event.pointerId !== pointerId) {
@@ -618,54 +682,103 @@ export class DragRuntime {
618
682
  if (event.pointerId !== pointerId) {
619
683
  return;
620
684
  }
621
- this.endDrag();
685
+ try {
686
+ this.endDrag();
687
+ this.suppressNextRelatedClick(initiatingElement);
688
+ }
689
+ catch (error) {
690
+ this.clearPostDragClickSuppression();
691
+ throw error;
692
+ }
622
693
  };
623
694
  const handlePointerCancel = (event) => {
624
695
  if (event.pointerId !== pointerId) {
625
696
  return;
626
697
  }
698
+ this.clearPostDragClickSuppression();
627
699
  this.cancelDrag();
628
700
  };
629
- window.addEventListener("pointermove", handlePointerMove, globalPointerListenerCapture);
630
- window.addEventListener("pointerup", handlePointerUp, globalPointerListenerCapture);
631
- window.addEventListener("pointercancel", handlePointerCancel, globalPointerListenerCapture);
701
+ targetWindow.addEventListener("pointermove", handlePointerMove, globalPointerListenerCapture);
702
+ targetWindow.addEventListener("pointerup", handlePointerUp, globalPointerListenerCapture);
703
+ targetWindow.addEventListener("pointercancel", handlePointerCancel, globalPointerListenerCapture);
632
704
  this.releaseActiveInputListeners = () => {
633
705
  if (listenersReleased) {
634
706
  return;
635
707
  }
636
708
  listenersReleased = true;
637
- window.removeEventListener("pointermove", handlePointerMove, globalPointerListenerCapture);
638
- window.removeEventListener("pointerup", handlePointerUp, globalPointerListenerCapture);
639
- window.removeEventListener("pointercancel", handlePointerCancel, globalPointerListenerCapture);
709
+ targetWindow.removeEventListener("pointermove", handlePointerMove, globalPointerListenerCapture);
710
+ targetWindow.removeEventListener("pointerup", handlePointerUp, globalPointerListenerCapture);
711
+ targetWindow.removeEventListener("pointercancel", handlePointerCancel, globalPointerListenerCapture);
640
712
  };
641
713
  }
642
- bindKeyboardWindowListeners() {
714
+ bindKeyboardWindowListeners(targetWindow) {
643
715
  this.releaseActiveInputListeners?.();
644
- this.releaseActiveInputListeners = this.keyboardDrag.bindWindowListeners();
716
+ this.releaseActiveInputListeners =
717
+ this.keyboardDrag.bindWindowListeners(targetWindow);
718
+ }
719
+ suppressNextRelatedClick(initiatingElement) {
720
+ this.clearPostDragClickSuppression();
721
+ const targetWindow = initiatingElement.ownerDocument.defaultView ?? window;
722
+ let timeoutId = null;
723
+ const handleClick = (event) => {
724
+ if (event.detail === 0 ||
725
+ !(event.target instanceof targetWindow.Node) ||
726
+ !initiatingElement.contains(event.target)) {
727
+ return;
728
+ }
729
+ this.clearPostDragClickSuppression();
730
+ event.preventDefault();
731
+ event.stopImmediatePropagation();
732
+ };
733
+ const release = () => {
734
+ targetWindow.removeEventListener("click", handleClick, true);
735
+ if (timeoutId !== null) {
736
+ targetWindow.clearTimeout(timeoutId);
737
+ timeoutId = null;
738
+ }
739
+ if (this.releasePostDragClickSuppression === release) {
740
+ this.releasePostDragClickSuppression = null;
741
+ }
742
+ };
743
+ targetWindow.addEventListener("click", handleClick, true);
744
+ this.releasePostDragClickSuppression = release;
745
+ timeoutId = targetWindow.setTimeout(release, 0);
746
+ }
747
+ clearPostDragClickSuppression() {
748
+ const release = this.releasePostDragClickSuppression;
749
+ this.releasePostDragClickSuppression = null;
750
+ release?.();
645
751
  }
646
- suppressTextSelection() {
752
+ suppressTextSelection(sourceDocument) {
647
753
  this.restoreTextSelectionSuppression?.();
648
- const root = document.documentElement;
649
- const body = document.body;
754
+ const root = sourceDocument.documentElement;
755
+ const body = sourceDocument.body;
650
756
  const previousRootUserSelect = root.style.userSelect;
651
- const previousBodyUserSelect = body.style.userSelect;
757
+ const previousBodyUserSelect = body?.style.userSelect;
652
758
  root.style.userSelect = "none";
653
- body.style.userSelect = "none";
759
+ if (body) {
760
+ body.style.userSelect = "none";
761
+ }
654
762
  this.restoreTextSelectionSuppression = () => {
655
763
  root.style.userSelect = previousRootUserSelect;
656
- body.style.userSelect = previousBodyUserSelect;
764
+ if (body) {
765
+ body.style.userSelect = previousBodyUserSelect ?? "";
766
+ }
657
767
  };
658
768
  }
659
769
  resetActiveDragState() {
660
770
  this.cancelQueuedPointerUpdate();
661
771
  this.setSession({ status: "idle" });
662
772
  this.activeDragModifiers = [];
773
+ this.activeDragWindow = null;
663
774
  }
664
775
  releaseActiveInputResources() {
665
776
  const releaseActiveInputListeners = this.releaseActiveInputListeners;
666
777
  this.releaseActiveInputListeners = null;
667
778
  const restoreTextSelectionSuppression = this.restoreTextSelectionSuppression;
668
779
  this.restoreTextSelectionSuppression = null;
780
+ const releasePointerDragState = this.releasePointerDragState;
781
+ this.releasePointerDragState = null;
669
782
  let releaseError;
670
783
  let hasReleaseError = false;
671
784
  try {
@@ -684,6 +797,15 @@ export class DragRuntime {
684
797
  hasReleaseError = true;
685
798
  }
686
799
  }
800
+ try {
801
+ releasePointerDragState?.();
802
+ }
803
+ catch (error) {
804
+ if (!hasReleaseError) {
805
+ releaseError = error;
806
+ hasReleaseError = true;
807
+ }
808
+ }
687
809
  if (hasReleaseError) {
688
810
  throw releaseError;
689
811
  }
@@ -693,8 +815,9 @@ export class DragRuntime {
693
815
  }
694
816
  flushQueuedPointerUpdate() {
695
817
  if (this.pointerFrameId !== null) {
696
- window.cancelAnimationFrame(this.pointerFrameId);
818
+ (this.pointerFrameWindow ?? window).cancelAnimationFrame(this.pointerFrameId);
697
819
  this.pointerFrameId = null;
820
+ this.pointerFrameWindow = null;
698
821
  }
699
822
  const nextPointerPosition = this.queuedPointerPosition;
700
823
  this.queuedPointerPosition = null;
@@ -704,8 +827,9 @@ export class DragRuntime {
704
827
  }
705
828
  cancelQueuedPointerUpdate() {
706
829
  if (this.pointerFrameId !== null) {
707
- window.cancelAnimationFrame(this.pointerFrameId);
830
+ (this.pointerFrameWindow ?? window).cancelAnimationFrame(this.pointerFrameId);
708
831
  this.pointerFrameId = null;
832
+ this.pointerFrameWindow = null;
709
833
  }
710
834
  this.queuedPointerPosition = null;
711
835
  }
@@ -734,18 +858,41 @@ export class DragRuntime {
734
858
  getDraggingSession() {
735
859
  return this.session.status === "dragging" ? this.session : null;
736
860
  }
737
- getDropEventSortablePlacement(session, dropTargetId) {
738
- const placement = this.dropTargetRegistry.getSortableDropPlacement({
861
+ getDropEventSortablePlacement(session) {
862
+ const preview = this.getSortablePreview(session);
863
+ return preview.status === "projected" ? preview.placement : undefined;
864
+ }
865
+ getSortablePreview(session) {
866
+ const currentRegistration = this.dropTargetRegistry.getDropTargetRegistration(session.draggableId, session.group);
867
+ if (!session.sourceSortablePlacement ||
868
+ !session.sourceSortableElement ||
869
+ !currentRegistration?.capabilities.sortable ||
870
+ currentRegistration.element !== session.sourceSortableElement) {
871
+ return { status: "inactive" };
872
+ }
873
+ const placement = this.dropTargetRegistry.normalizeSortablePlacement({
739
874
  draggableId: session.draggableId,
740
- dropTargetId,
875
+ activeDropTargetId: session.activeDropTargetId,
741
876
  group: session.group,
742
877
  sourceContainerId: session.sourceContainerId,
743
878
  });
744
- if (!placement ||
745
- isSameSortablePlacement(placement, session.sourceSortablePlacement)) {
746
- return undefined;
879
+ if (!placement) {
880
+ return { status: "inactive" };
881
+ }
882
+ if (isSameSortableLocation(placement, session.sourceSortablePlacement)) {
883
+ return {
884
+ status: "source",
885
+ placement: {
886
+ sourceContainerId: session.sourceContainerId,
887
+ containerId: session.sourceContainerId,
888
+ previousDraggableId: session.sourceSortablePlacement.previousDraggableId,
889
+ nextDraggableId: session.sourceSortablePlacement.nextDraggableId,
890
+ targetDraggableId: null,
891
+ side: null,
892
+ },
893
+ };
747
894
  }
748
- return placement;
895
+ return { status: "projected", placement };
749
896
  }
750
897
  createDragState(session) {
751
898
  return {
@@ -827,8 +974,7 @@ export class DragRuntime {
827
974
  });
828
975
  }
829
976
  removeDisconnectedDropTargets(group) {
830
- const removedTargets = this.dropTargetRegistry.pruneDisconnected(group);
831
- this.clearActiveDropTargetIdIfRemoved(removedTargets);
977
+ this.dropTargetRegistry.pruneDisconnected(group);
832
978
  }
833
979
  pruneDisconnectedDomBindingRecords(skipRecord) {
834
980
  for (const storedRecord of Array.from(this.staleDomBindingRecords)) {
@@ -846,21 +992,6 @@ export class DragRuntime {
846
992
  storedRecord.record.release();
847
993
  }
848
994
  }
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
995
  notifyDragStartSubscriptions(subscriptionEvent) {
865
996
  for (const subscription of Array.from(this.subscriptions)) {
866
997
  subscription.onDragStart?.(subscriptionEvent);
@@ -869,9 +1000,9 @@ export class DragRuntime {
869
1000
  notifyDragStartLifecycle(event) {
870
1001
  this.lifecycleCallbacks.onDragStart?.(event, this.lifecycleHelpers);
871
1002
  }
872
- notifyDragUpdate(event, subscriptionEvent) {
1003
+ notifyDragUpdate(event) {
873
1004
  for (const subscription of Array.from(this.subscriptions)) {
874
- subscription.onDragUpdate?.(subscriptionEvent);
1005
+ subscription.onDragUpdate?.(event);
875
1006
  }
876
1007
  this.lifecycleCallbacks.onDragUpdate?.(event, this.lifecycleHelpers);
877
1008
  }
@@ -917,16 +1048,9 @@ function getRectCenter(rect) {
917
1048
  export function createDragRuntime(options) {
918
1049
  return new DragRuntime(options);
919
1050
  }
920
- function isSameSortablePlacement(placement, sourcePlacement) {
921
- if (sourcePlacement === null ||
1051
+ function isSameSortableLocation(placement, sourcePlacement) {
1052
+ return !(sourcePlacement === null ||
922
1053
  placement.containerId !== sourcePlacement.containerId ||
923
1054
  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);
1055
+ placement.nextDraggableId !== sourcePlacement.nextDraggableId);
932
1056
  }
@@ -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;