@witchcraft/layout 0.4.4 → 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.
Files changed (99) 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 +44 -44
  15. package/dist/runtime/components/LayoutWindow.vue +27 -27
  16. package/dist/runtime/components/LayoutWindow.vue.d.ts +44 -44
  17. package/dist/runtime/composables/useFrames.d.ts +107 -109
  18. package/dist/runtime/composables/useFrames.js +107 -99
  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/helpers/createZoneSideClipPath.d.ts +2 -2
  24. package/dist/runtime/helpers/{findFrameDraggableEdges.d.ts → findFrameMoveableEdges.d.ts} +2 -2
  25. package/dist/runtime/helpers/{findFrameDraggableEdges.js → findFrameMoveableEdges.js} +3 -3
  26. package/dist/runtime/helpers/{findDraggableEdge.d.ts → findMoveableEdge.d.ts} +1 -1
  27. package/dist/runtime/helpers/{findDraggableEdge.js → findMoveableEdge.js} +1 -1
  28. package/dist/runtime/helpers/index.d.ts +2 -2
  29. package/dist/runtime/helpers/index.js +2 -2
  30. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +1 -1
  31. package/dist/runtime/layout/createSplitDecoFromDrag.js +2 -2
  32. package/dist/runtime/layout/findSafeSplitEdge.d.ts +1 -1
  33. package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
  34. package/dist/runtime/layout/getCloseFrameInfo.js +4 -4
  35. package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +2 -2
  36. package/dist/runtime/layout/getFrameRearrangeInfo.js +8 -8
  37. package/dist/runtime/layout/getFrameSplitInfo.d.ts +1 -1
  38. package/dist/runtime/layout/getFrameSplitInfo.js +2 -2
  39. package/dist/runtime/layout/{getFrameDragZones.d.ts → getFrameZones.d.ts} +3 -3
  40. package/dist/runtime/layout/{getFrameDragZones.js → getFrameZones.js} +1 -1
  41. package/dist/runtime/layout/{getWindowDragZones.d.ts → getWindowZones.d.ts} +1 -1
  42. package/dist/runtime/layout/{getWindowDragZones.js → getWindowZones.js} +1 -1
  43. package/dist/runtime/layout/getZones.d.ts +8 -0
  44. package/dist/runtime/layout/getZones.js +32 -0
  45. package/dist/runtime/layout/index.d.ts +3 -3
  46. package/dist/runtime/layout/index.js +3 -3
  47. package/dist/runtime/{drag/DragActionHandler.d.ts → move/ActionHandler.d.ts} +19 -21
  48. package/dist/runtime/{drag/DragActionHandler.js → move/ActionHandler.js} +21 -18
  49. package/dist/runtime/{drag → move}/CloseAction.d.ts +9 -8
  50. package/dist/runtime/{drag → move}/CloseAction.js +31 -27
  51. package/dist/runtime/{drag → move}/FrameDragAction.d.ts +9 -8
  52. package/dist/runtime/{drag → move}/FrameDragAction.js +23 -22
  53. package/dist/runtime/{drag/DragDirectionStore.d.ts → move/MoveDirectionStore.d.ts} +4 -4
  54. package/dist/runtime/{drag/DragDirectionStore.js → move/MoveDirectionStore.js} +9 -9
  55. package/dist/runtime/{drag → move}/SplitAction.d.ts +10 -9
  56. package/dist/runtime/{drag → move}/SplitAction.js +53 -44
  57. package/dist/runtime/{drag → move}/createDefaultHandlers.d.ts +2 -2
  58. package/dist/runtime/types/index.d.ts +192 -171
  59. package/dist/runtime/types/index.js +2 -2
  60. package/dist/runtime/types/vue.d.ts +14 -16
  61. package/dist/runtime/types/vue.js +1 -1
  62. package/package.json +1 -1
  63. package/src/runtime/components/FrameDragHandle.vue +3 -3
  64. package/src/runtime/components/LayoutDragEdgeGrabbed.vue +3 -3
  65. package/src/runtime/components/LayoutDragEdgeHandle.vue +4 -4
  66. package/src/runtime/components/LayoutDragEdges.vue +5 -5
  67. package/src/runtime/components/LayoutEdgesActiveFrame.vue +2 -2
  68. package/src/runtime/components/LayoutFrame.vue +2 -2
  69. package/src/runtime/components/LayoutIntersectionHandle.vue +4 -4
  70. package/src/runtime/components/LayoutIntersections.vue +4 -4
  71. package/src/runtime/components/LayoutWindow.vue +32 -32
  72. package/src/runtime/composables/useFrames.ts +115 -104
  73. package/src/runtime/demo/App.vue +18 -18
  74. package/src/runtime/demo/DemoControls.vue +5 -5
  75. package/src/runtime/helpers/createZoneSideClipPath.ts +2 -2
  76. package/src/runtime/helpers/{findFrameDraggableEdges.ts → findFrameMoveableEdges.ts} +4 -4
  77. package/src/runtime/helpers/{findDraggableEdge.ts → findMoveableEdge.ts} +1 -1
  78. package/src/runtime/helpers/index.ts +2 -2
  79. package/src/runtime/layout/createSplitDecoFromDrag.ts +2 -2
  80. package/src/runtime/layout/findSafeSplitEdge.ts +4 -4
  81. package/src/runtime/layout/getCloseFrameInfo.ts +4 -4
  82. package/src/runtime/layout/getFrameRearrangeInfo.ts +10 -10
  83. package/src/runtime/layout/getFrameSplitInfo.ts +5 -5
  84. package/src/runtime/layout/{getFrameDragZones.ts → getFrameZones.ts} +4 -4
  85. package/src/runtime/layout/{getWindowDragZones.ts → getWindowZones.ts} +1 -1
  86. package/src/runtime/layout/getZones.ts +48 -0
  87. package/src/runtime/layout/index.ts +3 -3
  88. package/src/runtime/{drag/DragActionHandler.ts → move/ActionHandler.ts} +48 -41
  89. package/src/runtime/{drag → move}/CloseAction.ts +42 -37
  90. package/src/runtime/{drag → move}/FrameDragAction.ts +37 -36
  91. package/src/runtime/{drag/DragDirectionStore.ts → move/MoveDirectionStore.ts} +10 -10
  92. package/src/runtime/{drag → move}/SplitAction.ts +64 -54
  93. package/src/runtime/{drag → move}/createDefaultHandlers.ts +2 -2
  94. package/src/runtime/types/index.ts +90 -69
  95. package/src/runtime/types/vue.ts +14 -14
  96. package/dist/runtime/layout/getDragZones.d.ts +0 -8
  97. package/dist/runtime/layout/getDragZones.js +0 -32
  98. package/src/runtime/layout/getDragZones.ts +0 -48
  99. /package/dist/runtime/{drag → move}/createDefaultHandlers.js +0 -0
@@ -1,17 +1,17 @@
1
- import { DragActionHandler } from "./DragActionHandler.js"
1
+ import { ActionHandler } from "./ActionHandler.js"
2
2
 
3
3
  import { createZoneSideClipPath } from "../helpers/createZoneSideClipPath.js"
4
4
  import { applyFrameChanges } from "../layout/applyFrameChanges.js"
5
- import { getDragZones } from "../layout/getDragZones.js"
6
5
  import { getFrameDockInfo } from "../layout/getFrameDockInfo.js"
7
6
  import { getFrameRearrangeInfo } from "../layout/getFrameRearrangeInfo.js"
8
7
  import { getFrameSwapInfo } from "../layout/getFrameSwapInfo.js"
8
+ import { getZones } from "../layout/getZones.js"
9
9
  import { settings } from "../settings.js"
10
- import type { ActionDragChangeResult, DragState, DragZone, FrameDragDeco, IDragAction, LayoutChange } from "../types/index.js"
10
+ import type { ActionChangeResult, FrameDeco, IAction, LayoutChange, MoveState, Zone } from "../types/index.js"
11
11
  import type { KnownError } from "../utils/KnownError.js"
12
12
 
13
13
 
14
- export class FrameDragAction implements IDragAction {
14
+ export class FrameDragAction implements IAction {
15
15
  name = "frameDrag" as const
16
16
 
17
17
  minDragDistance = 5
@@ -25,8 +25,8 @@ export class FrameDragAction implements IDragAction {
25
25
  debug: boolean | string = false
26
26
  textHints: { actions: string[], errors: string[] } = { actions: [], errors: [] }
27
27
 
28
- handleEvent: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean
29
- = (_e: PointerEvent | KeyboardEvent, state: DragState) => state.isDragging === "frame"
28
+ handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean
29
+ = (_e: PointerEvent | KeyboardEvent, state: MoveState) => state.isMoving === "frame"
30
30
 
31
31
  dragHints: {
32
32
  actions: { split?: string, swap?: string, rearrange?: string, dock?: string } | ((state: { type: "split" | "swap" | "rearrange" | "dock" }) => string[])
@@ -41,7 +41,7 @@ export class FrameDragAction implements IDragAction {
41
41
  transformError: e => e.message
42
42
  }
43
43
 
44
- modifyDecos: (shapes: FrameDragDeco[]) => void = () => { }
44
+ modifyDecos: (shapes: FrameDeco[]) => void = () => { }
45
45
  hooks: {
46
46
  onStart?: () => void
47
47
  onCancel?: () => void
@@ -101,15 +101,15 @@ export class FrameDragAction implements IDragAction {
101
101
 
102
102
 
103
103
  getDecos(
104
- matchedZone: DragZone | undefined,
105
- state: DragState,
104
+ matchedZone: Zone | undefined,
105
+ state: MoveState,
106
106
  result: LayoutChange<"split" | "swap" | "rearrange" | "dock"> | KnownError | undefined
107
- ): FrameDragDeco[] {
107
+ ): FrameDeco[] {
108
108
  const isError = result instanceof Error
109
- const frame = state.dragHoveredFrame
109
+ const frame = state.moveHoveredFrame
110
110
 
111
111
  if (!matchedZone || !frame) {
112
- const decos: FrameDragDeco[] = []
112
+ const decos: FrameDeco[] = []
113
113
  this.modifyDecos(decos)
114
114
  return decos
115
115
  }
@@ -120,7 +120,7 @@ export class FrameDragAction implements IDragAction {
120
120
  ? `deco-frame-drag deco-frame-drag-error deco-frame-drag-${matchedZone.type}-${matchedZone.side} bg-red-500/50`
121
121
  : `deco-frame-drag deco-frame-drag-${matchedZone.type}-${matchedZone.side} bg-blue-500/50`
122
122
 
123
- const decos: FrameDragDeco[] = [{
123
+ const decos: FrameDeco[] = [{
124
124
  id: frame.id,
125
125
  type: "drop",
126
126
  position: matchedZone.side ?? "center",
@@ -139,7 +139,7 @@ export class FrameDragAction implements IDragAction {
139
139
  return decos
140
140
  }
141
141
 
142
- canHandleRequest(e: PointerEvent | KeyboardEvent, state: DragState): boolean {
142
+ canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean {
143
143
  const res = this.handleEvent(e, state)
144
144
  this.setTextHints(undefined)
145
145
  if (res) {
@@ -150,29 +150,29 @@ export class FrameDragAction implements IDragAction {
150
150
  return false
151
151
  }
152
152
 
153
- onDragChange<T extends "start" | "move" | "end">(
154
- _type: T,
153
+ onMoveChange<T extends "start" | "move" | "end">(
154
+ type: T,
155
155
  _e: PointerEvent | undefined,
156
- state: DragState
157
- ): ActionDragChangeResult {
158
- if (state.dragDistance <= this.minDragDistance) {
159
- return { updateEdges: false, shapes: [], showDragging: false }
156
+ state: MoveState
157
+ ): ActionChangeResult {
158
+ if (state.moveDistance <= this.minDragDistance) {
159
+ return { updateEdges: false, shapes: [], showMoving: false }
160
160
  }
161
- const { win, draggingFrameId, dragHoveredFrame } = state
162
- const matchedZone = getDragZones(state, settings.zoneSizes)
161
+ const { win, movingFrameId, moveHoveredFrame } = state
162
+ const matchedZone = getZones(state, settings.zoneSizes)
163
163
 
164
164
  if (!matchedZone) {
165
165
  this.state.lastReturn = undefined
166
- } else if (dragHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
166
+ } else if (moveHoveredFrame && matchedZone.type === "frame" && matchedZone.side) {
167
167
  if (matchedZone.side !== "center") {
168
- this.state.lastReturn = getFrameRearrangeInfo(win, draggingFrameId!, dragHoveredFrame.id!, matchedZone.side)
168
+ this.state.lastReturn = getFrameRearrangeInfo(win, movingFrameId!, moveHoveredFrame.id!, matchedZone.side)
169
169
  } else {
170
- this.state.lastReturn = getFrameSwapInfo(win, draggingFrameId!, dragHoveredFrame.id!)
170
+ this.state.lastReturn = getFrameSwapInfo(win, movingFrameId!, moveHoveredFrame.id!)
171
171
  // for the hints
172
172
  if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "swap"
173
173
  }
174
- } else if (matchedZone.type === "window" && dragHoveredFrame && !dragHoveredFrame.docked) {
175
- this.state.lastReturn = getFrameDockInfo(win, draggingFrameId!, matchedZone.side)
174
+ } else if (matchedZone.type === "window" && moveHoveredFrame && !moveHoveredFrame.docked) {
175
+ this.state.lastReturn = getFrameDockInfo(win, movingFrameId!, matchedZone.side)
176
176
  // for the hints
177
177
  if (!(this.state.lastReturn instanceof Error)) this.state.lastReturn.info = "dock"
178
178
  }
@@ -181,32 +181,33 @@ export class FrameDragAction implements IDragAction {
181
181
  const decos = this.getDecos(matchedZone, state, this.state.lastReturn)
182
182
 
183
183
  return {
184
- shapes: decos.flatMap(_ => _.shapes),
184
+ shapes: type === "end" ? [] : decos.flatMap(_ => _.shapes),
185
185
  updateEdges: false,
186
- showDragging: false
186
+ showMoving: false
187
187
  }
188
188
  }
189
189
 
190
- onDragApply(state: DragState): boolean {
190
+ onMoveApply(state: MoveState): boolean {
191
191
  const result = this.state.lastReturn
192
- if (!result || !state.dragHoveredFrame || !state.draggingFrameId) {
193
- this.reset()
192
+ if (!result || !state.moveHoveredFrame || !state.movingFrameId) {
194
193
  return true
195
194
  }
196
195
 
197
-
198
196
  if (result instanceof Error) {
199
197
  this.hooks.onError?.(result)
200
198
  } else {
201
- if (this.debug) { DragActionHandler.debugState(this.name, "before", state, this.state, this.debug) }
199
+ if (this.debug) { ActionHandler.debugState(this.name, "before", state, this.state, this.debug) }
202
200
  applyFrameChanges(state.win, result)
203
- if (this.debug) { DragActionHandler.debugState(this.name, "after", state, this.state, this.debug) }
201
+ if (this.debug) { ActionHandler.debugState(this.name, "after", state, this.state, this.debug) }
204
202
  }
205
203
 
206
- this.reset()
207
204
  return true
208
205
  }
209
206
 
207
+ onMoveEnded() {
208
+ this.reset()
209
+ }
210
+
210
211
  cancel(): void {
211
212
  this.reset()
212
213
  }
@@ -1,19 +1,19 @@
1
1
  import type { Direction, Orientation, Point } from "../types/index.js"
2
2
 
3
- export class DragDirectionStore {
3
+ export class MoveDirectionStore {
4
4
  hooks: {
5
5
  onUpdate: (directions: Record<Orientation, Direction | undefined>) => void
6
6
  }
7
7
 
8
8
  constructor(
9
- hooks: DragDirectionStore["hooks"]
9
+ hooks: MoveDirectionStore["hooks"]
10
10
  ) {
11
11
  this.hooks = hooks
12
12
  }
13
13
 
14
14
  lastPoint: Point | undefined
15
15
 
16
- dragDirection: Record<Orientation, Direction | undefined> = {} as any
16
+ moveDirection: Record<Orientation, Direction | undefined> = {} as any
17
17
 
18
18
  lesser: { x: Direction, y: Direction } = {
19
19
  x: "left",
@@ -27,20 +27,20 @@ export class DragDirectionStore {
27
27
 
28
28
  reset(): void {
29
29
  this.lastPoint = undefined
30
- this.dragDirection = {} as any
30
+ this.moveDirection = {} as any
31
31
  }
32
32
 
33
33
  update(point: Point): boolean {
34
34
  // eslint-disable-next-line @typescript-eslint/naming-convention
35
- const newXDirection = this.getDragDirection("x", point)
35
+ const newXDirection = this.getMoveDirection("x", point)
36
36
  // eslint-disable-next-line @typescript-eslint/naming-convention
37
- const newYDirection = this.getDragDirection("y", point)
37
+ const newYDirection = this.getMoveDirection("y", point)
38
38
  let changed = false
39
39
  if (newXDirection) {
40
- this.dragDirection.horizontal = newXDirection
40
+ this.moveDirection.horizontal = newXDirection
41
41
  }
42
42
  if (newYDirection) {
43
- this.dragDirection.vertical = newYDirection
43
+ this.moveDirection.vertical = newYDirection
44
44
  }
45
45
 
46
46
  if (this.lastPoint?.x !== point.x || this.lastPoint?.y !== point.y) {
@@ -49,11 +49,11 @@ export class DragDirectionStore {
49
49
  }
50
50
 
51
51
  if (!changed) return false
52
- this.hooks.onUpdate(this.dragDirection)
52
+ this.hooks.onUpdate(this.moveDirection)
53
53
  return true
54
54
  }
55
55
 
56
- getDragDirection(coord: "x" | "y", point: Point): Direction | false {
56
+ getMoveDirection(coord: "x" | "y", point: Point): Direction | false {
57
57
  if (!this.lastPoint) return false
58
58
  const diff = point[coord] - this.lastPoint![coord]
59
59
  if (diff > 0) return this.greater[coord]
@@ -1,11 +1,11 @@
1
- import { DragActionHandler } from "./DragActionHandler.js"
1
+ import { ActionHandler } from "./ActionHandler.js"
2
2
 
3
3
  import { getEdgeOrientation } from "../helpers/getEdgeOrientation.js"
4
4
  import { oppositeSide } from "../helpers/oppositeSide.js"
5
5
  import { applyFrameChanges } from "../layout/applyFrameChanges.js"
6
6
  import { createSplitDecoFromDrag } from "../layout/createSplitDecoFromDrag.js"
7
7
  import { getFrameSplitInfo } from "../layout/getFrameSplitInfo.js"
8
- import type { ActionDragChangeResult, DragState, IDragAction, LayoutShape, Point, SplitDeco } from "../types/index.js"
8
+ import type { ActionChangeResult, IAction, LayoutShape, MoveState, Point, SplitDeco } from "../types/index.js"
9
9
  import type { KnownError } from "../utils/KnownError.js"
10
10
 
11
11
  export type SplitInfo = Exclude<ReturnType<typeof getFrameSplitInfo>, KnownError>
@@ -14,7 +14,7 @@ export type SplitInfo = Exclude<ReturnType<typeof getFrameSplitInfo>, KnownError
14
14
 
15
15
  export type DragChangeType = "start" | "move" | "end"
16
16
 
17
- export class SplitAction implements IDragAction {
17
+ export class SplitAction implements IAction {
18
18
  name = "split" as const
19
19
  minDragDistance = 5
20
20
 
@@ -27,7 +27,7 @@ export class SplitAction implements IDragAction {
27
27
  allowed: false
28
28
  res: SplitInfo | undefined
29
29
  lastPoint: Point | undefined
30
- lastReturn: ActionDragChangeResult | undefined
30
+ lastReturn: ActionChangeResult | undefined
31
31
  } = {} as any // this is initialized by `this.reset()`
32
32
 
33
33
  debug: boolean | string = false
@@ -40,8 +40,8 @@ export class SplitAction implements IDragAction {
40
40
  transformError: e => e.message
41
41
  }
42
42
 
43
- handleEvent: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean
44
- = (e: PointerEvent | KeyboardEvent, state: DragState) => e.altKey || state.isDraggingFromWindowEdge
43
+ handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean
44
+ = (e: PointerEvent | KeyboardEvent, state: MoveState) => e.altKey || state.isMovingFromWindowEdge
45
45
 
46
46
  modifyDecos: (shapes: SplitDeco[]) => void = () => { }
47
47
  hooks: {
@@ -83,23 +83,23 @@ export class SplitAction implements IDragAction {
83
83
  this.modifyDecos([])
84
84
  }
85
85
 
86
- getDecos(state: DragState): SplitDeco[] {
86
+ getDecos(state: MoveState): SplitDeco[] {
87
87
  let decos: SplitDeco[] = []
88
88
  const {
89
89
  win,
90
- isDragging,
91
- dragHoveredFrame,
92
- dragDirections,
93
- draggingEdges,
94
- dragPoint
90
+ isMoving,
91
+ moveHoveredFrame,
92
+ moveDirections,
93
+ movingEdges,
94
+ movePoint
95
95
  } = state
96
- if (isDragging && this.state.allowed && dragHoveredFrame && draggingEdges.length === 1) {
97
- const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]))
96
+ if (isMoving && this.state.allowed && moveHoveredFrame && movingEdges.length === 1) {
97
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(movingEdges[0]))
98
98
  const deco = createSplitDecoFromDrag(
99
99
  win.frames,
100
- dragHoveredFrame,
101
- dragDirections[oppositeOrientation]!,
102
- dragPoint!
100
+ moveHoveredFrame,
101
+ moveDirections[oppositeOrientation]!,
102
+ movePoint!
103
103
  )
104
104
  decos = [deco]
105
105
  }
@@ -107,11 +107,11 @@ export class SplitAction implements IDragAction {
107
107
  return decos
108
108
  }
109
109
 
110
- canHandleRequest(e: PointerEvent | KeyboardEvent, state: DragState): boolean {
111
- const { draggingEdges } = state
112
- if (draggingEdges.length !== 1) return false
110
+ canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean {
111
+ const { movingEdges } = state
112
+ if (movingEdges.length !== 1) return false
113
113
  // hint should not be shown when dragging from window edge but we should still handle the event
114
- this.setTextHints(state.isDragging === "edge" && !state.isDraggingFromWindowEdge ? true : undefined)
114
+ this.setTextHints(state.isMoving === "edge" && !state.isMovingFromWindowEdge ? true : undefined)
115
115
  if (this.handleEvent(e, state)) {
116
116
  this.hooks.onStart?.()
117
117
  return true
@@ -144,26 +144,26 @@ export class SplitAction implements IDragAction {
144
144
  return this.textHints
145
145
  }
146
146
 
147
- calculateSplitRequest(state: DragState): boolean {
147
+ calculateSplitRequest(state: MoveState): boolean {
148
148
  const {
149
- dragHoveredFrame,
150
- dragDirections,
151
- draggingEdges,
152
- dragPoint,
149
+ moveHoveredFrame,
150
+ moveDirections,
151
+ movingEdges,
152
+ movePoint,
153
153
  win
154
154
  } = state
155
- const oppositeOrientation = oppositeSide(getEdgeOrientation(draggingEdges[0]))
156
- const originalDragHoveredFrame = win.frames[dragHoveredFrame!.id]
155
+ const oppositeOrientation = oppositeSide(getEdgeOrientation(movingEdges[0]))
156
+ const originalDragHoveredFrame = win.frames[moveHoveredFrame!.id]
157
157
  const canSplit = getFrameSplitInfo(
158
158
  originalDragHoveredFrame!,
159
- dragDirections[oppositeOrientation]!,
160
- dragPoint!
159
+ moveDirections[oppositeOrientation]!,
160
+ movePoint!
161
161
  )
162
- this.setTextHints(state.isDragging === "edge" && !state.isDraggingFromWindowEdge ? canSplit : undefined)
162
+ this.setTextHints(state.isMoving === "edge" && !state.isMovingFromWindowEdge ? canSplit : undefined)
163
163
  if (!(canSplit instanceof Error)) {
164
164
  this.state.allowed = true
165
165
  this.state.res = canSplit
166
- this.state.lastPoint = dragPoint ? { ...dragPoint } : undefined
166
+ this.state.lastPoint = movePoint ? { ...movePoint } : undefined
167
167
  return true
168
168
  } else {
169
169
  this.hooks.onError?.(canSplit)
@@ -173,18 +173,18 @@ export class SplitAction implements IDragAction {
173
173
  }
174
174
  }
175
175
 
176
- onDragChange(
177
- _type: "start" | "end" | "move",
176
+ onMoveChange(
177
+ type: "start" | "end" | "move",
178
178
  _e: PointerEvent | undefined,
179
- state: DragState
180
- ): ActionDragChangeResult {
181
- const { dragHoveredFrame, dragDistance } = state
182
- if (dragDistance <= this.minDragDistance) {
183
- return { updateEdges: false, shapes: [], showDragging: false }
179
+ state: MoveState
180
+ ): ActionChangeResult {
181
+ const { moveHoveredFrame, moveDistance } = state
182
+ if (moveDistance <= this.minDragDistance) {
183
+ return { updateEdges: false, shapes: [], showMoving: false }
184
184
  }
185
185
  let ok = false
186
- if (dragHoveredFrame) {
187
- if (this.state.lastPoint?.x === state.dragPoint?.x && this.state.lastPoint?.y === state.dragPoint?.y && this.state.lastReturn) {
186
+ if (moveHoveredFrame) {
187
+ if (this.state.lastPoint?.x === state.movePoint?.x && this.state.lastPoint?.y === state.movePoint?.y && this.state.lastReturn) {
188
188
  return this.state.lastReturn!
189
189
  }
190
190
  ok = this.calculateSplitRequest(state)
@@ -192,42 +192,52 @@ export class SplitAction implements IDragAction {
192
192
  const decos = this.getDecos(state)
193
193
 
194
194
  if (!ok) {
195
- if (dragHoveredFrame && dragHoveredFrame.docked) {
195
+ if (moveHoveredFrame && moveHoveredFrame.docked) {
196
196
  const errorDeco: LayoutShape = {
197
197
  type: "rect",
198
198
  data: {
199
- x: dragHoveredFrame.x,
200
- y: dragHoveredFrame.y,
201
- width: dragHoveredFrame.width,
202
- height: dragHoveredFrame.height
199
+ x: moveHoveredFrame.x,
200
+ y: moveHoveredFrame.y,
201
+ width: moveHoveredFrame.width,
202
+ height: moveHoveredFrame.height
203
203
  },
204
204
  attrs: { class: "deco-split-error bg-red-500/50" }
205
205
  }
206
- this.state.lastReturn = { updateEdges: true, shapes: [errorDeco], showDragging: false }
206
+ this.state.lastReturn = {
207
+ updateEdges: true,
208
+ shapes: type === "end" ? [] : [errorDeco],
209
+ showMoving: false
210
+ }
207
211
  return this.state.lastReturn
208
212
  }
209
213
  }
210
- this.state.lastReturn = { updateEdges: false, shapes: decos.flatMap(_ => _.shapes), showDragging: false }
214
+ this.state.lastReturn = {
215
+ updateEdges: false,
216
+ shapes: type === "end" ? [] : decos.flatMap(_ => _.shapes),
217
+ showMoving: false
218
+ }
211
219
  return this.state.lastReturn
212
220
  }
213
221
 
214
- onDragApply(state: DragState): boolean {
215
- if (this.state.res && state.dragHoveredFrame) {
222
+ onMoveApply(state: MoveState): boolean {
223
+ if (this.state.res && state.moveHoveredFrame) {
216
224
  // this only caches once per frame hovered over
217
225
  // so the drag position is outdated, we must recalculate
218
226
  const ok = this.calculateSplitRequest(state)
219
227
  if (ok) {
220
- if (this.debug) { DragActionHandler.debugState(this.name, "before", state, this.state, this.debug) }
228
+ if (this.debug) { ActionHandler.debugState(this.name, "before", state, this.state, this.debug) }
221
229
  applyFrameChanges(state.win, this.state.res!)
222
- if (this.debug) { DragActionHandler.debugState(this.name, "after", state, this.state, this.debug) }
230
+ if (this.debug) { ActionHandler.debugState(this.name, "after", state, this.state, this.debug) }
223
231
  }
224
232
  }
225
- this.reset()
226
233
  return true
227
234
  }
228
235
 
229
- cancel(): void {
236
+ onMoveEnded() {
230
237
  this.reset()
238
+ }
239
+
240
+ cancel(): void {
231
241
  this.hooks.onCancel?.()
232
242
  }
233
243
  }
@@ -2,7 +2,7 @@ import { CloseAction } from "./CloseAction"
2
2
  import { FrameDragAction } from "./FrameDragAction.js"
3
3
  import { SplitAction } from "./SplitAction.js"
4
4
 
5
- import type { IDragAction } from "../types/index.js"
5
+ import type { IAction } from "../types/index.js"
6
6
 
7
7
  /**
8
8
  * Creates the default drag actions (Split, Close, FrameDrag).
@@ -11,7 +11,7 @@ export function createDefaultHandlers(config: {
11
11
  debugSplit?: boolean
12
12
  debugClose?: boolean
13
13
  debugFrameDrag?: boolean
14
- } = {}): IDragAction[] {
14
+ } = {}): IAction[] {
15
15
  return [
16
16
  new SplitAction(undefined, undefined, undefined, { debug: config.debugSplit }),
17
17
  new CloseAction(undefined, undefined, undefined, { debug: config.debugClose }),