@witchcraft/layout 0.5.8 → 0.5.9
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.
- package/dist/module.json +1 -1
- package/dist/runtime/components/LayoutWindow.vue +0 -2
- package/dist/runtime/move/ActionHandler.d.ts +1 -1
- package/dist/runtime/move/ActionHandler.js +1 -1
- package/dist/runtime/move/CloseAction.d.ts +2 -2
- package/dist/runtime/move/CloseAction.js +2 -2
- package/dist/runtime/move/FrameDragAction.d.ts +2 -2
- package/dist/runtime/move/SplitAction.d.ts +2 -2
- package/dist/runtime/move/SplitAction.js +1 -1
- package/dist/runtime/types/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/runtime/components/LayoutWindow.vue +0 -2
- package/src/runtime/move/ActionHandler.ts +3 -3
- package/src/runtime/move/CloseAction.ts +4 -4
- package/src/runtime/move/FrameDragAction.ts +3 -3
- package/src/runtime/move/SplitAction.ts +3 -3
- package/src/runtime/types/index.ts +3 -1
package/dist/module.json
CHANGED
|
@@ -98,7 +98,6 @@ const actionHandler = props.actionHandler ?? markRaw(new ActionHandler(
|
|
|
98
98
|
],
|
|
99
99
|
{
|
|
100
100
|
onEvent: (e, cancel) => {
|
|
101
|
-
showMoving.value = true;
|
|
102
101
|
if (e instanceof KeyboardEvent && e.key === "Escape") {
|
|
103
102
|
cancel();
|
|
104
103
|
}
|
|
@@ -108,7 +107,6 @@ const actionHandler = props.actionHandler ?? markRaw(new ActionHandler(
|
|
|
108
107
|
},
|
|
109
108
|
onEnd: () => {
|
|
110
109
|
requestType.value = void 0;
|
|
111
|
-
showMoving.value = true;
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
));
|
|
@@ -43,7 +43,7 @@ export declare class ActionHandler<TRawActions extends IAction[], TActions exten
|
|
|
43
43
|
* The default prevents movement when the edge is a window edge and when the edge is touching a collapsed frame.
|
|
44
44
|
*/
|
|
45
45
|
defaultOnMoveChange?: IAction["onMoveChange"]);
|
|
46
|
-
eventHandler(e: KeyboardEvent | PointerEvent, state: MoveState, forceRecalculateEdges: () => void): undefined;
|
|
46
|
+
eventHandler(e: KeyboardEvent | PointerEvent | undefined, state: MoveState, forceRecalculateEdges: () => void): undefined;
|
|
47
47
|
onMoveChange<T extends "start" | "move" | "end">(type: T, e: T extends "end" | "start" ? PointerEvent | undefined : PointerEvent, state: MoveState, forceRecalculateEdges: () => void, cancel: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => void, resolve: T extends "end" ? undefined : ((opts: ActionResolve) => void)): MoveChangeResult;
|
|
48
48
|
onMoveApply(state: MoveState, forceRecalculateEdges: () => void): ActionHandlerApplyResult;
|
|
49
49
|
onMoveEnded(): void;
|
|
@@ -29,7 +29,7 @@ export declare class CloseAction implements IAction {
|
|
|
29
29
|
}) => string[]);
|
|
30
30
|
transformError: (e: KnownError) => string;
|
|
31
31
|
};
|
|
32
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean | "force";
|
|
32
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean | "force";
|
|
33
33
|
modifyDecos: (shapes: CloseDeco[]) => void;
|
|
34
34
|
hooks: {
|
|
35
35
|
onStart?: (active: boolean) => void;
|
|
@@ -51,7 +51,7 @@ export declare class CloseAction implements IAction {
|
|
|
51
51
|
actions: string[];
|
|
52
52
|
errors: string[];
|
|
53
53
|
};
|
|
54
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean;
|
|
54
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean;
|
|
55
55
|
onMoveChange(type: "start" | "end" | "move", _e: PointerEvent | undefined, state: MoveState): ActionChangeResult;
|
|
56
56
|
onMoveApply(state: MoveState): ActionApplyResult;
|
|
57
57
|
cancel(): void;
|
|
@@ -17,10 +17,10 @@ export class CloseAction {
|
|
|
17
17
|
transformError: (e) => e.message
|
|
18
18
|
};
|
|
19
19
|
handleEvent = (e) => {
|
|
20
|
-
if (e
|
|
20
|
+
if (e?.ctrlKey && e?.shiftKey) {
|
|
21
21
|
return "force";
|
|
22
22
|
}
|
|
23
|
-
if (e
|
|
23
|
+
if (e?.shiftKey) return true;
|
|
24
24
|
return false;
|
|
25
25
|
};
|
|
26
26
|
modifyDecos = () => {
|
|
@@ -11,7 +11,7 @@ export declare class FrameDragAction implements IAction {
|
|
|
11
11
|
actions: string[];
|
|
12
12
|
errors: string[];
|
|
13
13
|
};
|
|
14
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean;
|
|
14
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean;
|
|
15
15
|
dragHints: {
|
|
16
16
|
actions: {
|
|
17
17
|
split?: string;
|
|
@@ -43,7 +43,7 @@ export declare class FrameDragAction implements IAction {
|
|
|
43
43
|
errors: string[];
|
|
44
44
|
};
|
|
45
45
|
getDecos(matchedZone: Zone | undefined, state: MoveState, result: LayoutChange<"split" | "swap" | "rearrange" | "dock"> | KnownError | undefined): FrameDeco[];
|
|
46
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean;
|
|
46
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean;
|
|
47
47
|
onMoveChange<T extends "start" | "move" | "end">(type: T, _e: PointerEvent | undefined, state: MoveState): ActionChangeResult;
|
|
48
48
|
onMoveApply(state: MoveState): ActionApplyResult;
|
|
49
49
|
onMoveEnded(): void;
|
|
@@ -26,7 +26,7 @@ export declare class SplitAction implements IAction {
|
|
|
26
26
|
actions: string[] | ((type: DragChangeType) => string[]);
|
|
27
27
|
transformError: (e: KnownError) => string;
|
|
28
28
|
};
|
|
29
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean;
|
|
29
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean;
|
|
30
30
|
modifyDecos: (shapes: SplitDeco[]) => void;
|
|
31
31
|
hooks: {
|
|
32
32
|
onStart?: () => void;
|
|
@@ -43,7 +43,7 @@ export declare class SplitAction implements IAction {
|
|
|
43
43
|
});
|
|
44
44
|
reset(): void;
|
|
45
45
|
getDecos(state: MoveState): SplitDeco[];
|
|
46
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean;
|
|
46
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean;
|
|
47
47
|
setTextHints(result: true | SplitInfo | KnownError | undefined): void;
|
|
48
48
|
getTextHints(type: "start" | "move" | "end"): {
|
|
49
49
|
actions: string[];
|
|
@@ -15,7 +15,7 @@ export class SplitAction {
|
|
|
15
15
|
actions: ["Hold Alt to Split"],
|
|
16
16
|
transformError: (e) => e.message
|
|
17
17
|
};
|
|
18
|
-
handleEvent = (e, state) => e
|
|
18
|
+
handleEvent = (e, state) => e?.altKey || state.isMovingFromWindowEdge;
|
|
19
19
|
modifyDecos = () => {
|
|
20
20
|
};
|
|
21
21
|
hooks;
|
|
@@ -1956,8 +1956,10 @@ export interface IAction {
|
|
|
1956
1956
|
* The user is not necessarily dragging at this point, though they might also change actions mid drag. So it does not necessarily mean the event is allowed.
|
|
1957
1957
|
*
|
|
1958
1958
|
* Here is where you should initiate your state. Don't allow the action by default unless it can always be allowed.
|
|
1959
|
+
*
|
|
1960
|
+
* Event might be undefined if it was initiated manually via moveStart without an event.
|
|
1959
1961
|
*/
|
|
1960
|
-
canHandleRequest(e: KeyboardEvent | PointerEvent, state: MoveState, forceRecalculateEdges: () => void): boolean;
|
|
1962
|
+
canHandleRequest(e: KeyboardEvent | PointerEvent | undefined, state: MoveState, forceRecalculateEdges: () => void): boolean;
|
|
1961
1963
|
/**
|
|
1962
1964
|
* 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).
|
|
1963
1965
|
*
|
package/package.json
CHANGED
|
@@ -128,7 +128,6 @@ const actionHandler = props.actionHandler ?? markRaw(new ActionHandler(
|
|
|
128
128
|
],
|
|
129
129
|
{
|
|
130
130
|
onEvent: (e, cancel) => {
|
|
131
|
-
showMoving.value = true
|
|
132
131
|
if (e instanceof KeyboardEvent && e.key === "Escape") {
|
|
133
132
|
cancel()
|
|
134
133
|
}
|
|
@@ -138,7 +137,6 @@ const actionHandler = props.actionHandler ?? markRaw(new ActionHandler(
|
|
|
138
137
|
},
|
|
139
138
|
onEnd: () => {
|
|
140
139
|
requestType.value = undefined
|
|
141
|
-
showMoving.value = true
|
|
142
140
|
},
|
|
143
141
|
}
|
|
144
142
|
))
|
|
@@ -77,12 +77,12 @@ export class ActionHandler<
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
eventHandler(
|
|
80
|
-
e: KeyboardEvent | PointerEvent,
|
|
80
|
+
e: KeyboardEvent | PointerEvent | undefined,
|
|
81
81
|
state: MoveState,
|
|
82
82
|
forceRecalculateEdges: () => void
|
|
83
83
|
) {
|
|
84
84
|
if (state.isMoving) {
|
|
85
|
-
e
|
|
85
|
+
e?.preventDefault()
|
|
86
86
|
}
|
|
87
87
|
let cancelled = false
|
|
88
88
|
this.hooks.onEvent?.(e, () => {
|
|
@@ -131,7 +131,7 @@ export class ActionHandler<
|
|
|
131
131
|
): MoveChangeResult {
|
|
132
132
|
if (type === "start") {
|
|
133
133
|
this.eventCanceller = cancel
|
|
134
|
-
this.eventHandler(e
|
|
134
|
+
this.eventHandler(e, state, forceRecalculateEdges)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
if (this.activeAction) {
|
|
@@ -40,11 +40,11 @@ export class CloseAction implements IAction {
|
|
|
40
40
|
transformError: e => e.message
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean | "force" = (e: PointerEvent | KeyboardEvent) => {
|
|
44
|
-
if (e
|
|
43
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean | "force" = (e: PointerEvent | KeyboardEvent | undefined) => {
|
|
44
|
+
if (e?.ctrlKey && e?.shiftKey) {
|
|
45
45
|
return "force"
|
|
46
46
|
}
|
|
47
|
-
if (e
|
|
47
|
+
if (e?.shiftKey) return true
|
|
48
48
|
return false
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -136,7 +136,7 @@ export class CloseAction implements IAction {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean {
|
|
139
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean {
|
|
140
140
|
const { movingEdges } = state
|
|
141
141
|
if (movingEdges.length !== 1) return false
|
|
142
142
|
const res = this.handleEvent(e, state)
|
|
@@ -25,8 +25,8 @@ export class FrameDragAction implements IAction {
|
|
|
25
25
|
debug: boolean | string = false
|
|
26
26
|
textHints: { actions: string[], errors: string[] } = { actions: [], errors: [] }
|
|
27
27
|
|
|
28
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean
|
|
29
|
-
= (_e: PointerEvent | KeyboardEvent, state: MoveState) => state.isMoving === "frame"
|
|
28
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean
|
|
29
|
+
= (_e: PointerEvent | KeyboardEvent | undefined, 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[])
|
|
@@ -139,7 +139,7 @@ export class FrameDragAction implements IAction {
|
|
|
139
139
|
return decos
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean {
|
|
142
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean {
|
|
143
143
|
const res = this.handleEvent(e, state)
|
|
144
144
|
this.setTextHints(undefined)
|
|
145
145
|
if (res) {
|
|
@@ -40,8 +40,8 @@ export class SplitAction implements IAction {
|
|
|
40
40
|
transformError: e => e.message
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
handleEvent: (e: PointerEvent | KeyboardEvent, state: MoveState) => boolean
|
|
44
|
-
= (e: PointerEvent | KeyboardEvent, state: MoveState) => e
|
|
43
|
+
handleEvent: (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => boolean
|
|
44
|
+
= (e: PointerEvent | KeyboardEvent | undefined, state: MoveState) => e?.altKey || state.isMovingFromWindowEdge
|
|
45
45
|
|
|
46
46
|
modifyDecos: (shapes: SplitDeco[]) => void = () => { }
|
|
47
47
|
hooks: {
|
|
@@ -107,7 +107,7 @@ export class SplitAction implements IAction {
|
|
|
107
107
|
return decos
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
canHandleRequest(e: PointerEvent | KeyboardEvent, state: MoveState): boolean {
|
|
110
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent | undefined, state: MoveState): boolean {
|
|
111
111
|
const { movingEdges } = state
|
|
112
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
|
|
@@ -574,9 +574,11 @@ export interface IAction {
|
|
|
574
574
|
* The user is not necessarily dragging at this point, though they might also change actions mid drag. So it does not necessarily mean the event is allowed.
|
|
575
575
|
*
|
|
576
576
|
* Here is where you should initiate your state. Don't allow the action by default unless it can always be allowed.
|
|
577
|
+
*
|
|
578
|
+
* Event might be undefined if it was initiated manually via moveStart without an event.
|
|
577
579
|
*/
|
|
578
580
|
canHandleRequest(
|
|
579
|
-
e: KeyboardEvent | PointerEvent,
|
|
581
|
+
e: KeyboardEvent | PointerEvent | undefined,
|
|
580
582
|
state: MoveState,
|
|
581
583
|
forceRecalculateEdges: () => void
|
|
582
584
|
): boolean
|