@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
@@ -118,7 +118,7 @@ const zCloseDeco = zBaseDeco.extend({
118
118
  type: z.literal("close"),
119
119
  force: z.boolean().optional()
120
120
  });
121
- const zFrameDragDeco = zBaseDeco.extend({
121
+ const zFrameDeco = zBaseDeco.extend({
122
122
  id: z.uuid(),
123
123
  type: z.literal("drop"),
124
124
  position: zSide.or(z.enum(["center"]))
@@ -126,7 +126,7 @@ const zFrameDragDeco = zBaseDeco.extend({
126
126
  export const zDeco = z.union([
127
127
  zSplitDeco,
128
128
  zCloseDeco,
129
- zFrameDragDeco
129
+ zFrameDeco
130
130
  ]);
131
131
  export const LAYOUT_ERROR = enumFromArray([
132
132
  "INVALID_ID",
@@ -153,7 +153,8 @@ export const LAYOUT_ERROR = enumFromArray([
153
153
  "CANT_COLLAPSE_NOT_DOCKED",
154
154
  "CANT_UNCOLLAPSE_NOT_COLLAPSED",
155
155
  "NO_FILL_CANDIDATES",
156
- "CANT_RESIZE_COLLAPSED_FRAME"
156
+ "CANT_RESIZE_COLLAPSED_FRAME",
157
+ "CANT_RESIZE_SINGLE_FRAME"
157
158
  ]);
158
159
  export const zWindowCreate = zLayoutWindowLoose.partial({ id: true, pxWidth: true, pxHeight: true, pxX: true, pxY: true }).extend({ frames: zLayoutWindow.shape.frames.optional() });
159
160
  export const zLayoutCreate = baseLayout.loose().extend({
@@ -1,5 +1,5 @@
1
1
  import type { ComputedRef, InjectionKey, Ref } from "vue";
2
- import type { Direction, DragState, Edge, FrameId, IntersectionEntry, LayoutFrame, LayoutShape, LayoutWindow, Orientation, Point } from "./index.js";
2
+ import type { ActionHandler, ActionHandlerApplyResult, Direction, Edge, FrameId, IntersectionEntry, LayoutFrame, LayoutShape, LayoutWindow, MoveState, Orientation, Point } from "./index.js";
3
3
  export type LayoutContext = ComputedRef<{
4
4
  /** The owning window, needed so we can correctly scale coordinates. */
5
5
  win: LayoutWindow;
@@ -8,34 +8,41 @@ export type LayoutContext = ComputedRef<{
8
8
  }>;
9
9
  export declare const layoutContextInjectionKey: InjectionKey<LayoutContext>;
10
10
  export interface UseFramesContext {
11
- dragStart: {
11
+ actionHandler: ActionHandler;
12
+ moveStart: {
12
13
  (e: PointerEvent, type: "edge", data: {
13
14
  edge?: Edge;
14
15
  intersection?: IntersectionEntry;
15
- }): void;
16
+ }, opts?: {
17
+ moveEvent?: string;
18
+ endEvent?: string;
19
+ context?: Record<string, unknown>;
20
+ }): Promise<any>;
16
21
  (e: PointerEvent, type: "frame", data: {
17
22
  frameId: FrameId;
18
- }): void;
23
+ }, opts?: {
24
+ moveEvent?: string;
25
+ endEvent?: string;
26
+ context?: Record<string, unknown>;
27
+ }): Promise<any>;
19
28
  };
20
- dragMove: (e: PointerEvent) => void;
21
- dragEnd: (e?: PointerEvent, options?: {
22
- apply?: boolean;
23
- }) => void;
29
+ onMove: (e: PointerEvent) => void;
30
+ moveEnd: (e?: PointerEvent, options?: Partial<Pick<ActionHandlerApplyResult, "apply">>) => void;
24
31
  cancel: () => void;
25
- dragDirections: Ref<Record<Orientation, Direction | undefined>>;
26
- dragPoint: Ref<Point | undefined>;
27
- isDragging: Ref<false | "frame" | "edge">;
28
- draggingEdges: Ref<Edge[]>;
29
- draggingIntersection: Ref<IntersectionEntry | undefined>;
32
+ moveDirections: Ref<Record<Orientation, Direction | undefined>>;
33
+ movePoint: Ref<Point | undefined>;
34
+ isMoving: Ref<false | "frame" | "edge">;
35
+ movingEdges: Ref<Edge[]>;
36
+ movingIntersection: Ref<IntersectionEntry | undefined>;
30
37
  visualEdges: Ref<Edge[]>;
31
38
  touchingFrames: Ref<Record<string, LayoutFrame>[]>;
32
39
  touchingFramesArrays: Ref<LayoutFrame[][]>;
33
40
  frames: ComputedRef<Record<string, LayoutFrame>>;
34
- dragHoveredFrame: ComputedRef<LayoutFrame | undefined>;
41
+ moveHoveredFrame: ComputedRef<LayoutFrame | undefined>;
35
42
  intersections: ComputedRef<IntersectionEntry[]>;
36
- isDraggingFromWindowEdge: Ref<boolean>;
43
+ isMovingFromWindowEdge: Ref<boolean>;
37
44
  forceRecalculateEdges: () => void;
38
- state: ComputedRef<DragState>;
39
- frameDragFrameId: Ref<FrameId | undefined>;
45
+ state: ComputedRef<MoveState>;
46
+ movingFrameId: Ref<FrameId | undefined>;
40
47
  }
41
- export declare const dragContextInjectionKey: InjectionKey<UseFramesContext>;
48
+ export declare const moveContextInjectionKey: InjectionKey<UseFramesContext>;
@@ -1,2 +1,2 @@
1
1
  export const layoutContextInjectionKey = Symbol.for("@witchcraft/layout:context");
2
- export const dragContextInjectionKey = Symbol.for("@witchcraft/layout:dragContext");
2
+ export const moveContextInjectionKey = Symbol.for("@witchcraft/layout:moveContext");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.4.3",
4
+ "version": "0.5.0",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -49,6 +49,7 @@
49
49
  "@alanscodelog/semantic-release-config": "^6.0.2",
50
50
  "@alanscodelog/tsconfigs": "^6.3.0",
51
51
  "@alanscodelog/vite-config": "^0.0.7",
52
+ "@babel/runtime": "^7.20.7",
52
53
  "@commitlint/cli": "^19.8.1",
53
54
  "@nuxt/eslint-config": "^1.15.2",
54
55
  "@nuxt/kit": "^4.4.6",
@@ -145,6 +146,6 @@
145
146
  "doc:dev": "concurrently \"pnpm doc:watch\" \"pnpm doc:serve\"",
146
147
  "doc:check-invalid": "typedoc --listInvalidSymbolLinks",
147
148
  "actions:debug": "act -r -v -j release",
148
- "gen:exports": "indexit update --ignore **/*.d.ts **.vue src/assets/** -o '${path}.js'"
149
+ "gen:exports": "indexit update --ignore **/*.d.ts **.vue src/assets/** **/demo/** **/dist/** -o '${path}.js'"
149
150
  }
150
151
  }
@@ -8,21 +8,21 @@
8
8
  </template>
9
9
  <script lang="ts" setup>
10
10
  import { inject, onBeforeUnmount } from "vue"
11
- import { dragContextInjectionKey } from "../types/vue.js"
11
+ import { moveContextInjectionKey } from "../types/vue.js"
12
12
 
13
13
  const props = defineProps<{
14
14
  frameId: string
15
15
  }>()
16
16
 
17
17
 
18
- const dragContext = inject(dragContextInjectionKey)
18
+ const dragContext = inject(moveContextInjectionKey)
19
19
  if (!dragContext) {
20
20
  throw new Error("FrameDragHandle must be used inside a LayoutWindow and drag context returned by useFrames must be injected.")
21
21
  }
22
22
  function handlePointerDown(e: PointerEvent): void {
23
23
  e.preventDefault()
24
24
  e.stopPropagation()
25
- dragContext!.dragStart( e,"frame", {frameId: props.frameId})
25
+ dragContext!.moveStart( e,"frame", {frameId: props.frameId})
26
26
  }
27
27
  onBeforeUnmount(() => {
28
28
  dragContext.cancel()
@@ -16,7 +16,7 @@
16
16
  />
17
17
  </template>
18
18
  <script lang="ts" setup>
19
- import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
19
+ import { moveContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
20
20
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
21
21
  import { computed, inject, useAttrs } from "vue"
22
22
 
@@ -34,10 +34,10 @@ defineOptions({
34
34
  const ctx = inject(layoutContextInjectionKey, undefined)
35
35
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
36
36
 
37
- const dragCtx = inject(dragContextInjectionKey, undefined)
37
+ const dragCtx = inject(moveContextInjectionKey, undefined)
38
38
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
39
39
 
40
- const draggingEdge = computed(() => dragCtx.draggingEdges.value.length === 1 ? dragCtx.draggingEdges.value[0] : undefined)
40
+ const draggingEdge = computed(() => dragCtx.movingEdges.value.length === 1 ? dragCtx.movingEdges.value[0] : undefined)
41
41
 
42
42
  const cssDragEdge = computed(() => {
43
43
  if (!draggingEdge.value) return []
@@ -26,8 +26,8 @@ import { twMerge } from "@witchcraft/ui/utils/twMerge"
26
26
  import { useAttrs, inject } from "vue"
27
27
 
28
28
  import LayoutShapeRect from "./LayoutShapeRect.vue"
29
- import { type EdgeDragStartData } from "../types/index.js"
30
- import { dragContextInjectionKey } from "../types/vue.js"
29
+ import { type EdgeMoveStartData } from "../types/index.js"
30
+ import { moveContextInjectionKey } from "../types/vue.js"
31
31
  import type { Edge, EdgeCss } from "../types/index.js"
32
32
 
33
33
  const $attrs = useAttrs()
@@ -39,13 +39,13 @@ defineOptions({
39
39
  const props = defineProps<{
40
40
  edge: Edge
41
41
  css: EdgeCss
42
- onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeDragStartData) => void
42
+ onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeMoveStartData) => void
43
43
  }>()
44
44
 
45
45
  const ctx = inject(layoutContextInjectionKey, undefined)
46
46
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
47
47
 
48
- const dragCtx = inject(dragContextInjectionKey, undefined)
48
+ const dragCtx = inject(moveContextInjectionKey, undefined)
49
49
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
50
50
 
51
51
  </script>
@@ -6,12 +6,12 @@
6
6
  <slot name="handle" v-bind="{
7
7
  css: css.handle,
8
8
  edge: visualEdges[i],
9
- onPointerDown: dragCtx.dragStart
9
+ onPointerDown: dragCtx.moveStart
10
10
  }">
11
11
  <LayoutDragEdgeHandle
12
12
  :css="css.handle"
13
13
  :edge="visualEdges[i]"
14
- :on-pointer-down="dragCtx.dragStart"
14
+ :on-pointer-down="dragCtx.moveStart"
15
15
  />
16
16
  </slot>
17
17
  <slot name="indicator" v-bind="{
@@ -37,7 +37,7 @@ import { isEdgeEqual } from "../helpers/isEdgeEqual.js"
37
37
  import { toRef } from "vue"
38
38
  import {cssToKey} from "../utils/cssToKey.js"
39
39
  import { type EdgeCss } from "../types/index.js"
40
- import { dragContextInjectionKey } from "../types/vue.js"
40
+ import { moveContextInjectionKey } from "../types/vue.js"
41
41
 
42
42
  defineOptions({
43
43
  inheritAttrs: false
@@ -46,13 +46,13 @@ defineOptions({
46
46
  const ctx = inject(layoutContextInjectionKey, undefined)
47
47
  if (!ctx) throw new Error("LayoutEdges must be used wivisible a LayoutWindow")
48
48
 
49
- const dragCtx = inject(dragContextInjectionKey, undefined)
49
+ const dragCtx = inject(moveContextInjectionKey, undefined)
50
50
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
51
51
 
52
52
 
53
53
  const visualEdges = toRef(dragCtx, "visualEdges")
54
54
 
55
- const draggingEdge = computed(() => dragCtx.draggingEdges.value.length === 1 ? dragCtx.draggingEdges.value[0] : undefined)
55
+ const draggingEdge = computed(() => dragCtx.movingEdges.value.length === 1 ? dragCtx.movingEdges.value[0] : undefined)
56
56
 
57
57
  const cssDragEdges = computed(() => {
58
58
  const handleEdges = getVisualEdgesCss(
@@ -17,7 +17,7 @@
17
17
  </template>
18
18
 
19
19
  <script lang="ts" setup>
20
- import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
20
+ import { moveContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
21
21
  import { computed, inject, useAttrs } from "vue"
22
22
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
23
23
 
@@ -34,7 +34,7 @@ defineOptions({
34
34
  const ctx = inject(layoutContextInjectionKey, undefined)
35
35
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
36
36
 
37
- const dragCtx = inject(dragContextInjectionKey, undefined)
37
+ const dragCtx = inject(moveContextInjectionKey, undefined)
38
38
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
39
39
 
40
40
 
@@ -25,7 +25,7 @@
25
25
  </template>
26
26
 
27
27
  <script lang="ts" setup>
28
- import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
28
+ import { moveContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
29
29
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
30
30
  import { useAttrs, inject, toRef } from "vue"
31
31
 
@@ -48,7 +48,7 @@ const emit = defineEmits<{
48
48
  const ctx = inject(layoutContextInjectionKey, undefined)
49
49
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
50
50
 
51
- const dragCtx = inject(dragContextInjectionKey, undefined)
51
+ const dragCtx = inject(moveContextInjectionKey, undefined)
52
52
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
53
53
 
54
54
  const frames = toRef(dragCtx, "frames")
@@ -20,8 +20,8 @@ import { twMerge } from "@witchcraft/ui/utils/twMerge"
20
20
  import LayoutShapeRect from "./LayoutShapeRect.vue"
21
21
 
22
22
  import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js"
23
- import { type EdgeDragStartData } from "../types/index.js"
24
- import { dragContextInjectionKey } from "../types/vue.js"
23
+ import { type EdgeMoveStartData } from "../types/index.js"
24
+ import { moveContextInjectionKey } from "../types/vue.js"
25
25
  import type { IntersectionEntry } from "../types/index.js"
26
26
 
27
27
  const $attrs = useAttrs()
@@ -33,13 +33,13 @@ defineOptions({
33
33
  const props = defineProps<{
34
34
  css: ReturnType<typeof getIntersectionsCss>[number]
35
35
  intersection: IntersectionEntry
36
- onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeDragStartData) => void
36
+ onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeMoveStartData) => void
37
37
  }>()
38
38
 
39
39
  const ctx = inject(layoutContextInjectionKey, undefined)
40
40
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
41
41
 
42
- const dragCtx = inject(dragContextInjectionKey, undefined)
42
+ const dragCtx = inject(moveContextInjectionKey, undefined)
43
43
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
44
44
 
45
45
  </script>
@@ -5,13 +5,13 @@
5
5
  >
6
6
  <slot name="handler" v-bind="{
7
7
  css: css.handle,
8
- onPointerDown: dragCtx.dragStart,
8
+ onPointerDown: dragCtx.moveStart,
9
9
  intersection: draggableIntersections[i]
10
10
  }">
11
11
  <LayoutIntersectionHandle
12
12
  :css="css.handle"
13
13
  :intersection="draggableIntersections[i]"
14
- :on-pointer-down="dragCtx.dragStart"
14
+ :on-pointer-down="dragCtx.moveStart"
15
15
  />
16
16
  </slot>
17
17
  <slot name="indicator" v-bind="{ css: css.visible, intersection: draggableIntersections[i] }">
@@ -23,7 +23,7 @@
23
23
  </template>
24
24
 
25
25
  <script lang="ts" setup>
26
- import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
26
+ import { moveContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js"
27
27
  import { computed, inject } from "vue"
28
28
 
29
29
 
@@ -40,7 +40,7 @@ defineOptions({
40
40
  const ctx = inject(layoutContextInjectionKey, undefined)
41
41
  if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow")
42
42
 
43
- const dragCtx = inject(dragContextInjectionKey, undefined)
43
+ const dragCtx = inject(moveContextInjectionKey, undefined)
44
44
  if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow")
45
45
 
46
46
  const draggableIntersections = computed(() => dragCtx.intersections.value
@@ -7,7 +7,7 @@
7
7
  flex
8
8
  flex-col
9
9
  `,
10
- isDragging && `dragging cursor-pointer user-select-none`,
10
+ isMoving && `dragging cursor-pointer user-select-none pointer-events-none`,
11
11
  requestType && `request-${requestType}`,
12
12
  ($attrs as any).class
13
13
  )"
@@ -23,25 +23,25 @@
23
23
  </template>
24
24
  </div>
25
25
  <Teleport
26
- v-if="isDragging === 'frame' && frameDragFrameId && dragPoint"
26
+ v-if="isMoving === 'frame' && movingFrameId && movePoint"
27
27
  :to="ghostTeleportTo"
28
28
  defer
29
29
  >
30
30
  <div
31
31
  class="fixed z-[9999] pointer-events-none"
32
32
  :style="{
33
- left: (dragPoint.x / settings.maxInt * win.pxWidth + win.pxX) + 'px',
34
- top: (dragPoint.y / settings.maxInt * win.pxHeight + win.pxY) + 'px',
35
- width: frames[frameDragFrameId]
36
- ? (frames[frameDragFrameId].width / settings.maxInt * win.pxWidth) + 'px'
33
+ left: (movePoint.x / settings.maxInt * win.pxWidth + win.pxX) + 'px',
34
+ top: (movePoint.y / settings.maxInt * win.pxHeight + win.pxY) + 'px',
35
+ width: frames[movingFrameId]
36
+ ? (frames[movingFrameId].width / settings.maxInt * win.pxWidth) + 'px'
37
37
  : undefined,
38
- height: frames[frameDragFrameId]
39
- ? (frames[frameDragFrameId].height / settings.maxInt * win.pxHeight) + 'px'
38
+ height: frames[movingFrameId]
39
+ ? (frames[movingFrameId].height / settings.maxInt * win.pxHeight) + 'px'
40
40
  : undefined
41
41
  }"
42
42
  >
43
43
  <slot
44
- :id="frameDragFrameId"
44
+ :id="movingFrameId"
45
45
  :name="`frame-drag-ghost`"
46
46
  >
47
47
  <div class="frame-drag-ghost border border-neutral-500 bg-white/50 w-10 h-10"/>
@@ -70,14 +70,14 @@
70
70
  <script lang="ts" setup>
71
71
  import { useGlobalResizeObserver } from "@witchcraft/ui/composables/useGlobalResizeObserver"
72
72
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
73
- import { computed, provide, reactive, ref, useAttrs, watch } from "vue"
73
+ import { computed, markRaw, provide, reactive, ref, useAttrs, watch } from "vue"
74
74
 
75
75
 
76
76
  import { useFrames } from "../composables/useFrames.js"
77
- import { createDefaultHandlers } from "../drag/createDefaultHandlers.js"
78
- import { DragActionHandler } from "../drag/DragActionHandler"
79
- import { dragContextInjectionKey } from "../types/vue.js"
80
- import { type DragState, type IDragAction } from "../types/index.js"
77
+ import { createDefaultHandlers } from "../move/createDefaultHandlers.js"
78
+ import { ActionHandler } from "../move/ActionHandler"
79
+ import { moveContextInjectionKey } from "../types/vue.js"
80
+ import { type MoveState, type IAction } from "../types/index.js"
81
81
  import { getUpdateWindowSizeInfo } from "../layout/getUpdateWindowSizeInfo.js"
82
82
  import { windowSetActiveFrame } from "../layout/windowSetActiveFrame.js"
83
83
  import { type LayoutWindow } from "../types/index.js"
@@ -90,10 +90,10 @@ const $attrs = useAttrs()
90
90
  const win = defineModel<LayoutWindow>("win", { required: true })
91
91
 
92
92
  const props = withDefaults(defineProps<{
93
- /** If you really need it, you can provide your own drag action handler, note the actionHandler's prop will no longer have any effect.*/
94
- dragActionHandler?: DragActionHandler<any, any>
93
+ /** If you really need it, you can provide your own drag action handler (remember to markRaw it), note the actionHandler's prop will no longer have any effect.*/
94
+ actionHandler?: ActionHandler<any, any>
95
95
  /** Custom drag action handlers. Falls back to default split/close/frame handlers if not provided. */
96
- actionHandlers?: IDragAction[]
96
+ actionHandlers?: IAction[]
97
97
  textHints?: {text:string, classes?:string}[]
98
98
  textHintsTeleportTo: string | undefined
99
99
  ghostTeleportTo?: string
@@ -113,8 +113,8 @@ const props = withDefaults(defineProps<{
113
113
  allowWindowSizeUpdate: true
114
114
  })
115
115
  const emit = defineEmits<{
116
- (e: "isShowingDrag", value: boolean): void
117
- (e: "dragState", value: DragState): void
116
+ (e: "isShowingMove", value: boolean): void
117
+ (e: "moveState", value: MoveState): void
118
118
  }>()
119
119
 
120
120
 
@@ -122,13 +122,13 @@ const windowEl = ref<HTMLElement | null>(null)
122
122
 
123
123
  const requestType = ref<string | undefined | string>()
124
124
 
125
- const dragActionHandler = props.dragActionHandler ?? new DragActionHandler(
125
+ const actionHandler = props.actionHandler ?? markRaw(new ActionHandler(
126
126
  [
127
127
  ...(props.actionHandlers ?? createDefaultHandlers())
128
128
  ],
129
129
  {
130
130
  onEvent: (e, cancel) => {
131
- showDragging.value = true
131
+ showMoving.value = true
132
132
  if (e instanceof KeyboardEvent && e.key === "Escape") {
133
133
  cancel()
134
134
  }
@@ -138,29 +138,29 @@ const dragActionHandler = props.dragActionHandler ?? new DragActionHandler(
138
138
  },
139
139
  onEnd: () => {
140
140
  requestType.value = undefined
141
- showDragging.value = true
141
+ showMoving.value = true
142
142
  },
143
143
  }
144
- )
145
- dragActionHandler.shapes = reactive([])
146
- dragActionHandler.textHints = reactive({ actions: [], errors: [] })
147
- const shapes = dragActionHandler.shapes
144
+ ))
145
+ actionHandler.shapes = reactive([])
146
+ actionHandler.textHints = reactive({ actions: [], errors: [] })
147
+ const shapes = actionHandler.shapes
148
148
 
149
149
  const dragContext = useFrames(
150
150
  win,
151
- dragActionHandler
151
+ actionHandler
152
152
  )
153
153
 
154
154
  const {
155
- dragPoint,
156
- isDragging,
155
+ movePoint,
156
+ isMoving,
157
157
  frames,
158
158
  state,
159
- frameDragFrameId,
160
- showDragging,
159
+ movingFrameId,
160
+ showMoving,
161
161
  } = dragContext
162
162
 
163
- provide(dragContextInjectionKey, dragContext)
163
+ provide(moveContextInjectionKey, dragContext)
164
164
 
165
165
  function getWindowOffset() {
166
166
  const windowElRect = windowEl.value!.getBoundingClientRect()
@@ -192,8 +192,8 @@ watch(() => props.allowWindowSizeUpdate, (newval, oldval) => {
192
192
  })
193
193
 
194
194
 
195
- watch(state, () => emit("dragState", state.value))
196
- watch(showDragging, () => emit("isShowingDrag", showDragging.value))
195
+ watch(state, () => emit("moveState", state.value))
196
+ watch(showMoving, () => emit("isShowingMove", showMoving.value))
197
197
 
198
198
  const layoutContext = computed(() => {
199
199
  return {
@@ -208,7 +208,7 @@ defineExpose({
208
208
  state,
209
209
  win,
210
210
  getUpdateWindowSizeInfo,
211
- dragActionHandler: dragActionHandler as DragActionHandler<any, any>,
211
+ actionHandler: actionHandler as ActionHandler<any, any>,
212
212
  })
213
213
  </script>
214
214