@witchcraft/layout 0.4.3 → 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.
Files changed (126) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/runtime/components/FrameDragHandle.vue +3 -3
  3. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
  4. package/dist/runtime/components/LayoutDragEdgeHandle.d.vue.ts +2 -2
  5. package/dist/runtime/components/LayoutDragEdgeHandle.vue +2 -2
  6. package/dist/runtime/components/LayoutDragEdgeHandle.vue.d.ts +2 -2
  7. package/dist/runtime/components/LayoutDragEdges.vue +5 -5
  8. package/dist/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
  9. package/dist/runtime/components/LayoutFrame.vue +2 -2
  10. package/dist/runtime/components/LayoutIntersectionHandle.d.vue.ts +2 -2
  11. package/dist/runtime/components/LayoutIntersectionHandle.vue +2 -2
  12. package/dist/runtime/components/LayoutIntersectionHandle.vue.d.ts +2 -2
  13. package/dist/runtime/components/LayoutIntersections.vue +4 -4
  14. package/dist/runtime/components/LayoutWindow.d.vue.ts +54 -45
  15. package/dist/runtime/components/LayoutWindow.vue +29 -29
  16. package/dist/runtime/components/LayoutWindow.vue.d.ts +54 -45
  17. package/dist/runtime/composables/useFrames.d.ts +142 -129
  18. package/dist/runtime/composables/useFrames.js +122 -94
  19. package/dist/runtime/demo/App.vue +16 -16
  20. package/dist/runtime/demo/DemoControls.d.vue.ts +2 -2
  21. package/dist/runtime/demo/DemoControls.vue +4 -4
  22. package/dist/runtime/demo/DemoControls.vue.d.ts +2 -2
  23. package/dist/runtime/demo/tailwind.css +1 -1
  24. package/dist/runtime/helpers/createZoneSideClipPath.d.ts +2 -2
  25. package/dist/runtime/helpers/findEdgesTouchingWindow.d.ts +7 -0
  26. package/dist/runtime/helpers/findEdgesTouchingWindow.js +20 -0
  27. package/dist/runtime/helpers/{findFrameDraggableEdges.d.ts → findFrameMoveableEdges.d.ts} +2 -2
  28. package/dist/runtime/helpers/{findFrameDraggableEdges.js → findFrameMoveableEdges.js} +3 -3
  29. package/dist/runtime/helpers/{findDraggableEdge.d.ts → findMoveableEdge.d.ts} +1 -1
  30. package/dist/runtime/helpers/{findDraggableEdge.js → findMoveableEdge.js} +1 -1
  31. package/dist/runtime/helpers/index.d.ts +10 -3
  32. package/dist/runtime/helpers/index.js +10 -3
  33. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +1 -1
  34. package/dist/runtime/layout/createSplitDecoFromDrag.js +2 -2
  35. package/dist/runtime/layout/debugFrame.js +5 -1
  36. package/dist/runtime/layout/findSafeSplitEdge.d.ts +1 -1
  37. package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
  38. package/dist/runtime/layout/getCloseFrameInfo.js +4 -4
  39. package/dist/runtime/layout/getFrameCollapseInfo.d.ts +1 -1
  40. package/dist/runtime/layout/getFrameCollapseInfo.js +9 -29
  41. package/dist/runtime/layout/getFrameDockInfo.d.ts +1 -1
  42. package/dist/runtime/layout/getFrameDockInfo.js +61 -44
  43. package/dist/runtime/layout/getFrameExpandInfo.d.ts +11 -0
  44. package/dist/runtime/layout/getFrameExpandInfo.js +49 -0
  45. package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +2 -2
  46. package/dist/runtime/layout/getFrameRearrangeInfo.js +8 -8
  47. package/dist/runtime/layout/getFrameShrinkInfo.d.ts +14 -0
  48. package/dist/runtime/layout/getFrameShrinkInfo.js +48 -0
  49. package/dist/runtime/layout/getFrameSplitInfo.d.ts +1 -1
  50. package/dist/runtime/layout/getFrameSplitInfo.js +2 -2
  51. package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +1 -1
  52. package/dist/runtime/layout/getFrameUncollapseInfo.js +6 -20
  53. package/dist/runtime/layout/{getFrameDragZones.d.ts → getFrameZones.d.ts} +3 -3
  54. package/dist/runtime/layout/{getFrameDragZones.js → getFrameZones.js} +1 -1
  55. package/dist/runtime/layout/getUpdateWindowSizeInfo.js +10 -12
  56. package/dist/runtime/layout/{getWindowDragZones.d.ts → getWindowZones.d.ts} +1 -1
  57. package/dist/runtime/layout/{getWindowDragZones.js → getWindowZones.js} +1 -1
  58. package/dist/runtime/layout/getZones.d.ts +8 -0
  59. package/dist/runtime/layout/getZones.js +32 -0
  60. package/dist/runtime/layout/index.d.ts +6 -3
  61. package/dist/runtime/layout/index.js +6 -3
  62. package/dist/runtime/{drag/DragActionHandler.d.ts → move/ActionHandler.d.ts} +18 -18
  63. package/dist/runtime/{drag/DragActionHandler.js → move/ActionHandler.js} +19 -19
  64. package/dist/runtime/{drag → move}/CloseAction.d.ts +8 -8
  65. package/dist/runtime/{drag → move}/CloseAction.js +29 -26
  66. package/dist/runtime/{drag → move}/FrameDragAction.d.ts +8 -8
  67. package/dist/runtime/{drag → move}/FrameDragAction.js +23 -21
  68. package/dist/runtime/{drag/DragDirectionStore.d.ts → move/MoveDirectionStore.d.ts} +4 -4
  69. package/dist/runtime/{drag/DragDirectionStore.js → move/MoveDirectionStore.js} +9 -9
  70. package/dist/runtime/{drag → move}/SplitAction.d.ts +9 -9
  71. package/dist/runtime/{drag → move}/SplitAction.js +46 -43
  72. package/dist/runtime/{drag → move}/createDefaultHandlers.d.ts +2 -2
  73. package/dist/runtime/types/index.d.ts +242 -158
  74. package/dist/runtime/types/index.js +4 -3
  75. package/dist/runtime/types/vue.d.ts +25 -18
  76. package/dist/runtime/types/vue.js +1 -1
  77. package/package.json +3 -2
  78. package/src/runtime/components/FrameDragHandle.vue +3 -3
  79. package/src/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
  80. package/src/runtime/components/LayoutDragEdgeHandle.vue +4 -4
  81. package/src/runtime/components/LayoutDragEdges.vue +5 -5
  82. package/src/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
  83. package/src/runtime/components/LayoutFrame.vue +2 -2
  84. package/src/runtime/components/LayoutIntersectionHandle.vue +4 -4
  85. package/src/runtime/components/LayoutIntersections.vue +4 -4
  86. package/src/runtime/components/LayoutWindow.vue +35 -35
  87. package/src/runtime/composables/useFrames.ts +141 -121
  88. package/src/runtime/demo/App.vue +18 -18
  89. package/src/runtime/demo/DemoControls.vue +5 -5
  90. package/src/runtime/demo/tailwind.css +4 -0
  91. package/src/runtime/helpers/createZoneSideClipPath.ts +2 -2
  92. package/src/runtime/helpers/findEdgesTouchingWindow.ts +30 -0
  93. package/src/runtime/helpers/{findFrameDraggableEdges.ts → findFrameMoveableEdges.ts} +4 -4
  94. package/src/runtime/helpers/{findDraggableEdge.ts → findMoveableEdge.ts} +1 -1
  95. package/src/runtime/helpers/index.ts +10 -3
  96. package/src/runtime/layout/createSplitDecoFromDrag.ts +2 -2
  97. package/src/runtime/layout/debugFrame.ts +6 -1
  98. package/src/runtime/layout/findSafeSplitEdge.ts +4 -4
  99. package/src/runtime/layout/getCloseFrameInfo.ts +4 -4
  100. package/src/runtime/layout/getFrameCollapseInfo.ts +12 -41
  101. package/src/runtime/layout/getFrameDockInfo.ts +77 -57
  102. package/src/runtime/layout/getFrameExpandInfo.ts +84 -0
  103. package/src/runtime/layout/getFrameRearrangeInfo.ts +10 -10
  104. package/src/runtime/layout/getFrameShrinkInfo.ts +87 -0
  105. package/src/runtime/layout/getFrameSplitInfo.ts +5 -5
  106. package/src/runtime/layout/getFrameUncollapseInfo.ts +8 -30
  107. package/src/runtime/layout/{getFrameDragZones.ts → getFrameZones.ts} +4 -4
  108. package/src/runtime/layout/getUpdateWindowSizeInfo.ts +16 -22
  109. package/src/runtime/layout/{getWindowDragZones.ts → getWindowZones.ts} +1 -1
  110. package/src/runtime/layout/getZones.ts +48 -0
  111. package/src/runtime/layout/index.ts +6 -3
  112. package/src/runtime/{drag/DragActionHandler.ts → move/ActionHandler.ts} +44 -42
  113. package/src/runtime/{drag → move}/CloseAction.ts +39 -36
  114. package/src/runtime/{drag → move}/FrameDragAction.ts +36 -35
  115. package/src/runtime/{drag/DragDirectionStore.ts → move/MoveDirectionStore.ts} +10 -10
  116. package/src/runtime/{drag → move}/SplitAction.ts +56 -53
  117. package/src/runtime/{drag/defaultDragActions.ts → move/createDefaultHandlers.ts} +2 -2
  118. package/src/runtime/types/index.ts +104 -55
  119. package/src/runtime/types/vue.ts +18 -16
  120. package/dist/runtime/drag/defaultDragActions.d.ts +0 -9
  121. package/dist/runtime/drag/defaultDragActions.js +0 -10
  122. package/dist/runtime/layout/getDragZones.d.ts +0 -8
  123. package/dist/runtime/layout/getDragZones.js +0 -32
  124. package/src/runtime/drag/createDefaultHandlers.ts +0 -20
  125. package/src/runtime/layout/getDragZones.ts +0 -48
  126. /package/dist/runtime/{drag → move}/createDefaultHandlers.js +0 -0
@@ -72,17 +72,17 @@ export declare const zEdge: z.ZodObject<{
72
72
  } | {
73
73
  frame: LayoutFrame;
74
74
  } | {
75
- draggingFrameId: string;
75
+ movingFrameId: string;
76
76
  hoveredFrameId: string;
77
- zoneSide: DragZone["side"];
77
+ zoneSide: Zone["side"];
78
78
  } | {
79
- draggingFrameId: string;
79
+ movingFrameId: string;
80
80
  hoveredFrameId: string;
81
- zoneSide: DragZone["side"];
81
+ zoneSide: Zone["side"];
82
82
  } | {
83
- draggingFrameId: string;
83
+ movingFrameId: string;
84
84
  hoveredFrameId: string;
85
- zoneSide: DragZone["side"];
85
+ zoneSide: Zone["side"];
86
86
  } | {
87
87
  frame: LayoutFrame;
88
88
  } | {
@@ -105,6 +105,8 @@ export declare const zEdge: z.ZodObject<{
105
105
  frame: LayoutFrame;
106
106
  } | {
107
107
  frame: LayoutFrame;
108
+ } | {
109
+ frame: LayoutFrame;
108
110
  }>, KnownError<LayoutError, {} | {
109
111
  id: string | undefined;
110
112
  } | {
@@ -129,17 +131,17 @@ export declare const zEdge: z.ZodObject<{
129
131
  } | {
130
132
  frame: LayoutFrame;
131
133
  } | {
132
- draggingFrameId: string;
134
+ movingFrameId: string;
133
135
  hoveredFrameId: string;
134
- zoneSide: DragZone["side"];
136
+ zoneSide: Zone["side"];
135
137
  } | {
136
- draggingFrameId: string;
138
+ movingFrameId: string;
137
139
  hoveredFrameId: string;
138
- zoneSide: DragZone["side"];
140
+ zoneSide: Zone["side"];
139
141
  } | {
140
- draggingFrameId: string;
142
+ movingFrameId: string;
141
143
  hoveredFrameId: string;
142
- zoneSide: DragZone["side"];
144
+ zoneSide: Zone["side"];
143
145
  } | {
144
146
  frame: LayoutFrame;
145
147
  } | {
@@ -162,6 +164,8 @@ export declare const zEdge: z.ZodObject<{
162
164
  frame: LayoutFrame;
163
165
  } | {
164
166
  frame: LayoutFrame;
167
+ } | {
168
+ frame: LayoutFrame;
165
169
  }>>, z.ZodObject<{
166
170
  code: z.ZodString;
167
171
  message: z.ZodString;
@@ -471,17 +475,17 @@ declare const zLayoutShape: z.ZodDiscriminatedUnion<[z.ZodObject<{
471
475
  } | {
472
476
  frame: LayoutFrame;
473
477
  } | {
474
- draggingFrameId: string;
478
+ movingFrameId: string;
475
479
  hoveredFrameId: string;
476
- zoneSide: DragZone["side"];
480
+ zoneSide: Zone["side"];
477
481
  } | {
478
- draggingFrameId: string;
482
+ movingFrameId: string;
479
483
  hoveredFrameId: string;
480
- zoneSide: DragZone["side"];
484
+ zoneSide: Zone["side"];
481
485
  } | {
482
- draggingFrameId: string;
486
+ movingFrameId: string;
483
487
  hoveredFrameId: string;
484
- zoneSide: DragZone["side"];
488
+ zoneSide: Zone["side"];
485
489
  } | {
486
490
  frame: LayoutFrame;
487
491
  } | {
@@ -504,6 +508,8 @@ declare const zLayoutShape: z.ZodDiscriminatedUnion<[z.ZodObject<{
504
508
  frame: LayoutFrame;
505
509
  } | {
506
510
  frame: LayoutFrame;
511
+ } | {
512
+ frame: LayoutFrame;
507
513
  }>, KnownError<LayoutError, {} | {
508
514
  id: string | undefined;
509
515
  } | {
@@ -528,17 +534,17 @@ declare const zLayoutShape: z.ZodDiscriminatedUnion<[z.ZodObject<{
528
534
  } | {
529
535
  frame: LayoutFrame;
530
536
  } | {
531
- draggingFrameId: string;
537
+ movingFrameId: string;
532
538
  hoveredFrameId: string;
533
- zoneSide: DragZone["side"];
539
+ zoneSide: Zone["side"];
534
540
  } | {
535
- draggingFrameId: string;
541
+ movingFrameId: string;
536
542
  hoveredFrameId: string;
537
- zoneSide: DragZone["side"];
543
+ zoneSide: Zone["side"];
538
544
  } | {
539
- draggingFrameId: string;
545
+ movingFrameId: string;
540
546
  hoveredFrameId: string;
541
- zoneSide: DragZone["side"];
547
+ zoneSide: Zone["side"];
542
548
  } | {
543
549
  frame: LayoutFrame;
544
550
  } | {
@@ -561,6 +567,8 @@ declare const zLayoutShape: z.ZodDiscriminatedUnion<[z.ZodObject<{
561
567
  frame: LayoutFrame;
562
568
  } | {
563
569
  frame: LayoutFrame;
570
+ } | {
571
+ frame: LayoutFrame;
564
572
  }>>, z.ZodObject<{
565
573
  code: z.ZodString;
566
574
  message: z.ZodString;
@@ -610,17 +618,17 @@ declare const zBaseDeco: z.ZodObject<{
610
618
  } | {
611
619
  frame: LayoutFrame;
612
620
  } | {
613
- draggingFrameId: string;
621
+ movingFrameId: string;
614
622
  hoveredFrameId: string;
615
- zoneSide: DragZone["side"];
623
+ zoneSide: Zone["side"];
616
624
  } | {
617
- draggingFrameId: string;
625
+ movingFrameId: string;
618
626
  hoveredFrameId: string;
619
- zoneSide: DragZone["side"];
627
+ zoneSide: Zone["side"];
620
628
  } | {
621
- draggingFrameId: string;
629
+ movingFrameId: string;
622
630
  hoveredFrameId: string;
623
- zoneSide: DragZone["side"];
631
+ zoneSide: Zone["side"];
624
632
  } | {
625
633
  frame: LayoutFrame;
626
634
  } | {
@@ -643,6 +651,8 @@ declare const zBaseDeco: z.ZodObject<{
643
651
  frame: LayoutFrame;
644
652
  } | {
645
653
  frame: LayoutFrame;
654
+ } | {
655
+ frame: LayoutFrame;
646
656
  }>, KnownError<LayoutError, {} | {
647
657
  id: string | undefined;
648
658
  } | {
@@ -667,17 +677,17 @@ declare const zBaseDeco: z.ZodObject<{
667
677
  } | {
668
678
  frame: LayoutFrame;
669
679
  } | {
670
- draggingFrameId: string;
680
+ movingFrameId: string;
671
681
  hoveredFrameId: string;
672
- zoneSide: DragZone["side"];
682
+ zoneSide: Zone["side"];
673
683
  } | {
674
- draggingFrameId: string;
684
+ movingFrameId: string;
675
685
  hoveredFrameId: string;
676
- zoneSide: DragZone["side"];
686
+ zoneSide: Zone["side"];
677
687
  } | {
678
- draggingFrameId: string;
688
+ movingFrameId: string;
679
689
  hoveredFrameId: string;
680
- zoneSide: DragZone["side"];
690
+ zoneSide: Zone["side"];
681
691
  } | {
682
692
  frame: LayoutFrame;
683
693
  } | {
@@ -700,6 +710,8 @@ declare const zBaseDeco: z.ZodObject<{
700
710
  frame: LayoutFrame;
701
711
  } | {
702
712
  frame: LayoutFrame;
713
+ } | {
714
+ frame: LayoutFrame;
703
715
  }>>, z.ZodObject<{
704
716
  code: z.ZodString;
705
717
  message: z.ZodString;
@@ -750,17 +762,17 @@ export declare const zSplitDeco: z.ZodObject<{
750
762
  } | {
751
763
  frame: LayoutFrame;
752
764
  } | {
753
- draggingFrameId: string;
765
+ movingFrameId: string;
754
766
  hoveredFrameId: string;
755
- zoneSide: DragZone["side"];
767
+ zoneSide: Zone["side"];
756
768
  } | {
757
- draggingFrameId: string;
769
+ movingFrameId: string;
758
770
  hoveredFrameId: string;
759
- zoneSide: DragZone["side"];
771
+ zoneSide: Zone["side"];
760
772
  } | {
761
- draggingFrameId: string;
773
+ movingFrameId: string;
762
774
  hoveredFrameId: string;
763
- zoneSide: DragZone["side"];
775
+ zoneSide: Zone["side"];
764
776
  } | {
765
777
  frame: LayoutFrame;
766
778
  } | {
@@ -783,6 +795,8 @@ export declare const zSplitDeco: z.ZodObject<{
783
795
  frame: LayoutFrame;
784
796
  } | {
785
797
  frame: LayoutFrame;
798
+ } | {
799
+ frame: LayoutFrame;
786
800
  }>, KnownError<LayoutError, {} | {
787
801
  id: string | undefined;
788
802
  } | {
@@ -807,17 +821,17 @@ export declare const zSplitDeco: z.ZodObject<{
807
821
  } | {
808
822
  frame: LayoutFrame;
809
823
  } | {
810
- draggingFrameId: string;
824
+ movingFrameId: string;
811
825
  hoveredFrameId: string;
812
- zoneSide: DragZone["side"];
826
+ zoneSide: Zone["side"];
813
827
  } | {
814
- draggingFrameId: string;
828
+ movingFrameId: string;
815
829
  hoveredFrameId: string;
816
- zoneSide: DragZone["side"];
830
+ zoneSide: Zone["side"];
817
831
  } | {
818
- draggingFrameId: string;
832
+ movingFrameId: string;
819
833
  hoveredFrameId: string;
820
- zoneSide: DragZone["side"];
834
+ zoneSide: Zone["side"];
821
835
  } | {
822
836
  frame: LayoutFrame;
823
837
  } | {
@@ -840,6 +854,8 @@ export declare const zSplitDeco: z.ZodObject<{
840
854
  frame: LayoutFrame;
841
855
  } | {
842
856
  frame: LayoutFrame;
857
+ } | {
858
+ frame: LayoutFrame;
843
859
  }>>, z.ZodObject<{
844
860
  code: z.ZodString;
845
861
  message: z.ZodString;
@@ -911,17 +927,17 @@ declare const zCloseDeco: z.ZodObject<{
911
927
  } | {
912
928
  frame: LayoutFrame;
913
929
  } | {
914
- draggingFrameId: string;
930
+ movingFrameId: string;
915
931
  hoveredFrameId: string;
916
- zoneSide: DragZone["side"];
932
+ zoneSide: Zone["side"];
917
933
  } | {
918
- draggingFrameId: string;
934
+ movingFrameId: string;
919
935
  hoveredFrameId: string;
920
- zoneSide: DragZone["side"];
936
+ zoneSide: Zone["side"];
921
937
  } | {
922
- draggingFrameId: string;
938
+ movingFrameId: string;
923
939
  hoveredFrameId: string;
924
- zoneSide: DragZone["side"];
940
+ zoneSide: Zone["side"];
925
941
  } | {
926
942
  frame: LayoutFrame;
927
943
  } | {
@@ -944,6 +960,8 @@ declare const zCloseDeco: z.ZodObject<{
944
960
  frame: LayoutFrame;
945
961
  } | {
946
962
  frame: LayoutFrame;
963
+ } | {
964
+ frame: LayoutFrame;
947
965
  }>, KnownError<LayoutError, {} | {
948
966
  id: string | undefined;
949
967
  } | {
@@ -968,17 +986,17 @@ declare const zCloseDeco: z.ZodObject<{
968
986
  } | {
969
987
  frame: LayoutFrame;
970
988
  } | {
971
- draggingFrameId: string;
989
+ movingFrameId: string;
972
990
  hoveredFrameId: string;
973
- zoneSide: DragZone["side"];
991
+ zoneSide: Zone["side"];
974
992
  } | {
975
- draggingFrameId: string;
993
+ movingFrameId: string;
976
994
  hoveredFrameId: string;
977
- zoneSide: DragZone["side"];
995
+ zoneSide: Zone["side"];
978
996
  } | {
979
- draggingFrameId: string;
997
+ movingFrameId: string;
980
998
  hoveredFrameId: string;
981
- zoneSide: DragZone["side"];
999
+ zoneSide: Zone["side"];
982
1000
  } | {
983
1001
  frame: LayoutFrame;
984
1002
  } | {
@@ -1001,6 +1019,8 @@ declare const zCloseDeco: z.ZodObject<{
1001
1019
  frame: LayoutFrame;
1002
1020
  } | {
1003
1021
  frame: LayoutFrame;
1022
+ } | {
1023
+ frame: LayoutFrame;
1004
1024
  }>>, z.ZodObject<{
1005
1025
  code: z.ZodString;
1006
1026
  message: z.ZodString;
@@ -1013,7 +1033,7 @@ declare const zCloseDeco: z.ZodObject<{
1013
1033
  force: z.ZodOptional<z.ZodBoolean>;
1014
1034
  }, z.core.$strip>;
1015
1035
  export type CloseDeco = z.infer<typeof zCloseDeco>;
1016
- declare const zFrameDragDeco: z.ZodObject<{
1036
+ declare const zFrameDeco: z.ZodObject<{
1017
1037
  shapes: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1018
1038
  type: z.ZodLiteral<"rect">;
1019
1039
  data: z.ZodObject<{
@@ -1054,17 +1074,17 @@ declare const zFrameDragDeco: z.ZodObject<{
1054
1074
  } | {
1055
1075
  frame: LayoutFrame;
1056
1076
  } | {
1057
- draggingFrameId: string;
1077
+ movingFrameId: string;
1058
1078
  hoveredFrameId: string;
1059
- zoneSide: DragZone["side"];
1079
+ zoneSide: Zone["side"];
1060
1080
  } | {
1061
- draggingFrameId: string;
1081
+ movingFrameId: string;
1062
1082
  hoveredFrameId: string;
1063
- zoneSide: DragZone["side"];
1083
+ zoneSide: Zone["side"];
1064
1084
  } | {
1065
- draggingFrameId: string;
1085
+ movingFrameId: string;
1066
1086
  hoveredFrameId: string;
1067
- zoneSide: DragZone["side"];
1087
+ zoneSide: Zone["side"];
1068
1088
  } | {
1069
1089
  frame: LayoutFrame;
1070
1090
  } | {
@@ -1087,6 +1107,8 @@ declare const zFrameDragDeco: z.ZodObject<{
1087
1107
  frame: LayoutFrame;
1088
1108
  } | {
1089
1109
  frame: LayoutFrame;
1110
+ } | {
1111
+ frame: LayoutFrame;
1090
1112
  }>, KnownError<LayoutError, {} | {
1091
1113
  id: string | undefined;
1092
1114
  } | {
@@ -1111,17 +1133,17 @@ declare const zFrameDragDeco: z.ZodObject<{
1111
1133
  } | {
1112
1134
  frame: LayoutFrame;
1113
1135
  } | {
1114
- draggingFrameId: string;
1136
+ movingFrameId: string;
1115
1137
  hoveredFrameId: string;
1116
- zoneSide: DragZone["side"];
1138
+ zoneSide: Zone["side"];
1117
1139
  } | {
1118
- draggingFrameId: string;
1140
+ movingFrameId: string;
1119
1141
  hoveredFrameId: string;
1120
- zoneSide: DragZone["side"];
1142
+ zoneSide: Zone["side"];
1121
1143
  } | {
1122
- draggingFrameId: string;
1144
+ movingFrameId: string;
1123
1145
  hoveredFrameId: string;
1124
- zoneSide: DragZone["side"];
1146
+ zoneSide: Zone["side"];
1125
1147
  } | {
1126
1148
  frame: LayoutFrame;
1127
1149
  } | {
@@ -1144,6 +1166,8 @@ declare const zFrameDragDeco: z.ZodObject<{
1144
1166
  frame: LayoutFrame;
1145
1167
  } | {
1146
1168
  frame: LayoutFrame;
1169
+ } | {
1170
+ frame: LayoutFrame;
1147
1171
  }>>, z.ZodObject<{
1148
1172
  code: z.ZodString;
1149
1173
  message: z.ZodString;
@@ -1162,7 +1186,7 @@ declare const zFrameDragDeco: z.ZodObject<{
1162
1186
  center: "center";
1163
1187
  }>]>;
1164
1188
  }, z.core.$strip>;
1165
- export type FrameDragDeco = z.infer<typeof zFrameDragDeco>;
1189
+ export type FrameDeco = z.infer<typeof zFrameDeco>;
1166
1190
  export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1167
1191
  shapes: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
1168
1192
  type: z.ZodLiteral<"rect">;
@@ -1204,17 +1228,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1204
1228
  } | {
1205
1229
  frame: LayoutFrame;
1206
1230
  } | {
1207
- draggingFrameId: string;
1231
+ movingFrameId: string;
1208
1232
  hoveredFrameId: string;
1209
- zoneSide: DragZone["side"];
1233
+ zoneSide: Zone["side"];
1210
1234
  } | {
1211
- draggingFrameId: string;
1235
+ movingFrameId: string;
1212
1236
  hoveredFrameId: string;
1213
- zoneSide: DragZone["side"];
1237
+ zoneSide: Zone["side"];
1214
1238
  } | {
1215
- draggingFrameId: string;
1239
+ movingFrameId: string;
1216
1240
  hoveredFrameId: string;
1217
- zoneSide: DragZone["side"];
1241
+ zoneSide: Zone["side"];
1218
1242
  } | {
1219
1243
  frame: LayoutFrame;
1220
1244
  } | {
@@ -1237,6 +1261,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1237
1261
  frame: LayoutFrame;
1238
1262
  } | {
1239
1263
  frame: LayoutFrame;
1264
+ } | {
1265
+ frame: LayoutFrame;
1240
1266
  }>, KnownError<LayoutError, {} | {
1241
1267
  id: string | undefined;
1242
1268
  } | {
@@ -1261,17 +1287,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1261
1287
  } | {
1262
1288
  frame: LayoutFrame;
1263
1289
  } | {
1264
- draggingFrameId: string;
1290
+ movingFrameId: string;
1265
1291
  hoveredFrameId: string;
1266
- zoneSide: DragZone["side"];
1292
+ zoneSide: Zone["side"];
1267
1293
  } | {
1268
- draggingFrameId: string;
1294
+ movingFrameId: string;
1269
1295
  hoveredFrameId: string;
1270
- zoneSide: DragZone["side"];
1296
+ zoneSide: Zone["side"];
1271
1297
  } | {
1272
- draggingFrameId: string;
1298
+ movingFrameId: string;
1273
1299
  hoveredFrameId: string;
1274
- zoneSide: DragZone["side"];
1300
+ zoneSide: Zone["side"];
1275
1301
  } | {
1276
1302
  frame: LayoutFrame;
1277
1303
  } | {
@@ -1294,6 +1320,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1294
1320
  frame: LayoutFrame;
1295
1321
  } | {
1296
1322
  frame: LayoutFrame;
1323
+ } | {
1324
+ frame: LayoutFrame;
1297
1325
  }>>, z.ZodObject<{
1298
1326
  code: z.ZodString;
1299
1327
  message: z.ZodString;
@@ -1351,17 +1379,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1351
1379
  } | {
1352
1380
  frame: LayoutFrame;
1353
1381
  } | {
1354
- draggingFrameId: string;
1382
+ movingFrameId: string;
1355
1383
  hoveredFrameId: string;
1356
- zoneSide: DragZone["side"];
1384
+ zoneSide: Zone["side"];
1357
1385
  } | {
1358
- draggingFrameId: string;
1386
+ movingFrameId: string;
1359
1387
  hoveredFrameId: string;
1360
- zoneSide: DragZone["side"];
1388
+ zoneSide: Zone["side"];
1361
1389
  } | {
1362
- draggingFrameId: string;
1390
+ movingFrameId: string;
1363
1391
  hoveredFrameId: string;
1364
- zoneSide: DragZone["side"];
1392
+ zoneSide: Zone["side"];
1365
1393
  } | {
1366
1394
  frame: LayoutFrame;
1367
1395
  } | {
@@ -1384,6 +1412,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1384
1412
  frame: LayoutFrame;
1385
1413
  } | {
1386
1414
  frame: LayoutFrame;
1415
+ } | {
1416
+ frame: LayoutFrame;
1387
1417
  }>, KnownError<LayoutError, {} | {
1388
1418
  id: string | undefined;
1389
1419
  } | {
@@ -1408,17 +1438,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1408
1438
  } | {
1409
1439
  frame: LayoutFrame;
1410
1440
  } | {
1411
- draggingFrameId: string;
1441
+ movingFrameId: string;
1412
1442
  hoveredFrameId: string;
1413
- zoneSide: DragZone["side"];
1443
+ zoneSide: Zone["side"];
1414
1444
  } | {
1415
- draggingFrameId: string;
1445
+ movingFrameId: string;
1416
1446
  hoveredFrameId: string;
1417
- zoneSide: DragZone["side"];
1447
+ zoneSide: Zone["side"];
1418
1448
  } | {
1419
- draggingFrameId: string;
1449
+ movingFrameId: string;
1420
1450
  hoveredFrameId: string;
1421
- zoneSide: DragZone["side"];
1451
+ zoneSide: Zone["side"];
1422
1452
  } | {
1423
1453
  frame: LayoutFrame;
1424
1454
  } | {
@@ -1441,6 +1471,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1441
1471
  frame: LayoutFrame;
1442
1472
  } | {
1443
1473
  frame: LayoutFrame;
1474
+ } | {
1475
+ frame: LayoutFrame;
1444
1476
  }>>, z.ZodObject<{
1445
1477
  code: z.ZodString;
1446
1478
  message: z.ZodString;
@@ -1492,17 +1524,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1492
1524
  } | {
1493
1525
  frame: LayoutFrame;
1494
1526
  } | {
1495
- draggingFrameId: string;
1527
+ movingFrameId: string;
1496
1528
  hoveredFrameId: string;
1497
- zoneSide: DragZone["side"];
1529
+ zoneSide: Zone["side"];
1498
1530
  } | {
1499
- draggingFrameId: string;
1531
+ movingFrameId: string;
1500
1532
  hoveredFrameId: string;
1501
- zoneSide: DragZone["side"];
1533
+ zoneSide: Zone["side"];
1502
1534
  } | {
1503
- draggingFrameId: string;
1535
+ movingFrameId: string;
1504
1536
  hoveredFrameId: string;
1505
- zoneSide: DragZone["side"];
1537
+ zoneSide: Zone["side"];
1506
1538
  } | {
1507
1539
  frame: LayoutFrame;
1508
1540
  } | {
@@ -1525,6 +1557,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1525
1557
  frame: LayoutFrame;
1526
1558
  } | {
1527
1559
  frame: LayoutFrame;
1560
+ } | {
1561
+ frame: LayoutFrame;
1528
1562
  }>, KnownError<LayoutError, {} | {
1529
1563
  id: string | undefined;
1530
1564
  } | {
@@ -1549,17 +1583,17 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1549
1583
  } | {
1550
1584
  frame: LayoutFrame;
1551
1585
  } | {
1552
- draggingFrameId: string;
1586
+ movingFrameId: string;
1553
1587
  hoveredFrameId: string;
1554
- zoneSide: DragZone["side"];
1588
+ zoneSide: Zone["side"];
1555
1589
  } | {
1556
- draggingFrameId: string;
1590
+ movingFrameId: string;
1557
1591
  hoveredFrameId: string;
1558
- zoneSide: DragZone["side"];
1592
+ zoneSide: Zone["side"];
1559
1593
  } | {
1560
- draggingFrameId: string;
1594
+ movingFrameId: string;
1561
1595
  hoveredFrameId: string;
1562
- zoneSide: DragZone["side"];
1596
+ zoneSide: Zone["side"];
1563
1597
  } | {
1564
1598
  frame: LayoutFrame;
1565
1599
  } | {
@@ -1582,6 +1616,8 @@ export declare const zDeco: z.ZodUnion<readonly [z.ZodObject<{
1582
1616
  frame: LayoutFrame;
1583
1617
  } | {
1584
1618
  frame: LayoutFrame;
1619
+ } | {
1620
+ frame: LayoutFrame;
1585
1621
  }>>, z.ZodObject<{
1586
1622
  code: z.ZodString;
1587
1623
  message: z.ZodString;
@@ -1627,6 +1663,7 @@ export declare const LAYOUT_ERROR: {
1627
1663
  CANT_UNCOLLAPSE_NOT_COLLAPSED: "CANT_UNCOLLAPSE_NOT_COLLAPSED";
1628
1664
  NO_FILL_CANDIDATES: "NO_FILL_CANDIDATES";
1629
1665
  CANT_RESIZE_COLLAPSED_FRAME: "CANT_RESIZE_COLLAPSED_FRAME";
1666
+ CANT_RESIZE_SINGLE_FRAME: "CANT_RESIZE_SINGLE_FRAME";
1630
1667
  };
1631
1668
  export type LayoutError = EnumLike<typeof LAYOUT_ERROR>;
1632
1669
  export type LayoutErrorInfo<T extends LayoutError> = LayoutErrorsInfo[T] extends undefined ? never : LayoutErrorsInfo[T];
@@ -1666,19 +1703,19 @@ export type LayoutErrorsInfo = {
1666
1703
  frame: LayoutFrame;
1667
1704
  };
1668
1705
  [LAYOUT_ERROR.CANT_REARRANGE_TO_SAME_RELATIVE_POSITION]: {
1669
- draggingFrameId: string;
1706
+ movingFrameId: string;
1670
1707
  hoveredFrameId: string;
1671
- zoneSide: DragZone["side"];
1708
+ zoneSide: Zone["side"];
1672
1709
  };
1673
1710
  [LAYOUT_ERROR.CANT_REARRANGE_WITH_DOCKED_EDGES]: {
1674
- draggingFrameId: string;
1711
+ movingFrameId: string;
1675
1712
  hoveredFrameId: string;
1676
- zoneSide: DragZone["side"];
1713
+ zoneSide: Zone["side"];
1677
1714
  };
1678
1715
  [LAYOUT_ERROR.CANT_REARRANGE_DOCKED_WITH_NON_DOCKED]: {
1679
- draggingFrameId: string;
1716
+ movingFrameId: string;
1680
1717
  hoveredFrameId: string;
1681
- zoneSide: DragZone["side"];
1718
+ zoneSide: Zone["side"];
1682
1719
  };
1683
1720
  [LAYOUT_ERROR.CANT_SPLIT_DOCKED_FRAME]: {
1684
1721
  frame: LayoutFrame;
@@ -1710,12 +1747,15 @@ export type LayoutErrorsInfo = {
1710
1747
  [LAYOUT_ERROR.CANT_RESIZE_COLLAPSED_FRAME]: {
1711
1748
  frame: LayoutFrame;
1712
1749
  };
1750
+ [LAYOUT_ERROR.CANT_RESIZE_SINGLE_FRAME]: {
1751
+ frame: LayoutFrame;
1752
+ };
1713
1753
  [LAYOUT_ERROR.REDISTRIBUTE_WOULD_RESULT_IN_INVALID_FRAMES]: {
1714
1754
  problemEdgeCoordinates: number[];
1715
1755
  };
1716
1756
  };
1717
1757
  export type HasOpposite = Direction | EdgeSide | ExtendedDirection | ExtendedEdgeSide | keyof Point | keyof Size;
1718
- export type BaseDragZone = {
1758
+ export type BaseZone = {
1719
1759
  x: number;
1720
1760
  y: number;
1721
1761
  width: number;
@@ -1723,15 +1763,15 @@ export type BaseDragZone = {
1723
1763
  pxWidth: number;
1724
1764
  pxHeight: number;
1725
1765
  };
1726
- export type FrameDragZone = BaseDragZone & {
1766
+ export type FrameZone = BaseZone & {
1727
1767
  type: "frame";
1728
1768
  side: EdgeSide | "center";
1729
1769
  };
1730
- export type WindowEdgeZone = BaseDragZone & {
1770
+ export type WindowEdgeZone = BaseZone & {
1731
1771
  type: "window";
1732
1772
  side: EdgeSide;
1733
1773
  };
1734
- export type DragZone = FrameDragZone | WindowEdgeZone;
1774
+ export type Zone = FrameZone | WindowEdgeZone;
1735
1775
  export declare const zWindowCreate: z.ZodObject<{
1736
1776
  id: z.ZodOptional<z.ZodUUID>;
1737
1777
  activeFrame: z.ZodOptional<z.ZodString>;
@@ -1803,33 +1843,33 @@ export type LayoutChange<TInfo = never> = {
1803
1843
  window?: Partial<LayoutWindow>;
1804
1844
  info?: TInfo;
1805
1845
  };
1806
- export type DragState = {
1846
+ export type MoveState = {
1807
1847
  /** The current directions in the corresponding orientations that the user is dragging in. */
1808
- dragDirections: Record<Orientation, Direction | undefined>;
1848
+ moveDirections: Record<Orientation, Direction | undefined>;
1809
1849
  /** The curren point (in scaled window coordinates) the user is dragging at. */
1810
- dragPoint?: Point;
1850
+ movePoint?: Point;
1811
1851
  /** Cumulative pixel distance the user has dragged from the initial click point. 0 on start, increases on each move. */
1812
- dragDistance: number;
1852
+ moveDistance: number;
1813
1853
  /** Whether the user is currently dragging and what type of drag. Is truthy string during all drag events. */
1814
- isDragging: boolean | "frame" | "edge";
1854
+ isMoving: boolean | "frame" | "edge";
1815
1855
  /** Whether to show the moved frames while dragging. */
1816
- showDragging: boolean;
1817
- /** The frame being dragged during a frame drag. Only set when isDragging is "frame". */
1818
- draggingFrameId?: FrameId;
1856
+ showMoving: boolean;
1857
+ /** The frame being dragged during a frame drag. Only set when isMoving is "frame". */
1858
+ movingFrameId?: FrameId;
1819
1859
  /**
1820
1860
  * The edges that are currently being dragged. There are multiple edges if they drag an intersection since what's actually happening is we're just dragging the closest horizontal and vertical edges.
1821
1861
  */
1822
- draggingEdges: Edge[];
1862
+ movingEdges: Edge[];
1823
1863
  /**
1824
1864
  * The intersection that is currently being dragged.
1825
1865
  */
1826
- draggingIntersection?: IntersectionEntry;
1866
+ movingIntersection?: IntersectionEntry;
1827
1867
  /** The "visual" edges that can be displayed for dragging. See {@link getVisualEdges} */
1828
1868
  visualEdges: Edge[];
1829
1869
  /**
1830
1870
  * The frames touching the currently dragged edges. Each entry corresponds to the frames touching the corresponding dragging edge.
1831
1871
  *
1832
- * So you can use the index in draggingEdges to get the corresponding frames.
1872
+ * So you can use the index in movingEdges to get the corresponding frames.
1833
1873
  */
1834
1874
  touchingFrames: Record<string, LayoutFrame>[];
1835
1875
  /**
@@ -1837,13 +1877,13 @@ export type DragState = {
1837
1877
  */
1838
1878
  touchingFramesArrays: LayoutFrame[][];
1839
1879
  /**
1840
- * All the frames, with/without the currently dragged frames depending on if `showDragging` is true.
1880
+ * All the frames, with/without the currently dragged frames depending on if `showMoving` is true.
1841
1881
  */
1842
1882
  frames: Record<string, LayoutFrame>;
1843
1883
  /**
1844
- * The frame that is currently being hovered over (according to whether `dragPoint` in in the frame or not).
1884
+ * The frame that is currently being hovered over (according to whether `movePoint` in in the frame or not).
1845
1885
  */
1846
- dragHoveredFrame: LayoutFrame | undefined;
1886
+ moveHoveredFrame: LayoutFrame | undefined;
1847
1887
  /**
1848
1888
  * A list of corner intersections. Frames can also be dragged by these.
1849
1889
  */
@@ -1851,26 +1891,39 @@ export type DragState = {
1851
1891
  /**
1852
1892
  * Whether the drag was initiated from a point along the window edge.
1853
1893
  */
1854
- isDraggingFromWindowEdge: boolean;
1894
+ isMovingFromWindowEdge: boolean;
1895
+ /** Custom context passed to moveStart, available to action handlers via state.eventContext. */
1896
+ eventContext?: Record<string, unknown>;
1855
1897
  win: LayoutWindow;
1856
1898
  };
1857
- export interface ActionDragChangeResult {
1899
+ export interface ActionChangeResult {
1858
1900
  /** Whether the drag should update the edges. Defaults to false. */
1859
1901
  updateEdges?: boolean;
1860
1902
  /** Deco shapes produced by this action during this drag step. */
1861
1903
  shapes: LayoutShape[];
1862
1904
  /** Whether to show the moved edges while dragging. Defaults to true. */
1863
- showDragging?: boolean;
1905
+ showMoving?: boolean;
1864
1906
  }
1865
- export type DragChangeResult = Omit<ActionDragChangeResult, "shapes">;
1907
+ export type MoveChangeResult = Omit<ActionChangeResult, "shapes">;
1866
1908
  /**
1867
1909
  * Called when the drag coordinates change (during any event).
1868
1910
  *
1869
1911
  * Should return `{ allowed: true/false, shapes: LayoutShape[] }` to control whether the action is allowed and edges update and what deco shapes to render.
1870
1912
  *
1871
1913
  * Note that the allowed return type only affect the `move` event but is also typed as `boolean` for other events for ease of use.
1914
+ *
1915
+ * Use also to cleanup your action when type is "end".
1916
+ *
1917
+ * See also {@link ActionHandler.onMoveChange} to understand it's lifecycle as it is the extended version of.
1872
1918
  */
1873
- export type DragChangeHandler = <T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: DragState, forceRecalculateEdges: () => void, cancel: (e: PointerEvent | KeyboardEvent | undefined, state: DragState) => void) => ActionDragChangeResult;
1919
+ export type MoveChangeHandler = <T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: MoveState, forceRecalculateEdges: () => void,
1920
+ /** Calls moveEnd with apply: false */
1921
+ cancel: T extends "end" ? undefined : (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void,
1922
+ /** Saves result to resolve moveStart promise with then calls moveEnd with given apply. */
1923
+ resolve: T extends "end" ? undefined : ({ apply, result }: {
1924
+ apply: boolean;
1925
+ result: any;
1926
+ }) => void) => ActionChangeResult;
1874
1927
  /**
1875
1928
  * A drag action describes when and how to handle a drag event.
1876
1929
  *
@@ -1878,19 +1931,21 @@ export type DragChangeHandler = <T extends "start" | "move" | "end">(type: T, e:
1878
1931
  *
1879
1932
  * Each action should handle it's configuration and saving/caching any state it needs. See {@link SplitAction} and {@link CloseAction} for examples.
1880
1933
  */
1881
- export interface IDragAction {
1934
+ export interface IAction {
1882
1935
  /** A unique name for your action. */
1883
1936
  name: string;
1884
- onDragChange: DragChangeHandler;
1937
+ onMoveChange: MoveChangeHandler;
1885
1938
  /**
1886
1939
  *
1887
- * Is called after `onDragChange("end")` with the same event. Might not be called if the request was cancelled.
1940
+ * Is called before `onMoveChange("end")` with the same event. Might not be called if the request was cancelled.
1888
1941
  *
1889
1942
  * You should apply your action if possible and return whether it was applied.
1890
1943
  *
1891
- * This is also a good place to reset your state.
1944
+ * Do not reset state here, use onMoveChange ("end").
1945
+ *
1946
+ * See also {@link ActionHandler.onMoveApply} which this is the extended version of.
1892
1947
  */
1893
- onDragApply: (state: DragState, forceRecalculateEdges: () => void) => boolean;
1948
+ onMoveApply: (state: MoveState, forceRecalculateEdges: () => void) => boolean;
1894
1949
  /**
1895
1950
  * Should return true if it should handle the "request"/event (e.g. some modifier is being pressed => user is requesting x action).
1896
1951
  *
@@ -1898,20 +1953,14 @@ export interface IDragAction {
1898
1953
  *
1899
1954
  * Here is where you should initiate your state. Don't allow the action by default unless it can always be allowed.
1900
1955
  */
1901
- canHandleRequest(e: KeyboardEvent | PointerEvent, state: DragState, forceRecalculateEdges: () => void): boolean;
1902
- /**
1903
- * Called when a user cancels the drag action.
1904
- *
1905
- * You should reset your state here.
1906
- */
1907
- cancel(e: PointerEvent | KeyboardEvent | undefined, state: DragState): void;
1956
+ canHandleRequest(e: KeyboardEvent | PointerEvent, state: MoveState, forceRecalculateEdges: () => void): boolean;
1908
1957
  /**
1909
- * Plugins should implement some basic debug logs by calling {@link DragActionHandler.debugState } at least before and after applying actions in onDragApply. Debug can be a string because it can be an object key to filter on (see the debugState function).
1958
+ * Plugins should implement some basic debug logs by calling {@link ActionHandler.debugState } at least before and after applying actions in onMoveApply. Debug can be a string because it can be an object key to filter on (see the debugState function).
1910
1959
  *
1911
1960
  *
1912
1961
  * Calls look like this usually, where this.state is the plugin state:
1913
1962
  * ```ts
1914
- * DragActionHandler.debugState(this.name, "before", state, this.state, this.debug)
1963
+ * ActionHandler.debugState(this.name, "before", state, this.state, this.debug)
1915
1964
  * ```
1916
1965
  */
1917
1966
  debug: boolean | string;
@@ -1949,15 +1998,50 @@ export interface IDragAction {
1949
1998
  */
1950
1999
  annotateEdge?(edge: Edge, frames: LayoutFrame[]): void;
1951
2000
  }
1952
- export type EdgeDragStartData = {
2001
+ export type EdgeMoveStartData = {
1953
2002
  edge?: Edge;
1954
2003
  intersection?: IntersectionEntry;
1955
2004
  };
1956
- export type FrameDragStartData = {
2005
+ export type FrameMoveStartData = {
1957
2006
  frameId: FrameId;
1958
2007
  };
1959
- export type DragStartFn = {
1960
- (e: PointerEvent, type: "edge", data: EdgeDragStartData): void;
1961
- (e: PointerEvent, type: "frame", data: FrameDragStartData): void;
2008
+ export type ActionHandlerApplyResult = {
2009
+ /** Whether to apply the regular drag end changes. Return false to reset to the position before dragging. */
2010
+ apply: boolean;
2011
+ /** Value to resolve the drag promise with. Ignored if `apply` is false. */
2012
+ result: any;
2013
+ };
2014
+ /**
2015
+ * Handler interface for drag actions.
2016
+ */
2017
+ export interface ActionHandler {
2018
+ eventHandler: (e: KeyboardEvent, state: MoveState, forceRecalculateEdges: () => void) => void;
2019
+ /**
2020
+ * Called when the drag coordinates change (during any event). Should return true to allow the edges to be updated/moved, or false to prevent it. Note that the return only affects the move event but it's typed like this for ease of use. See also {@link MoveChangeHandler}.
2021
+ *
2022
+ * Can be used to save some context/info to later apply safely during onMoveApply.
2023
+ *
2024
+ * The call order is:
2025
+ * - onMoveChange("start", ...)
2026
+ * - onMoveChange("move", ...)
2027
+ * - onMoveApply(...) (IF moveEnd was called with apply: true, otherwise this is skipped)
2028
+ * - onMoveChange("end", ...) // always called last, do cleanup here
2029
+ */
2030
+ onMoveChange: (...args: Parameters<MoveChangeHandler>) => MoveChangeResult;
2031
+ /**
2032
+ * Called when drag will be applied. If moveEnd was called with apply false, it will not be called.
2033
+ * Return false to not apply the regular drag end changes (i.e. return false to reset to the position before dragging).
2034
+ *
2035
+ * Do not use for resetting handler state, use onMoveChange("end", ...) for that.
2036
+ */
2037
+ onMoveApply: (state: MoveState, forceRecalculateEdges: () => void) => ActionHandlerApplyResult;
2038
+ /**
2039
+ * Called after visual edges are recalculated. Action handlers can annotate edges with error info.
2040
+ */
2041
+ annotateEdges?: (edges: Edge[], frames: LayoutFrame[]) => void;
2042
+ }
2043
+ export type MoveStartFn = {
2044
+ (e: PointerEvent, type: "edge", data: EdgeMoveStartData): void;
2045
+ (e: PointerEvent, type: "frame", data: FrameMoveStartData): void;
1962
2046
  };
1963
2047
  export type * from "./vue.js";