@witchcraft/layout 0.0.4 → 0.0.6
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/LayoutDecos.d.vue.ts +8 -0
- package/dist/runtime/components/LayoutDecos.vue.d.ts +8 -0
- package/dist/runtime/components/LayoutEdges.d.vue.ts +27 -0
- package/dist/runtime/components/LayoutEdges.vue.d.ts +27 -0
- package/dist/runtime/components/LayoutFrame.d.vue.ts +36 -0
- package/dist/runtime/components/LayoutFrame.vue.d.ts +36 -0
- package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +36 -0
- package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +36 -0
- package/dist/runtime/components/LayoutWindow.d.vue.ts +108 -0
- package/dist/runtime/components/LayoutWindow.vue.d.ts +108 -0
- package/dist/runtime/composables/useFrames.d.ts +180 -0
- package/dist/runtime/demo/App.d.vue.ts +2 -0
- package/dist/runtime/demo/App.vue.d.ts +2 -0
- package/dist/runtime/demo/DemoControls.d.vue.ts +6 -0
- package/dist/runtime/demo/DemoControls.vue.d.ts +6 -0
- package/dist/runtime/demo/main.d.ts +2 -0
- package/dist/runtime/demo/sharedLayoutInstance.d.ts +6 -0
- package/dist/runtime/demo/tailwind.css +1 -1
- package/dist/runtime/drag/CloseAction.d.ts +33 -0
- package/dist/runtime/drag/DragActionHandler.d.ts +42 -0
- package/dist/runtime/drag/DragDirectionStore.d.ts +20 -0
- package/dist/runtime/drag/SplitAction.d.ts +32 -0
- package/dist/runtime/drag/types.d.ts +92 -0
- package/dist/runtime/helpers/addPointsToIntersection.d.ts +2 -0
- package/dist/runtime/helpers/assertEdgeSorted.d.ts +2 -0
- package/dist/runtime/helpers/assertItemIn.d.ts +1 -0
- package/dist/runtime/helpers/assertItemNotIn.d.ts +1 -0
- package/dist/runtime/helpers/assertLayoutHasActiveWindow.d.ts +4 -0
- package/dist/runtime/helpers/assertValidWinAndFrame.d.ts +5 -0
- package/dist/runtime/helpers/assertValidWinAndFrameIds.d.ts +2 -0
- package/dist/runtime/helpers/assertWindowHasActiveFrame.d.ts +4 -0
- package/dist/runtime/helpers/clampNumber.d.ts +1 -0
- package/dist/runtime/helpers/cloneFrame.d.ts +2 -0
- package/dist/runtime/helpers/cloneFrames.d.ts +2 -0
- package/dist/runtime/helpers/containsEdge.d.ts +2 -0
- package/dist/runtime/helpers/convertLayoutWindowToWorkspace.d.ts +2 -0
- package/dist/runtime/helpers/copySize.d.ts +2 -0
- package/dist/runtime/helpers/createEdge.d.ts +5 -0
- package/dist/runtime/helpers/dirToOrientation.d.ts +2 -0
- package/dist/runtime/helpers/dirToSide.d.ts +2 -0
- package/dist/runtime/helpers/doEdgesOverlap.d.ts +2 -0
- package/dist/runtime/helpers/doesEdgeContinueEdge.d.ts +2 -0
- package/dist/runtime/helpers/edgeToPoints.d.ts +2 -0
- package/dist/runtime/helpers/findDraggableEdge.d.ts +4 -0
- package/dist/runtime/helpers/findFrameDraggableEdges.d.ts +7 -0
- package/dist/runtime/helpers/frameToEdges.d.ts +2 -0
- package/dist/runtime/helpers/frameToPoints.d.ts +19 -0
- package/dist/runtime/helpers/getEdgeOrientation.d.ts +2 -0
- package/dist/runtime/helpers/getEdgeSharedDirection.d.ts +2 -0
- package/dist/runtime/helpers/getEdgeSide.d.ts +2 -0
- package/dist/runtime/helpers/getFrameById.d.ts +2 -0
- package/dist/runtime/helpers/getFrameConstant.d.ts +2 -0
- package/dist/runtime/helpers/getIntersections.d.ts +2 -0
- package/dist/runtime/helpers/getIntersectionsCss.d.ts +9 -0
- package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +11 -0
- package/dist/runtime/helpers/getResizeLimit.d.ts +2 -0
- package/dist/runtime/helpers/getShapeSquareCss.d.ts +7 -0
- package/dist/runtime/helpers/getSideTouching.d.ts +2 -0
- package/dist/runtime/helpers/getVisualEdgeCss.d.ts +7 -0
- package/dist/runtime/helpers/getVisualEdges.d.ts +48 -0
- package/dist/runtime/helpers/getVisualEdgesCss.d.ts +3 -0
- package/dist/runtime/helpers/getWinAndFrameById.d.ts +10 -0
- package/dist/runtime/helpers/getWinByFrameUuid.d.ts +2 -0
- package/dist/runtime/helpers/getWinById.d.ts +2 -0
- package/dist/runtime/helpers/getWindowConstant.d.ts +2 -0
- package/dist/runtime/helpers/inRange.d.ts +1 -0
- package/dist/runtime/helpers/index.d.ts +62 -0
- package/dist/runtime/helpers/isEdgeEqual.d.ts +2 -0
- package/dist/runtime/helpers/isEdgeParallel.d.ts +2 -0
- package/dist/runtime/helpers/isPointEqual.d.ts +2 -0
- package/dist/runtime/helpers/isSizeAboveMin.d.ts +2 -0
- package/dist/runtime/helpers/isSizeEqual.d.ts +2 -0
- package/dist/runtime/helpers/isWindowEdge.d.ts +2 -0
- package/dist/runtime/helpers/isWindowEdgePoint.d.ts +2 -0
- package/dist/runtime/helpers/moveEdge.d.ts +4 -0
- package/dist/runtime/helpers/numberToScaledPercent.d.ts +13 -0
- package/dist/runtime/helpers/numberToScaledSize.d.ts +2 -0
- package/dist/runtime/helpers/oppositeSide.d.ts +2 -0
- package/dist/runtime/helpers/resizeByEdge.d.ts +2 -0
- package/dist/runtime/helpers/sideToDirection.d.ts +3 -0
- package/dist/runtime/helpers/sideToOrientation.d.ts +2 -0
- package/dist/runtime/helpers/splitEdge.d.ts +2 -0
- package/dist/runtime/helpers/toCoord.d.ts +3 -0
- package/dist/runtime/helpers/toId.d.ts +3 -0
- package/dist/runtime/helpers/toWindowCoord.d.ts +2 -0
- package/dist/runtime/helpers/unionEdges.d.ts +2 -0
- package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +2 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/layout/closeFrame.d.ts +5 -0
- package/dist/runtime/layout/closeFrames.d.ts +2 -0
- package/dist/runtime/layout/createSplitDecoEdge.d.ts +2 -0
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +2 -0
- package/dist/runtime/layout/debugFrame.d.ts +2 -0
- package/dist/runtime/layout/findFramesTouchingEdge.d.ts +49 -0
- package/dist/runtime/layout/findSafeSplitEdge.d.ts +5 -0
- package/dist/runtime/layout/findVisualEdge.d.ts +2 -0
- package/dist/runtime/layout/frameCreate.d.ts +3 -0
- package/dist/runtime/layout/frameSplit.d.ts +16 -0
- package/dist/runtime/layout/getCloseFrameInfo.d.ts +73 -0
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +16 -0
- package/dist/runtime/layout/getFrameTo.d.ts +2 -0
- package/dist/runtime/layout/index.d.ts +22 -0
- package/dist/runtime/layout/isPointInFrame.d.ts +2 -0
- package/dist/runtime/layout/layoutAddWindow.d.ts +2 -0
- package/dist/runtime/layout/layoutCreate.d.ts +3 -0
- package/dist/runtime/layout/layoutRemoveWindow.d.ts +2 -0
- package/dist/runtime/layout/resizeFrame.d.ts +6 -0
- package/dist/runtime/layout/windowAddFrame.d.ts +2 -0
- package/dist/runtime/layout/windowCreate.d.ts +4 -0
- package/dist/runtime/layout/windowRemoveFrame.d.ts +2 -0
- package/dist/runtime/layout/windowSetActiveFrame.d.ts +2 -0
- package/dist/runtime/settings.d.ts +23 -0
- package/dist/runtime/types/index.d.ts +459 -0
- package/dist/runtime/utils/KnownError.d.ts +10 -0
- package/package.json +5 -5
- package/src/runtime/demo/tailwind.css +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DragState, IDragAction } from "./types.js";
|
|
2
|
+
import { getCloseFrameInfo } from "../layout/getCloseFrameInfo.js";
|
|
3
|
+
import type { CloseDeco } from "../types/index.js";
|
|
4
|
+
import type { KnownError } from "../utils/KnownError.js";
|
|
5
|
+
export type CloseInfo = Exclude<ReturnType<typeof getCloseFrameInfo>, KnownError>;
|
|
6
|
+
export declare class CloseAction implements IDragAction {
|
|
7
|
+
name: "close";
|
|
8
|
+
state: {
|
|
9
|
+
allowed: true;
|
|
10
|
+
force: boolean;
|
|
11
|
+
res: CloseInfo;
|
|
12
|
+
cacheKey: string | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
allowed: false;
|
|
15
|
+
force: boolean;
|
|
16
|
+
res: CloseInfo | undefined;
|
|
17
|
+
cacheKey: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
handleEvent: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean | "force";
|
|
20
|
+
updateCloseDecos: (decos: CloseDeco[]) => void;
|
|
21
|
+
hooks: {
|
|
22
|
+
onStart?: (active: boolean) => void;
|
|
23
|
+
onCancel?: () => void;
|
|
24
|
+
onError?: (e: KnownError) => void;
|
|
25
|
+
};
|
|
26
|
+
constructor(handleEvent: CloseAction["handleEvent"], updateCloseDecos: CloseAction["updateCloseDecos"], hooks?: CloseAction["hooks"]);
|
|
27
|
+
reset(): void;
|
|
28
|
+
updateDecos(state: DragState): void;
|
|
29
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent, state: DragState): boolean;
|
|
30
|
+
onDragChange(_type: "start" | "end" | "move", _e: PointerEvent | undefined, state: DragState): boolean;
|
|
31
|
+
onDragApply(state: DragState): boolean;
|
|
32
|
+
cancel(): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { RecordFromArray } from "@alanscodelog/utils";
|
|
2
|
+
import type { DragChangeHandler, DragState, IDragAction } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Handles the lifecycle of a drag actions {@link IDragAction} and provides additional hooks.
|
|
5
|
+
*
|
|
6
|
+
* The first action instance that can handle the request is passed control of the event handlers until the request changes.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DragActionHandler<TRawDragActions extends IDragAction[], TDragActions extends RecordFromArray<TRawDragActions, "name"> = RecordFromArray<TRawDragActions, "name">> {
|
|
9
|
+
activeAction?: keyof TDragActions;
|
|
10
|
+
actions: TDragActions;
|
|
11
|
+
eventCanceller: (() => void) | undefined;
|
|
12
|
+
boundCancel: () => void;
|
|
13
|
+
defaultOnDragChange: DragChangeHandler;
|
|
14
|
+
hooks: {
|
|
15
|
+
/** Called while dragging during dragChange events. You can use this to update the dragging edges. */
|
|
16
|
+
onRecalculate?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Called before searching for a matching action. Useful for re-initializing state.
|
|
19
|
+
*
|
|
20
|
+
* Is passed a `cancel` function if you want to cancel the current drag action.
|
|
21
|
+
*/
|
|
22
|
+
onEvent?: (e: PointerEvent | KeyboardEvent | undefined, cancel: () => void) => void;
|
|
23
|
+
/** Called when the action requested changes. */
|
|
24
|
+
onRequestChange?: (type: keyof TDragActions | undefined) => void;
|
|
25
|
+
/** Called when the drag action ends either because it was completed or cancelled. */
|
|
26
|
+
onEnd?: (context: {
|
|
27
|
+
cancelled: boolean;
|
|
28
|
+
applied: boolean;
|
|
29
|
+
}) => void;
|
|
30
|
+
};
|
|
31
|
+
constructor(
|
|
32
|
+
/**
|
|
33
|
+
* Default onDragChange handler for when no action can handle the request.
|
|
34
|
+
*
|
|
35
|
+
* Should return true to allow the edges to be moved, or false to prevent it.
|
|
36
|
+
*/
|
|
37
|
+
defaultOnDragChange: DragChangeHandler, actions: TRawDragActions, hooks?: DragActionHandler<TRawDragActions, TDragActions>["hooks"]);
|
|
38
|
+
eventHandler(e: KeyboardEvent | PointerEvent, state: DragState, forceRecalculateEdges: () => void): undefined;
|
|
39
|
+
onDragChange<T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: DragState, forceRecalculateEdges: () => void, cancel?: () => void): boolean | undefined;
|
|
40
|
+
onDragApply(state: DragState, forceRecalculateEdges: () => void): boolean;
|
|
41
|
+
cancel(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Direction, Orientation, Point } from "../types/index.js";
|
|
2
|
+
export declare class DragDirectionStore {
|
|
3
|
+
hooks: {
|
|
4
|
+
onUpdate: (directions: Record<Orientation, Direction | undefined>) => void;
|
|
5
|
+
};
|
|
6
|
+
constructor(hooks: DragDirectionStore["hooks"]);
|
|
7
|
+
lastPoint: Point | undefined;
|
|
8
|
+
dragDirection: Record<Orientation, Direction | undefined>;
|
|
9
|
+
lesser: {
|
|
10
|
+
x: Direction;
|
|
11
|
+
y: Direction;
|
|
12
|
+
};
|
|
13
|
+
greater: {
|
|
14
|
+
x: Direction;
|
|
15
|
+
y: Direction;
|
|
16
|
+
};
|
|
17
|
+
reset(): void;
|
|
18
|
+
update(point: Point): boolean;
|
|
19
|
+
getDragDirection(coord: "x" | "y", point: Point): Direction | false;
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DragState, IDragAction } from "./types.js";
|
|
2
|
+
import { getFrameSplitInfo } from "../layout/getFrameSplitInfo.js";
|
|
3
|
+
import type { SplitDeco } from "../types/index.js";
|
|
4
|
+
import type { KnownError } from "../utils/KnownError.js";
|
|
5
|
+
export type SplitInfo = Exclude<ReturnType<typeof getFrameSplitInfo>, KnownError>;
|
|
6
|
+
export declare class SplitAction implements IDragAction {
|
|
7
|
+
name: "split";
|
|
8
|
+
state: {
|
|
9
|
+
allowed: false;
|
|
10
|
+
res: SplitInfo | undefined;
|
|
11
|
+
cacheKey: string | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
allowed: true;
|
|
14
|
+
res: SplitInfo;
|
|
15
|
+
cacheKey: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
handleEvent: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
|
|
18
|
+
updateSplitDecos: (decos: SplitDeco[]) => void;
|
|
19
|
+
hooks: {
|
|
20
|
+
onStart?: () => void;
|
|
21
|
+
onCancel?: () => void;
|
|
22
|
+
onError?: (e: KnownError) => void;
|
|
23
|
+
};
|
|
24
|
+
constructor(handleEvent: SplitAction["handleEvent"], updateSplitDecos: SplitAction["updateSplitDecos"], hooks?: SplitAction["hooks"]);
|
|
25
|
+
reset(): void;
|
|
26
|
+
updateDecos(state: DragState): void;
|
|
27
|
+
canHandleRequest(e: PointerEvent | KeyboardEvent, state: DragState): boolean;
|
|
28
|
+
calculateSplitRequest(state: DragState): boolean;
|
|
29
|
+
onDragChange(_type: "start" | "end" | "move", _e: PointerEvent | undefined, state: DragState): true;
|
|
30
|
+
onDragApply(state: DragState): boolean;
|
|
31
|
+
cancel(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Direction, Edge, IntersectionEntry, LayoutFrame, LayoutWindow, Orientation, Point } from "../types/index.js";
|
|
2
|
+
export type DragState = {
|
|
3
|
+
/** The current directions in the corresponding orientations that the user is dragging in. */
|
|
4
|
+
dragDirections: Record<Orientation, Direction | undefined>;
|
|
5
|
+
/** The curren point (in scaled window coordinates) the user is dragging at. */
|
|
6
|
+
dragPoint?: Point;
|
|
7
|
+
/** Whether the user is currently dragging. Is true during all drag events. */
|
|
8
|
+
isDragging: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 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.
|
|
11
|
+
*/
|
|
12
|
+
draggingEdges: Edge[];
|
|
13
|
+
/**
|
|
14
|
+
* The intersection that is currently being dragged.
|
|
15
|
+
*/
|
|
16
|
+
draggingIntersection?: IntersectionEntry;
|
|
17
|
+
/** The "visual" edges that can be displayed for dragging. See {@link getVisualEdges} */
|
|
18
|
+
visualEdges: Edge[];
|
|
19
|
+
/**
|
|
20
|
+
* The frames touching the currently dragged edges. Each entry corresponds to the frames touching the corresponding dragging edge.
|
|
21
|
+
*
|
|
22
|
+
* So you can use the index in draggingEdges to get the corresponding frames.
|
|
23
|
+
*/
|
|
24
|
+
touchingFrames: Record<string, LayoutFrame>[];
|
|
25
|
+
/**
|
|
26
|
+
* Same as touchingFrames, but with the frames in an array.
|
|
27
|
+
*/
|
|
28
|
+
touchingFramesArrays: LayoutFrame[][];
|
|
29
|
+
/**
|
|
30
|
+
* All the frames, with/without the currently dragged frames depending on if `showDragging` is true.
|
|
31
|
+
*/
|
|
32
|
+
frames: Record<string, LayoutFrame>;
|
|
33
|
+
/**
|
|
34
|
+
* The frame that is currently being hovered over (according to whether `dragPoint` in in the frame or not).
|
|
35
|
+
*/
|
|
36
|
+
dragHoveredFrame: LayoutFrame | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* A list of corner intersections. Frames can also be dragged by these.
|
|
39
|
+
*/
|
|
40
|
+
intersections: IntersectionEntry[];
|
|
41
|
+
/**
|
|
42
|
+
* Whether the drag was initiated from a point along the window edge.
|
|
43
|
+
*/
|
|
44
|
+
isDraggingFromWindowEdge: boolean;
|
|
45
|
+
win: LayoutWindow;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Note that the return type only affects the `move` event but is also typed as `boolean` for other events for ease of use.
|
|
49
|
+
*/
|
|
50
|
+
export interface DragChangeHandler {
|
|
51
|
+
<T extends "start" | "move" | "end">(type: T, e: T extends "end" ? PointerEvent | undefined : PointerEvent, state: DragState, forceRecalculateEdges: () => void, cancel: () => void): boolean | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A drag action describes when and how to handle a drag event.
|
|
55
|
+
*
|
|
56
|
+
* For example, there are the default split/close actions that can be triggered in certain situations. This could be when holding down a modifier or key, or some other condition (e.g. the user is dragging a specific edge).
|
|
57
|
+
*
|
|
58
|
+
* Each action should handle it's configuration and saving/caching any state it needs. See {@link SplitAction} and {@link CloseAction} for examples.
|
|
59
|
+
*/
|
|
60
|
+
export interface IDragAction {
|
|
61
|
+
/** A unique name for your action. */
|
|
62
|
+
name: string;
|
|
63
|
+
/**
|
|
64
|
+
* Called when the drag coordinates change (during any event). Should return true to allow the edges to be moved, or false to prevent it.
|
|
65
|
+
*
|
|
66
|
+
* Can be used to save some context/info to later apply safely during onDragApply.
|
|
67
|
+
*/
|
|
68
|
+
onDragChange: DragChangeHandler;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* Is called after `onDragChange("end")` with the same event. Might not be called if the request was cancelled.
|
|
72
|
+
*
|
|
73
|
+
* You should apply your action if possible and return whether it was applied.
|
|
74
|
+
*
|
|
75
|
+
* This is also a good place to reset your state.
|
|
76
|
+
*/
|
|
77
|
+
onDragApply: (state: DragState, forceRecalculateEdges: () => void) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Should return true if it should handle the "request"/event (e.g. some modifier is being pressed => user is requesting x action).
|
|
80
|
+
*
|
|
81
|
+
* 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.
|
|
82
|
+
*
|
|
83
|
+
* Here is where you should initiate your state. Don't allow the action by default unless it can always be allowed.
|
|
84
|
+
*/
|
|
85
|
+
canHandleRequest(e: KeyboardEvent | PointerEvent, state: DragState, forceRecalculateEdges: () => void): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Called when a user cancels the drag action.
|
|
88
|
+
*
|
|
89
|
+
* You should reset your state here.
|
|
90
|
+
*/
|
|
91
|
+
cancel(): void;
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertItemIn<T extends Record<string, any>>(entries: T, id: keyof T | string | undefined): asserts id is keyof T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function assertItemNotIn(entries: Record<string, any>, id: string | undefined): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clampNumber(num: number, lowerLimit: number, upperLimit: number): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Edge, Orientation } from "../types/index.js";
|
|
2
|
+
export declare function findDraggableEdge(edge: Edge, edges: Edge[],
|
|
3
|
+
/** Whether the edge must match exactly and does not "contain/touch" another frame. */
|
|
4
|
+
exact?: boolean, edgeOrientation?: Orientation): Edge | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Edge, EdgeSide, LayoutFrame } from "../types/index.js";
|
|
2
|
+
export declare function findFrameDraggableEdges(frame: LayoutFrame, edges: Edge[],
|
|
3
|
+
/** See {@link findDraggableEdge} */
|
|
4
|
+
exact?: boolean, sides?: EdgeSide[]): {
|
|
5
|
+
edge: Edge;
|
|
6
|
+
side: EdgeSide;
|
|
7
|
+
}[] | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LayoutFrame } from "../types/index.js";
|
|
2
|
+
export declare function frameToPoints(frame: LayoutFrame): {
|
|
3
|
+
tl: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
tr: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
bl: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
br: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IntersectionEntry, PointCss } from "../types/index.js";
|
|
2
|
+
export declare function getIntersectionsCss(entries: IntersectionEntry[], { intersectionWidth,
|
|
3
|
+
/** How much to shift the intersections by when it's not on a four corner intersection. Otherwise it tends to look ugly because it overlaps one of the frame edges, this shifts it away from it. */
|
|
4
|
+
shiftAmount }?: {
|
|
5
|
+
intersectionWidth?: string;
|
|
6
|
+
shiftAmount?: string;
|
|
7
|
+
}): (PointCss & {
|
|
8
|
+
_shifted?: true;
|
|
9
|
+
})[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Direction, Edge, LayoutFrame, Point, Size } from "../types/index.js";
|
|
2
|
+
export declare function getMoveEdgeInfo(touchingFrames: LayoutFrame[], edge: Edge,
|
|
3
|
+
/** Window scaled/snaped position. See {@link toWindowCoord} */
|
|
4
|
+
position: Point, margin?: Size, clamp?: boolean): {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
dir: Direction;
|
|
8
|
+
isPassedLimit: boolean;
|
|
9
|
+
pos: number;
|
|
10
|
+
distance: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { Edge, ExtendedDirection, LayoutFrame } from "../types/index.js";
|
|
2
|
+
export declare function getResizeLimit<TDir extends ExtendedDirection>(edge: Edge, touchingFrames: LayoutFrame[], dir: TDir, amount: number, margin: number): TDir extends "horizontal" ? Record<"left" | "right", number> : TDir extends "vertical" ? Record<"up" | "down", number> : number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Edge, EdgeCss } from "../types/index.js";
|
|
2
|
+
export declare function getVisualEdgeCss(edge: Edge, { translate, edgeWidth, padLongAxis, padShortAxis }?: {
|
|
3
|
+
translate?: boolean;
|
|
4
|
+
edgeWidth?: string;
|
|
5
|
+
padLongAxis?: string;
|
|
6
|
+
padShortAxis?: string;
|
|
7
|
+
}): EdgeCss;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Edge, LayoutFrame, Orientation } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns the "visual" edges that can be dragged.
|
|
4
|
+
*
|
|
5
|
+
* Visual edges are a combination of all edges shared by frames that must be moved together.
|
|
6
|
+
*
|
|
7
|
+
* For example, if we have two frames A and B, they share the center edge, and the function would return this single edge (unless `includeWindowEdges` is true).
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* ┌──┰──┐
|
|
11
|
+
* │A ┃B │ returns ┃
|
|
12
|
+
* └──┸──┘
|
|
13
|
+
* ```
|
|
14
|
+
* Or in this example, we would get two edges:
|
|
15
|
+
* - The one shared by A, B, and C, because no frame edge sharing this edge can without also moving the other frames touching the edge.
|
|
16
|
+
* - The one shared by A and B.
|
|
17
|
+
*```
|
|
18
|
+
* ┌──┰──┐
|
|
19
|
+
* │A ┃C │ ┃
|
|
20
|
+
* ┝━━┫ │ returns ━━ ┃
|
|
21
|
+
* │B ┃ │ ┃
|
|
22
|
+
* └──┸──┘
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* And here, we get four edges, because all four can be moved on their own (moving the edge would only affect the two frames sharing that edge).
|
|
26
|
+
*```
|
|
27
|
+
* ┌──┰──┐
|
|
28
|
+
* │A ┃C │ ┃
|
|
29
|
+
* ┝━━╋━━┥ returns ━━ ━━
|
|
30
|
+
* │B ┃D │ ┃
|
|
31
|
+
* └──┸──┘
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export declare function getVisualEdges<T extends boolean = false>(frames: LayoutFrame[], { separateByDir, includeWindowEdges }?: {
|
|
36
|
+
/**
|
|
37
|
+
* Whether the result is separated into horizontal/vertical edges or not.
|
|
38
|
+
*
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
separateByDir?: T;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include edges along the window edges.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
includeWindowEdges?: boolean;
|
|
48
|
+
}): T extends true ? Record<Orientation, Edge[]> : Edge[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnyUuid, FrameId, Layout, LayoutFrame, LayoutWindow, WindowId } from "../types/index.js";
|
|
2
|
+
export declare function getWinAndFrameById<T extends boolean = false>(layout: Layout,
|
|
3
|
+
/** winId can be undefined only if frameId is a uuid */
|
|
4
|
+
winId: WindowId | undefined, frameId: AnyUuid | FrameId, assert?: T): T extends true ? {
|
|
5
|
+
win: LayoutWindow;
|
|
6
|
+
frame: LayoutFrame;
|
|
7
|
+
} : {
|
|
8
|
+
win?: LayoutWindow;
|
|
9
|
+
frame?: LayoutFrame;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function inRange(coord: number, lowerLimit: number, upperLimit: number, inclusive?: boolean): boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export { addPointsToIntersection } from "./addPointsToIntersection.js";
|
|
2
|
+
export { assertEdgeSorted } from "./assertEdgeSorted.js";
|
|
3
|
+
export { assertItemIn } from "./assertItemIn.js";
|
|
4
|
+
export { assertItemNotIn } from "./assertItemNotIn.js";
|
|
5
|
+
export { assertLayoutHasActiveWindow } from "./assertLayoutHasActiveWindow.js";
|
|
6
|
+
export { assertValidWinAndFrame } from "./assertValidWinAndFrame.js";
|
|
7
|
+
export { assertValidWinAndFrameIds } from "./assertValidWinAndFrameIds.js";
|
|
8
|
+
export { assertWindowHasActiveFrame } from "./assertWindowHasActiveFrame.js";
|
|
9
|
+
export { clampNumber } from "./clampNumber.js";
|
|
10
|
+
export { cloneFrame } from "./cloneFrame.js";
|
|
11
|
+
export { cloneFrames } from "./cloneFrames.js";
|
|
12
|
+
export { containsEdge } from "./containsEdge.js";
|
|
13
|
+
export { convertLayoutWindowToWorkspace } from "./convertLayoutWindowToWorkspace.js";
|
|
14
|
+
export { copySize } from "./copySize.js";
|
|
15
|
+
export { createEdge } from "./createEdge.js";
|
|
16
|
+
export { dirToOrientation } from "./dirToOrientation.js";
|
|
17
|
+
export { dirToSide } from "./dirToSide.js";
|
|
18
|
+
export { doEdgesOverlap } from "./doEdgesOverlap.js";
|
|
19
|
+
export { doesEdgeContinueEdge } from "./doesEdgeContinueEdge.js";
|
|
20
|
+
export { edgeToPoints } from "./edgeToPoints.js";
|
|
21
|
+
export { findDraggableEdge } from "./findDraggableEdge.js";
|
|
22
|
+
export { findFrameDraggableEdges } from "./findFrameDraggableEdges.js";
|
|
23
|
+
export { frameToEdges } from "./frameToEdges.js";
|
|
24
|
+
export { frameToPoints } from "./frameToPoints.js";
|
|
25
|
+
export { getEdgeOrientation } from "./getEdgeOrientation.js";
|
|
26
|
+
export { getEdgeSharedDirection } from "./getEdgeSharedDirection.js";
|
|
27
|
+
export { getEdgeSide } from "./getEdgeSide.js";
|
|
28
|
+
export { getFrameById } from "./getFrameById.js";
|
|
29
|
+
export { getFrameConstant } from "./getFrameConstant.js";
|
|
30
|
+
export { getIntersections } from "./getIntersections.js";
|
|
31
|
+
export { getIntersectionsCss } from "./getIntersectionsCss.js";
|
|
32
|
+
export { getMoveEdgeInfo } from "./getMoveEdgeInfo.js";
|
|
33
|
+
export { getResizeLimit } from "./getResizeLimit.js";
|
|
34
|
+
export { getShapeSquareCss } from "./getShapeSquareCss.js";
|
|
35
|
+
export { getSideTouching } from "./getSideTouching.js";
|
|
36
|
+
export { getVisualEdgeCss } from "./getVisualEdgeCss.js";
|
|
37
|
+
export { getVisualEdges } from "./getVisualEdges.js";
|
|
38
|
+
export { getVisualEdgesCss } from "./getVisualEdgesCss.js";
|
|
39
|
+
export { getWinAndFrameById } from "./getWinAndFrameById.js";
|
|
40
|
+
export { getWinByFrameUuid } from "./getWinByFrameUuid.js";
|
|
41
|
+
export { getWinById } from "./getWinById.js";
|
|
42
|
+
export { getWindowConstant } from "./getWindowConstant.js";
|
|
43
|
+
export { inRange } from "./inRange.js";
|
|
44
|
+
export { isEdgeEqual } from "./isEdgeEqual.js";
|
|
45
|
+
export { isEdgeParallel } from "./isEdgeParallel.js";
|
|
46
|
+
export { isPointEqual } from "./isPointEqual.js";
|
|
47
|
+
export { isSizeAboveMin } from "./isSizeAboveMin.js";
|
|
48
|
+
export { isSizeEqual } from "./isSizeEqual.js";
|
|
49
|
+
export { isWindowEdge } from "./isWindowEdge.js";
|
|
50
|
+
export { isWindowEdgePoint } from "./isWindowEdgePoint.js";
|
|
51
|
+
export { moveEdge } from "./moveEdge.js";
|
|
52
|
+
export { numberToScaledPercent } from "./numberToScaledPercent.js";
|
|
53
|
+
export { numberToScaledSize } from "./numberToScaledSize.js";
|
|
54
|
+
export { oppositeSide } from "./oppositeSide.js";
|
|
55
|
+
export { resizeByEdge } from "./resizeByEdge.js";
|
|
56
|
+
export { sideToDirection } from "./sideToDirection.js";
|
|
57
|
+
export { sideToOrientation } from "./sideToOrientation.js";
|
|
58
|
+
export { splitEdge } from "./splitEdge.js";
|
|
59
|
+
export { toCoord } from "./toCoord.js";
|
|
60
|
+
export { toId } from "./toId.js";
|
|
61
|
+
export { toWindowCoord } from "./toWindowCoord.js";
|
|
62
|
+
export { unionEdges } from "./unionEdges.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Edge, LayoutFrame, Point, Size } from "../types/index.js";
|
|
2
|
+
export declare function moveEdge(touchingFrames: LayoutFrame[] | undefined, edge: Edge | undefined,
|
|
3
|
+
/** Window scaled/snaped position. See {@link toWindowCoord} */
|
|
4
|
+
position: Point, margin?: Size): void;
|