@witchcraft/layout 0.1.3 → 0.2.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.
- package/README.md +27 -24
- package/dist/module.json +1 -1
- package/dist/runtime/components/FrameDragHandle.d.vue.ts +15 -0
- package/dist/runtime/components/FrameDragHandle.vue +28 -0
- package/dist/runtime/components/FrameDragHandle.vue.d.ts +15 -0
- package/dist/runtime/components/LayoutDecos.d.vue.ts +2 -4
- package/dist/runtime/components/LayoutDecos.vue +10 -29
- package/dist/runtime/components/LayoutDecos.vue.d.ts +2 -4
- package/dist/runtime/components/LayoutEdges.d.vue.ts +3 -3
- package/dist/runtime/components/LayoutEdges.vue +8 -8
- package/dist/runtime/components/LayoutEdges.vue.d.ts +3 -3
- package/dist/runtime/components/LayoutFrame.d.vue.ts +1 -1
- package/dist/runtime/components/LayoutFrame.vue +0 -1
- package/dist/runtime/components/LayoutFrame.vue.d.ts +1 -1
- package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +3 -1
- package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +3 -1
- package/dist/runtime/components/LayoutWindow.d.vue.ts +26 -12
- package/dist/runtime/components/LayoutWindow.vue +95 -84
- package/dist/runtime/components/LayoutWindow.vue.d.ts +26 -12
- package/dist/runtime/composables/useFrames.d.ts +15 -13
- package/dist/runtime/composables/useFrames.js +59 -39
- package/dist/runtime/demo/App.vue +116 -30
- package/dist/runtime/demo/DemoControls.d.vue.ts +4 -1
- package/dist/runtime/demo/DemoControls.vue +98 -4
- package/dist/runtime/demo/DemoControls.vue.d.ts +4 -1
- package/dist/runtime/drag/CloseAction.d.ts +26 -5
- package/dist/runtime/drag/CloseAction.js +87 -40
- package/dist/runtime/drag/DragActionHandler.d.ts +20 -8
- package/dist/runtime/drag/DragActionHandler.js +47 -12
- package/dist/runtime/drag/FrameDragAction.d.ts +45 -0
- package/dist/runtime/drag/FrameDragAction.js +143 -0
- package/dist/runtime/drag/SplitAction.d.ts +32 -11
- package/dist/runtime/drag/SplitAction.js +82 -24
- package/dist/runtime/drag/createDefaultHandlers.d.ts +9 -0
- package/dist/runtime/drag/createDefaultHandlers.js +10 -0
- package/dist/runtime/drag/defaultDragActions.d.ts +9 -0
- package/dist/runtime/drag/defaultDragActions.js +10 -0
- package/dist/runtime/drag/types.d.ts +82 -13
- package/dist/runtime/drag/types.js +1 -0
- package/dist/runtime/helpers/createZoneSideClipPath.d.ts +12 -0
- package/dist/runtime/helpers/createZoneSideClipPath.js +17 -0
- package/dist/runtime/helpers/doEdgesOverlap.d.ts +3 -1
- package/dist/runtime/helpers/doEdgesOverlap.js +5 -5
- package/dist/runtime/helpers/getDockBoundaries.d.ts +19 -0
- package/dist/runtime/helpers/getDockBoundaries.js +14 -0
- package/dist/runtime/helpers/getEdgeLength.d.ts +2 -0
- package/dist/runtime/helpers/getEdgeLength.js +5 -0
- package/dist/runtime/helpers/getIntersections.js +2 -2
- package/dist/runtime/helpers/getIntersectionsCss.js +2 -2
- package/dist/runtime/helpers/getMoveEdgeInfo.js +2 -2
- package/dist/runtime/helpers/getResizeLimit.js +2 -2
- package/dist/runtime/helpers/getShapeSquareCss.js +2 -2
- package/dist/runtime/helpers/getVisualEdgeCss.js +2 -2
- package/dist/runtime/helpers/getVisualEdges.d.ts +1 -1
- package/dist/runtime/helpers/getVisualEdges.js +4 -3
- package/dist/runtime/helpers/index.d.ts +4 -0
- package/dist/runtime/helpers/index.js +4 -0
- package/dist/runtime/helpers/isEdgeEqual.js +2 -4
- package/dist/runtime/helpers/isWindowEdge.js +2 -2
- package/dist/runtime/helpers/isWindowEdgePoint.js +2 -2
- package/dist/runtime/helpers/moveEdge.js +2 -2
- package/dist/runtime/helpers/numberToScaledPercent.d.ts +1 -1
- package/dist/runtime/helpers/numberToScaledPercent.js +2 -2
- package/dist/runtime/helpers/numberToScaledSize.js +2 -2
- package/dist/runtime/helpers/rotateFrames.d.ts +7 -0
- package/dist/runtime/helpers/rotateFrames.js +36 -0
- package/dist/runtime/helpers/scaledPointToPx.d.ts +13 -0
- package/dist/runtime/helpers/scaledPointToPx.js +7 -0
- package/dist/runtime/helpers/toWindowCoord.js +2 -2
- package/dist/runtime/layout/applyFrameChanges.d.ts +10 -0
- package/dist/runtime/layout/applyFrameChanges.js +29 -0
- package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +6 -1
- package/dist/runtime/layout/createSplitDecoFromDrag.js +4 -4
- package/dist/runtime/layout/createSplitDecoShapes.d.ts +7 -0
- package/dist/runtime/layout/{createSplitDecoEdge.js → createSplitDecoShapes.js} +6 -3
- package/dist/runtime/layout/debugFrame.js +2 -1
- package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
- package/dist/runtime/layout/frameCreate.js +2 -2
- package/dist/runtime/layout/getCloseFrameInfo.d.ts +7 -6
- package/dist/runtime/layout/getCloseFrameInfo.js +10 -3
- package/dist/runtime/layout/getDragZones.d.ts +8 -0
- package/dist/runtime/layout/getDragZones.js +32 -0
- package/dist/runtime/layout/getFillEmptySpaceInfo.d.ts +65 -0
- package/dist/runtime/layout/getFillEmptySpaceInfo.js +69 -0
- package/dist/runtime/layout/getFrameCollapseInfo.d.ts +13 -0
- package/dist/runtime/layout/getFrameCollapseInfo.js +93 -0
- package/dist/runtime/layout/getFrameDockInfo.d.ts +9 -0
- package/dist/runtime/layout/getFrameDockInfo.js +82 -0
- package/dist/runtime/layout/getFrameDragZones.d.ts +16 -0
- package/dist/runtime/layout/getFrameDragZones.js +74 -0
- package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +139 -0
- package/dist/runtime/layout/getFrameRearrangeInfo.js +87 -0
- package/dist/runtime/layout/getFrameSplitInfo.d.ts +7 -5
- package/dist/runtime/layout/getFrameSplitInfo.js +10 -3
- package/dist/runtime/layout/getFrameSwapInfo.d.ts +9 -0
- package/dist/runtime/layout/getFrameSwapInfo.js +27 -0
- package/dist/runtime/layout/getFrameTo.js +2 -2
- package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +12 -0
- package/dist/runtime/layout/getFrameUncollapseInfo.js +88 -0
- package/dist/runtime/layout/getFrameUndockInfo.d.ts +13 -0
- package/dist/runtime/layout/getFrameUndockInfo.js +51 -0
- package/dist/runtime/layout/getFramesRedistributeInfo.d.ts +29 -0
- package/dist/runtime/layout/getFramesRedistributeInfo.js +53 -0
- package/dist/runtime/layout/getWindowDragZones.d.ts +6 -0
- package/dist/runtime/layout/getWindowDragZones.js +49 -0
- package/dist/runtime/layout/index.d.ts +14 -5
- package/dist/runtime/layout/index.js +14 -5
- package/dist/runtime/layout/isPointInRect.d.ts +7 -0
- package/dist/runtime/layout/{isPointInFrame.js → isPointInRect.js} +1 -1
- package/dist/runtime/layout/resizeFrame.js +2 -2
- package/dist/runtime/settings.d.ts +41 -16
- package/dist/runtime/settings.js +95 -53
- package/dist/runtime/types/index.d.ts +324 -54
- package/dist/runtime/types/index.js +54 -20
- package/package.json +28 -29
- package/src/runtime/components/FrameDragHandle.vue +30 -0
- package/src/runtime/components/LayoutDecos.vue +12 -36
- package/src/runtime/components/LayoutEdges.vue +27 -23
- package/src/runtime/components/LayoutFrame.vue +6 -5
- package/src/runtime/components/LayoutShapeSquare.vue +9 -3
- package/src/runtime/components/LayoutWindow.vue +110 -101
- package/src/runtime/composables/useFrames.ts +80 -50
- package/src/runtime/demo/App.vue +126 -36
- package/src/runtime/demo/DemoControls.vue +115 -6
- package/src/runtime/drag/CloseAction.ts +106 -44
- package/src/runtime/drag/DragActionHandler.ts +71 -20
- package/src/runtime/drag/FrameDragAction.ts +202 -0
- package/src/runtime/drag/SplitAction.ts +106 -34
- package/src/runtime/drag/createDefaultHandlers.ts +19 -0
- package/src/runtime/drag/defaultDragActions.ts +19 -0
- package/src/runtime/drag/types.ts +90 -20
- package/src/runtime/helpers/createZoneSideClipPath.ts +41 -0
- package/src/runtime/helpers/doEdgesOverlap.ts +11 -5
- package/src/runtime/helpers/getDockBoundaries.ts +36 -0
- package/src/runtime/helpers/getEdgeLength.ts +10 -0
- package/src/runtime/helpers/getIntersections.ts +2 -2
- package/src/runtime/helpers/getIntersectionsCss.ts +2 -2
- package/src/runtime/helpers/getMoveEdgeInfo.ts +2 -2
- package/src/runtime/helpers/getResizeLimit.ts +2 -2
- package/src/runtime/helpers/getShapeSquareCss.ts +2 -2
- package/src/runtime/helpers/getVisualEdgeCss.ts +2 -2
- package/src/runtime/helpers/getVisualEdges.ts +5 -4
- package/src/runtime/helpers/index.ts +4 -0
- package/src/runtime/helpers/isEdgeEqual.ts +2 -4
- package/src/runtime/helpers/isWindowEdge.ts +2 -2
- package/src/runtime/helpers/isWindowEdgePoint.ts +2 -2
- package/src/runtime/helpers/moveEdge.ts +2 -2
- package/src/runtime/helpers/numberToScaledPercent.ts +3 -3
- package/src/runtime/helpers/numberToScaledSize.ts +2 -2
- package/src/runtime/helpers/rotateFrames.ts +45 -0
- package/src/runtime/helpers/scaledPointToPx.ts +13 -0
- package/src/runtime/helpers/toWindowCoord.ts +2 -2
- package/src/runtime/layout/applyFrameChanges.ts +39 -0
- package/src/runtime/layout/createSplitDecoFromDrag.ts +12 -6
- package/src/runtime/layout/{createSplitDecoEdge.ts → createSplitDecoShapes.ts} +17 -7
- package/src/runtime/layout/debugFrame.ts +1 -1
- package/src/runtime/layout/findSafeSplitEdge.ts +3 -3
- package/src/runtime/layout/frameCreate.ts +2 -2
- package/src/runtime/layout/getCloseFrameInfo.ts +21 -8
- package/src/runtime/layout/getDragZones.ts +48 -0
- package/src/runtime/layout/getFillEmptySpaceInfo.ts +177 -0
- package/src/runtime/layout/getFrameCollapseInfo.ts +164 -0
- package/src/runtime/layout/getFrameDockInfo.ts +126 -0
- package/src/runtime/layout/getFrameDragZones.ts +100 -0
- package/src/runtime/layout/getFrameRearrangeInfo.ts +261 -0
- package/src/runtime/layout/getFrameSplitInfo.ts +21 -8
- package/src/runtime/layout/getFrameSwapInfo.ts +45 -0
- package/src/runtime/layout/getFrameTo.ts +2 -2
- package/src/runtime/layout/getFrameUncollapseInfo.ts +160 -0
- package/src/runtime/layout/getFrameUndockInfo.ts +97 -0
- package/src/runtime/layout/getFramesRedistributeInfo.ts +98 -0
- package/src/runtime/layout/getWindowDragZones.ts +59 -0
- package/src/runtime/layout/index.ts +14 -5
- package/src/runtime/layout/isPointInRect.ts +7 -0
- package/src/runtime/layout/resizeFrame.ts +2 -2
- package/src/runtime/settings.ts +69 -49
- package/src/runtime/types/index.ts +143 -28
- package/dist/runtime/layout/closeFrame.d.ts +0 -5
- package/dist/runtime/layout/closeFrame.js +0 -13
- package/dist/runtime/layout/closeFrames.d.ts +0 -2
- package/dist/runtime/layout/closeFrames.js +0 -8
- package/dist/runtime/layout/createSplitDecoEdge.d.ts +0 -2
- package/dist/runtime/layout/frameSplit.d.ts +0 -16
- package/dist/runtime/layout/frameSplit.js +0 -9
- package/dist/runtime/layout/isPointInFrame.d.ts +0 -2
- package/src/runtime/layout/closeFrame.ts +0 -33
- package/src/runtime/layout/closeFrames.ts +0 -14
- package/src/runtime/layout/frameSplit.ts +0 -31
- package/src/runtime/layout/isPointInFrame.ts +0 -7
package/README.md
CHANGED
|
@@ -112,38 +112,25 @@ This is done like this to make it easy to keep the dimensions rounded to x decim
|
|
|
112
112
|
|
|
113
113
|
## Configuration
|
|
114
114
|
|
|
115
|
-
There are a few variables that need to be used nearly everywhere such as `
|
|
115
|
+
There are a few variables that need to be used nearly everywhere internally such as `settings.scale`.
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
They are exported from `/settings.js` and stored in a variable called `globalOptions` which you can modify, but helpers are provided for getting/setting the information we actually want to extract using these variables, `maxInt`, `margin`, `snapPoint`.
|
|
117
|
+
To avoid having to pass them around into functions, they are exported from `/settings.js` and stored in a class instance called `settings` with special getters on the non-scaled values to automatically set scaled ones.
|
|
120
118
|
|
|
121
119
|
```ts
|
|
122
|
-
import {
|
|
123
|
-
globalOptions,
|
|
124
|
-
getMaxInt,
|
|
125
|
-
// this is called snapPoint because it's type looks like a point
|
|
126
|
-
// but it's more like it describes snap steps / distance in x/y
|
|
127
|
-
getSnapPoint,
|
|
128
|
-
setScale,
|
|
129
|
-
setSnapAmount
|
|
130
|
-
} from "@witchcraft-layout/settings.js"
|
|
120
|
+
import { settings } from "@witchcraft-layout/settings.js"
|
|
131
121
|
|
|
132
122
|
// the function checks the max number is safe to use (using `isSafeInteger`)
|
|
133
123
|
// 3 decimal points of precision
|
|
134
|
-
|
|
124
|
+
settings.scale = 3 // setter forces recacl of other values
|
|
125
|
+
settings.maxInt; // 100000 (100 * (10 ** 3))
|
|
135
126
|
// snap to 1%
|
|
136
|
-
|
|
127
|
+
settings.snapPoint = 1
|
|
137
128
|
// snap x/y differently
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
settings.snapPoint = { x: 1, y: 2 }
|
|
130
|
+
settings.minSize = 5 (5%)
|
|
140
131
|
|
|
141
|
-
// like doing const maxInt = globalOptions.maxInt
|
|
142
|
-
const maxInt = getMaxInt() // 100000
|
|
143
|
-
const snapAmountPoint = getSnapPoint() // { x: 1000, y: 1000 }
|
|
144
|
-
const marginSize = getMarginSize() // { width: 1000, height: 1000 }
|
|
145
132
|
```
|
|
146
|
-
**NOTE: If you are saving layouts, if you change the snap or the
|
|
133
|
+
**NOTE: If you are saving layouts, if you change the snap or the min size to a bigger value, old layouts will become "invalid".** They should still load and you should be able to close frames, but it's not guaranteed they'll function correctly with other actions.
|
|
147
134
|
|
|
148
135
|
There are utilities for converting between non-scaled and scaled values if you need to:
|
|
149
136
|
|
|
@@ -190,6 +177,16 @@ Edges and Decos are very simple and there are various utilies like `getVisualEdg
|
|
|
190
177
|
|
|
191
178
|
This has the benefit for edges, that the grabable area can be easily adjusted and bigger than the displayed edge.
|
|
192
179
|
|
|
180
|
+
## Making Changes
|
|
181
|
+
|
|
182
|
+
The majority of actions are done in two steps:
|
|
183
|
+
|
|
184
|
+
1. `get*Info` (e.g. `getFrameSplitInfo`) functions that return a `LayoutChange` object. These don't mutate the window and return the changes needed to apply the function. They can also be used to just check if the action can be done.
|
|
185
|
+
2. `applyFrameChanges` which applies these changes by mutating the window.
|
|
186
|
+
|
|
187
|
+
`get*Info` functions can return KnownErrors (e.g. out of bounds, can't split, no space, etc. see the `LAYOUT_ERROR` enum), which depending on the situation can be used to show an error decoration or just plain ignored.
|
|
188
|
+
They only throw for logical errors (e.g. passing an invalid frame id, trying to undock an undocked frame) which indicate errors in your calling code.
|
|
189
|
+
|
|
193
190
|
## Dragging
|
|
194
191
|
|
|
195
192
|
Then you will need to add dragging. This is not implemented by default (except for vue) as the state and rendering of a layout being dragged like this is almost always tightly coupled with whatever framework you're using and how you've structured your app. What I've figured out how to separate such as the `DragDirectionStore` and the drag action handlers is in `/drag`.
|
|
@@ -203,16 +200,15 @@ Add a `pointerdown` handler to all the edges.
|
|
|
203
200
|
You can then use `toWindowCoord` to translate the event coordinates into a point.
|
|
204
201
|
|
|
205
202
|
Before using it, you should be sure the window's coordinates are updated as this requires knowing the x/y px offset and the window dimensions.
|
|
206
|
-
|
|
207
203
|
```ts
|
|
208
204
|
const point = toWindowCoord(win, e, snapPoint) // snapPoint is optional, it uses the global settings
|
|
209
|
-
```
|
|
210
205
|
|
|
211
206
|
One drag starts, I suggest making a copy of the original positions in case you need to cancel the drag. This can be further optimized by only cloning and modifying the touching frames and overlaying them over the unmoved edges to render them. See [Overlayed Frames Technique](#overlayed-frames-technique) below.
|
|
212
207
|
|
|
213
208
|
You can use the `DragDirectionStore `to help keep track of which direction the user is dragging.
|
|
214
209
|
|
|
215
210
|
Minus framework specific details, the drag handlers might look something like this:
|
|
211
|
+
|
|
216
212
|
```ts
|
|
217
213
|
// i suggest against a barrel import if not using all features, but this is for demo purposes
|
|
218
214
|
import {
|
|
@@ -410,11 +406,18 @@ Decos:
|
|
|
410
406
|
- Split:
|
|
411
407
|
- `.deco-split-new-frame` (new frame preview)
|
|
412
408
|
- `.deco-split-edge` (edge preview)
|
|
409
|
+
- `.deco-split-error` (split preview in error state)
|
|
410
|
+
- FrameDrag:
|
|
411
|
+
- `.deco-frame-drag` (frame drag ghost preview)
|
|
412
|
+
- `.deco-frame-drag-error` (frame drag preview in error state)
|
|
413
|
+
- `.deco-frame-drag-${type}-${side}` (e.g. `.deco-frame-drag-frame-left`, `.deco-frame-drag-zone-right`)
|
|
414
|
+
|
|
413
415
|
|
|
414
416
|
State classes (so you can do stuff like `.request-split .drag-edge`)
|
|
415
417
|
- `.dragging`
|
|
416
418
|
- `.request-split`
|
|
417
419
|
- `.request-close`
|
|
420
|
+
- `.request-frame-drag`
|
|
418
421
|
|
|
419
422
|
Several css variables are provided to help with sizing:
|
|
420
423
|
- `--layoutHandleWidth`
|
package/dist/module.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
frameId: string;
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_1: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_1) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="cursor-grabbing"
|
|
4
|
+
@pointerdown="handlePointerDown"
|
|
5
|
+
>
|
|
6
|
+
<slot/>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
import { inject, onBeforeUnmount } from "vue";
|
|
12
|
+
import { dragContextInjectionKey } from "../drag/types.js";
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
frameId: { type: String, required: true }
|
|
15
|
+
});
|
|
16
|
+
const dragContext = inject(dragContextInjectionKey);
|
|
17
|
+
if (!dragContext) {
|
|
18
|
+
throw new Error("FrameDragHandle must be used inside a LayoutWindow and drag context returned by useFrames must be injected.");
|
|
19
|
+
}
|
|
20
|
+
function handlePointerDown(e) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
dragContext.dragStart(e, "frame", { frameId: props.frameId });
|
|
24
|
+
}
|
|
25
|
+
onBeforeUnmount(() => {
|
|
26
|
+
dragContext.cancel();
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
frameId: string;
|
|
3
|
+
};
|
|
4
|
+
declare var __VLS_1: {};
|
|
5
|
+
type __VLS_Slots = {} & {
|
|
6
|
+
default?: (props: typeof __VLS_1) => any;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { LayoutShape } from "../types/index.js";
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
4
|
-
splitDecos: SplitDeco[];
|
|
5
|
-
closeDecos: CloseDeco[];
|
|
3
|
+
shapes: LayoutShape[];
|
|
6
4
|
};
|
|
7
5
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
6
|
export default _default;
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<template
|
|
3
|
-
v-for="(
|
|
4
|
-
|
|
3
|
+
v-for="(shape, i) of shapes"
|
|
4
|
+
:key="`${shape.type}-${i}`"
|
|
5
5
|
>
|
|
6
6
|
<LayoutShapeSquare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
:css="getShapeSquareCss(deco.shapes.newFrame, `var(--layoutEdgeWidth,2px)`)"
|
|
7
|
+
v-if="shape.type === 'square'"
|
|
8
|
+
:css="getShapeSquareCss(shape.data, `var(--layoutEdgeWidth,2px)`)"
|
|
9
|
+
v-bind="shape.attrs ?? {}"
|
|
12
10
|
/>
|
|
13
11
|
<LayoutShapeSquare
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
:css="getVisualEdgeCss(deco.shapes.edge, { padLongAxis: `var(--layoutEdgeWidth,2px)` })"
|
|
19
|
-
/>
|
|
20
|
-
</template>
|
|
21
|
-
<template
|
|
22
|
-
v-for="deco of closeDecos"
|
|
23
|
-
:key="deco.id"
|
|
24
|
-
>
|
|
25
|
-
<LayoutShapeSquare
|
|
26
|
-
:class="`
|
|
27
|
-
${deco.force ? 'deco-close-force-frame' : 'deco-close-frame'}
|
|
28
|
-
bg-red-500/50
|
|
29
|
-
`"
|
|
30
|
-
:css="getShapeSquareCss(frames[deco.id], `var(--layoutEdgeWidth,2px)`)"
|
|
12
|
+
v-else-if="shape.type === 'edge'"
|
|
13
|
+
:css="getVisualEdgeCss(shape.data, { padLongAxis: 'var(--layoutEdgeWidth,2px)' })"
|
|
14
|
+
v-bind="shape.attrs ?? {}"
|
|
31
15
|
/>
|
|
32
16
|
</template>
|
|
33
17
|
</template>
|
|
@@ -36,10 +20,7 @@
|
|
|
36
20
|
import LayoutShapeSquare from "./LayoutShapeSquare.vue";
|
|
37
21
|
import { getShapeSquareCss } from "../helpers/getShapeSquareCss";
|
|
38
22
|
import { getVisualEdgeCss } from "../helpers/getVisualEdgeCss";
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
frames: { type: Object, required: true },
|
|
42
|
-
splitDecos: { type: Array, required: true },
|
|
43
|
-
closeDecos: { type: Array, required: true }
|
|
23
|
+
defineProps({
|
|
24
|
+
shapes: { type: Array, required: true }
|
|
44
25
|
});
|
|
45
26
|
</script>
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { LayoutShape } from "../types/index.js";
|
|
2
2
|
type __VLS_Props = {
|
|
3
|
-
|
|
4
|
-
splitDecos: SplitDeco[];
|
|
5
|
-
closeDecos: CloseDeco[];
|
|
3
|
+
shapes: LayoutShape[];
|
|
6
4
|
};
|
|
7
5
|
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
6
|
export default _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Edge, IntersectionEntry, LayoutEdgesProps } from "../types/index.js";
|
|
2
2
|
declare const _default: import("vue").DefineComponent<LayoutEdgesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
-
dragStart: (e: PointerEvent,
|
|
3
|
+
dragStart: (e: PointerEvent, type: "edge", opts: {
|
|
4
4
|
edge?: Edge;
|
|
5
5
|
intersection?: IntersectionEntry;
|
|
6
6
|
}) => any;
|
|
7
7
|
}, string, import("vue").PublicProps, Readonly<LayoutEdgesProps> & Readonly<{
|
|
8
|
-
onDragStart?: ((e: PointerEvent,
|
|
8
|
+
onDragStart?: ((e: PointerEvent, type: "edge", opts: {
|
|
9
9
|
edge?: Edge;
|
|
10
10
|
intersection?: IntersectionEntry;
|
|
11
11
|
}) => any) | undefined;
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
z-0
|
|
10
10
|
border-blue-500
|
|
11
11
|
border
|
|
12
|
-
rounded-md
|
|
13
12
|
`,
|
|
14
13
|
$attrs.class
|
|
15
14
|
)"
|
|
16
15
|
v-bind="{ ...$attrs, class: void 0 }"
|
|
17
16
|
/>
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
<template
|
|
20
19
|
v-for="css, i of cssDragEdges"
|
|
21
20
|
:key="i"
|
|
@@ -28,9 +27,9 @@
|
|
|
28
27
|
hover:cursor-pointer
|
|
29
28
|
[&:hover+.edge]:bg-blue-500/50
|
|
30
29
|
`)"
|
|
31
|
-
@pointerdown="emit('dragStart', $event, { edge: edges[i] })"
|
|
30
|
+
@pointerdown="emit('dragStart', $event, 'edge', { edge: edges[i] })"
|
|
32
31
|
/>
|
|
33
|
-
|
|
32
|
+
<LayoutShapeSquare
|
|
34
33
|
:css="css.thin"
|
|
35
34
|
:class="twMerge(`
|
|
36
35
|
pointer-events-none
|
|
@@ -49,7 +48,10 @@
|
|
|
49
48
|
v-for="css, i of cssDragEdge"
|
|
50
49
|
:key="i"
|
|
51
50
|
/>
|
|
52
|
-
<template
|
|
51
|
+
<template
|
|
52
|
+
v-for="css, i of cssDragIntersections"
|
|
53
|
+
:key="i"
|
|
54
|
+
>
|
|
53
55
|
<LayoutShapeSquare
|
|
54
56
|
:css="css.thick"
|
|
55
57
|
:class="twMerge(
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
[&:hover+.intersection]:bg-blue-500/50
|
|
62
64
|
`
|
|
63
65
|
)"
|
|
64
|
-
@pointerdown="emit('dragStart', $event, { intersection: wantedIntersections[i] })"
|
|
66
|
+
@pointerdown="emit('dragStart', $event, 'edge', { intersection: wantedIntersections[i] })"
|
|
65
67
|
/>
|
|
66
68
|
<LayoutShapeSquare
|
|
67
69
|
:css="css.thin"
|
|
@@ -86,8 +88,6 @@ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
|
|
|
86
88
|
import { getShapeSquareCss } from "../helpers/getShapeSquareCss.js";
|
|
87
89
|
import { getVisualEdgesCss } from "../helpers/getVisualEdgesCss.js";
|
|
88
90
|
import { isEdgeEqual } from "../helpers/isEdgeEqual.js";
|
|
89
|
-
import {
|
|
90
|
-
} from "../types/index.js";
|
|
91
91
|
const $attrs = useAttrs();
|
|
92
92
|
defineOptions({
|
|
93
93
|
inheritAttrs: false
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Edge, IntersectionEntry, LayoutEdgesProps } from "../types/index.js";
|
|
2
2
|
declare const _default: import("vue").DefineComponent<LayoutEdgesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
-
dragStart: (e: PointerEvent,
|
|
3
|
+
dragStart: (e: PointerEvent, type: "edge", opts: {
|
|
4
4
|
edge?: Edge;
|
|
5
5
|
intersection?: IntersectionEntry;
|
|
6
6
|
}) => any;
|
|
7
7
|
}, string, import("vue").PublicProps, Readonly<LayoutEdgesProps> & Readonly<{
|
|
8
|
-
onDragStart?: ((e: PointerEvent,
|
|
8
|
+
onDragStart?: ((e: PointerEvent, type: "edge", opts: {
|
|
9
9
|
edge?: Edge;
|
|
10
10
|
intersection?: IntersectionEntry;
|
|
11
11
|
}) => any) | undefined;
|
|
@@ -33,7 +33,6 @@ defineOptions({
|
|
|
33
33
|
import LayoutShapeSquare from "./LayoutShapeSquare.vue";
|
|
34
34
|
import { getShapeSquareCss } from "../helpers/getShapeSquareCss";
|
|
35
35
|
import { debugFrame } from "../layout/debugFrame.js";
|
|
36
|
-
import {} from "../types/index.js";
|
|
37
36
|
const emit = defineEmits(["focus"]);
|
|
38
37
|
defineProps({
|
|
39
38
|
frame: { type: Object, required: true },
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
1
2
|
import type { LayoutShapeSquareProps } from "../types/index.js";
|
|
3
|
+
type __VLS_Props = LayoutShapeSquareProps & /** @vue-ignore */ HTMLAttributes;
|
|
2
4
|
declare var __VLS_1: {};
|
|
3
5
|
type __VLS_Slots = {} & {
|
|
4
6
|
default?: (props: typeof __VLS_1) => any;
|
|
5
7
|
};
|
|
6
|
-
declare const __VLS_component: import("vue").DefineComponent<
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
9
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
8
10
|
export default _default;
|
|
9
11
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "vue";
|
|
1
2
|
import type { LayoutShapeSquareProps } from "../types/index.js";
|
|
3
|
+
type __VLS_Props = LayoutShapeSquareProps & /** @vue-ignore */ HTMLAttributes;
|
|
2
4
|
declare var __VLS_1: {};
|
|
3
5
|
type __VLS_Slots = {} & {
|
|
4
6
|
default?: (props: typeof __VLS_1) => any;
|
|
5
7
|
};
|
|
6
|
-
declare const __VLS_component: import("vue").DefineComponent<
|
|
8
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
9
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
8
10
|
export default _default;
|
|
9
11
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import { DragActionHandler } from "../drag/DragActionHandler";
|
|
1
2
|
import { type DragState, type IDragAction } from "../drag/types.js";
|
|
2
|
-
import {
|
|
3
|
+
import type { LayoutEdgesProps, LayoutFrameProps, LayoutWindow } from "../types/index.js";
|
|
3
4
|
type __VLS_Props = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/** Custom drag action handlers. Falls back to default split/close/frame handlers if not provided. */
|
|
6
|
+
actionHandlers?: IDragAction[];
|
|
7
|
+
textHints?: {
|
|
8
|
+
text: string;
|
|
9
|
+
classes?: string;
|
|
10
|
+
}[];
|
|
11
|
+
textHintsTeleportTo: string | undefined;
|
|
12
|
+
ghostTeleportTo?: string;
|
|
9
13
|
/**
|
|
10
14
|
* You might need to temporarily disable updating the window size while transitioning, depending on your layout.
|
|
11
15
|
*
|
|
@@ -23,9 +27,13 @@ type __VLS_PublicProps = __VLS_Props & {
|
|
|
23
27
|
};
|
|
24
28
|
declare var __VLS_9: any, __VLS_10: {
|
|
25
29
|
frame: any;
|
|
26
|
-
}, __VLS_22: {}
|
|
30
|
+
}, __VLS_22: {}, __VLS_29: any, __VLS_30: {
|
|
31
|
+
id: any;
|
|
32
|
+
};
|
|
27
33
|
type __VLS_Slots = {} & {
|
|
28
34
|
[K in NonNullable<typeof __VLS_9>]?: (props: typeof __VLS_10) => any;
|
|
35
|
+
} & {
|
|
36
|
+
[K in NonNullable<typeof __VLS_29>]?: (props: typeof __VLS_30) => any;
|
|
29
37
|
} & {
|
|
30
38
|
'extra-decos'?: (props: typeof __VLS_22) => any;
|
|
31
39
|
};
|
|
@@ -39,7 +47,9 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps,
|
|
|
39
47
|
x: number;
|
|
40
48
|
y: number;
|
|
41
49
|
} | undefined;
|
|
42
|
-
isDragging:
|
|
50
|
+
isDragging: false | "edge" | "frame";
|
|
51
|
+
showDragging: boolean;
|
|
52
|
+
draggingFrameId: string | undefined;
|
|
43
53
|
draggingEdges: {
|
|
44
54
|
startX: number;
|
|
45
55
|
startY: number;
|
|
@@ -85,6 +95,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps,
|
|
|
85
95
|
}>;
|
|
86
96
|
win: import("vue").ModelRef<import("../types/index.js").BaseLayoutWindow, string, import("../types/index.js").BaseLayoutWindow, import("../types/index.js").BaseLayoutWindow>;
|
|
87
97
|
updateWindowSize: typeof updateWindowSize;
|
|
98
|
+
dragActionHandler: DragActionHandler<IDragAction[], import("@alanscodelog/utils").RecordFromArray<IDragAction[], "name">>;
|
|
88
99
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
89
100
|
"update:win": (value: import("../types/index.js").BaseLayoutWindow) => any;
|
|
90
101
|
} & {
|
|
@@ -95,10 +106,13 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps,
|
|
|
95
106
|
onDragState?: ((value: DragState) => any) | undefined;
|
|
96
107
|
"onUpdate:win"?: ((value: import("../types/index.js").BaseLayoutWindow) => any) | undefined;
|
|
97
108
|
}>, {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
actionHandlers: IDragAction[];
|
|
110
|
+
textHints: {
|
|
111
|
+
text: string;
|
|
112
|
+
classes?: string;
|
|
113
|
+
}[];
|
|
114
|
+
textHintsTeleportTo: string | undefined;
|
|
115
|
+
ghostTeleportTo: string;
|
|
102
116
|
allowWindowSizeUpdate: boolean;
|
|
103
117
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
104
118
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|