@witchcraft/layout 0.1.2 → 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.
Files changed (190) hide show
  1. package/README.md +27 -24
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/FrameDragHandle.d.vue.ts +15 -0
  4. package/dist/runtime/components/FrameDragHandle.vue +28 -0
  5. package/dist/runtime/components/FrameDragHandle.vue.d.ts +15 -0
  6. package/dist/runtime/components/LayoutDecos.d.vue.ts +2 -4
  7. package/dist/runtime/components/LayoutDecos.vue +10 -29
  8. package/dist/runtime/components/LayoutDecos.vue.d.ts +2 -4
  9. package/dist/runtime/components/LayoutEdges.d.vue.ts +3 -3
  10. package/dist/runtime/components/LayoutEdges.vue +9 -10
  11. package/dist/runtime/components/LayoutEdges.vue.d.ts +3 -3
  12. package/dist/runtime/components/LayoutFrame.d.vue.ts +1 -1
  13. package/dist/runtime/components/LayoutFrame.vue +1 -4
  14. package/dist/runtime/components/LayoutFrame.vue.d.ts +1 -1
  15. package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +3 -1
  16. package/dist/runtime/components/LayoutShapeSquare.vue +3 -5
  17. package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +3 -1
  18. package/dist/runtime/components/LayoutWindow.d.vue.ts +26 -12
  19. package/dist/runtime/components/LayoutWindow.vue +95 -84
  20. package/dist/runtime/components/LayoutWindow.vue.d.ts +26 -12
  21. package/dist/runtime/composables/useFrames.d.ts +15 -13
  22. package/dist/runtime/composables/useFrames.js +59 -39
  23. package/dist/runtime/demo/App.vue +116 -30
  24. package/dist/runtime/demo/DemoControls.d.vue.ts +4 -1
  25. package/dist/runtime/demo/DemoControls.vue +98 -4
  26. package/dist/runtime/demo/DemoControls.vue.d.ts +4 -1
  27. package/dist/runtime/drag/CloseAction.d.ts +26 -5
  28. package/dist/runtime/drag/CloseAction.js +87 -40
  29. package/dist/runtime/drag/DragActionHandler.d.ts +20 -8
  30. package/dist/runtime/drag/DragActionHandler.js +47 -12
  31. package/dist/runtime/drag/FrameDragAction.d.ts +45 -0
  32. package/dist/runtime/drag/FrameDragAction.js +143 -0
  33. package/dist/runtime/drag/SplitAction.d.ts +32 -11
  34. package/dist/runtime/drag/SplitAction.js +82 -24
  35. package/dist/runtime/drag/createDefaultHandlers.d.ts +9 -0
  36. package/dist/runtime/drag/createDefaultHandlers.js +10 -0
  37. package/dist/runtime/drag/defaultDragActions.d.ts +9 -0
  38. package/dist/runtime/drag/defaultDragActions.js +10 -0
  39. package/dist/runtime/drag/types.d.ts +82 -13
  40. package/dist/runtime/drag/types.js +1 -0
  41. package/dist/runtime/helpers/createZoneSideClipPath.d.ts +12 -0
  42. package/dist/runtime/helpers/createZoneSideClipPath.js +17 -0
  43. package/dist/runtime/helpers/doEdgesOverlap.d.ts +3 -1
  44. package/dist/runtime/helpers/doEdgesOverlap.js +5 -5
  45. package/dist/runtime/helpers/getDockBoundaries.d.ts +19 -0
  46. package/dist/runtime/helpers/getDockBoundaries.js +14 -0
  47. package/dist/runtime/helpers/getEdgeLength.d.ts +2 -0
  48. package/dist/runtime/helpers/getEdgeLength.js +5 -0
  49. package/dist/runtime/helpers/getIntersections.js +2 -2
  50. package/dist/runtime/helpers/getIntersectionsCss.js +2 -2
  51. package/dist/runtime/helpers/getMoveEdgeInfo.js +2 -2
  52. package/dist/runtime/helpers/getResizeLimit.js +2 -2
  53. package/dist/runtime/helpers/getShapeSquareCss.js +2 -2
  54. package/dist/runtime/helpers/getVisualEdgeCss.js +2 -2
  55. package/dist/runtime/helpers/getVisualEdges.d.ts +1 -1
  56. package/dist/runtime/helpers/getVisualEdges.js +4 -3
  57. package/dist/runtime/helpers/index.d.ts +4 -0
  58. package/dist/runtime/helpers/index.js +4 -0
  59. package/dist/runtime/helpers/isEdgeEqual.js +2 -4
  60. package/dist/runtime/helpers/isWindowEdge.js +2 -2
  61. package/dist/runtime/helpers/isWindowEdgePoint.js +2 -2
  62. package/dist/runtime/helpers/moveEdge.js +2 -2
  63. package/dist/runtime/helpers/numberToScaledPercent.d.ts +1 -1
  64. package/dist/runtime/helpers/numberToScaledPercent.js +2 -2
  65. package/dist/runtime/helpers/numberToScaledSize.js +2 -2
  66. package/dist/runtime/helpers/rotateFrames.d.ts +7 -0
  67. package/dist/runtime/helpers/rotateFrames.js +36 -0
  68. package/dist/runtime/helpers/scaledPointToPx.d.ts +13 -0
  69. package/dist/runtime/helpers/scaledPointToPx.js +7 -0
  70. package/dist/runtime/helpers/toWindowCoord.js +2 -2
  71. package/dist/runtime/layout/applyFrameChanges.d.ts +10 -0
  72. package/dist/runtime/layout/applyFrameChanges.js +29 -0
  73. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +6 -1
  74. package/dist/runtime/layout/createSplitDecoFromDrag.js +4 -4
  75. package/dist/runtime/layout/createSplitDecoShapes.d.ts +7 -0
  76. package/dist/runtime/layout/{createSplitDecoEdge.js → createSplitDecoShapes.js} +6 -3
  77. package/dist/runtime/layout/debugFrame.js +2 -1
  78. package/dist/runtime/layout/findSafeSplitEdge.js +2 -2
  79. package/dist/runtime/layout/frameCreate.js +2 -2
  80. package/dist/runtime/layout/getCloseFrameInfo.d.ts +7 -6
  81. package/dist/runtime/layout/getCloseFrameInfo.js +10 -3
  82. package/dist/runtime/layout/getDragZones.d.ts +8 -0
  83. package/dist/runtime/layout/getDragZones.js +32 -0
  84. package/dist/runtime/layout/getFillEmptySpaceInfo.d.ts +65 -0
  85. package/dist/runtime/layout/getFillEmptySpaceInfo.js +69 -0
  86. package/dist/runtime/layout/getFrameCollapseInfo.d.ts +13 -0
  87. package/dist/runtime/layout/getFrameCollapseInfo.js +93 -0
  88. package/dist/runtime/layout/getFrameDockInfo.d.ts +9 -0
  89. package/dist/runtime/layout/getFrameDockInfo.js +82 -0
  90. package/dist/runtime/layout/getFrameDragZones.d.ts +16 -0
  91. package/dist/runtime/layout/getFrameDragZones.js +74 -0
  92. package/dist/runtime/layout/getFrameRearrangeInfo.d.ts +139 -0
  93. package/dist/runtime/layout/getFrameRearrangeInfo.js +87 -0
  94. package/dist/runtime/layout/getFrameSplitInfo.d.ts +7 -5
  95. package/dist/runtime/layout/getFrameSplitInfo.js +10 -3
  96. package/dist/runtime/layout/getFrameSwapInfo.d.ts +9 -0
  97. package/dist/runtime/layout/getFrameSwapInfo.js +27 -0
  98. package/dist/runtime/layout/getFrameTo.js +2 -2
  99. package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +12 -0
  100. package/dist/runtime/layout/getFrameUncollapseInfo.js +88 -0
  101. package/dist/runtime/layout/getFrameUndockInfo.d.ts +13 -0
  102. package/dist/runtime/layout/getFrameUndockInfo.js +51 -0
  103. package/dist/runtime/layout/getFramesRedistributeInfo.d.ts +29 -0
  104. package/dist/runtime/layout/getFramesRedistributeInfo.js +53 -0
  105. package/dist/runtime/layout/getWindowDragZones.d.ts +6 -0
  106. package/dist/runtime/layout/getWindowDragZones.js +49 -0
  107. package/dist/runtime/layout/index.d.ts +14 -5
  108. package/dist/runtime/layout/index.js +14 -5
  109. package/dist/runtime/layout/isPointInRect.d.ts +7 -0
  110. package/dist/runtime/layout/{isPointInFrame.js → isPointInRect.js} +1 -1
  111. package/dist/runtime/layout/resizeFrame.js +2 -2
  112. package/dist/runtime/settings.d.ts +41 -16
  113. package/dist/runtime/settings.js +95 -53
  114. package/dist/runtime/types/index.d.ts +324 -55
  115. package/dist/runtime/types/index.js +54 -20
  116. package/package.json +28 -29
  117. package/src/runtime/components/FrameDragHandle.vue +30 -0
  118. package/src/runtime/components/LayoutDecos.vue +12 -36
  119. package/src/runtime/components/LayoutEdges.vue +27 -22
  120. package/src/runtime/components/LayoutFrame.vue +6 -5
  121. package/src/runtime/components/LayoutShapeSquare.vue +11 -5
  122. package/src/runtime/components/LayoutWindow.vue +110 -101
  123. package/src/runtime/composables/useFrames.ts +80 -50
  124. package/src/runtime/demo/App.vue +126 -36
  125. package/src/runtime/demo/DemoControls.vue +115 -6
  126. package/src/runtime/drag/CloseAction.ts +106 -44
  127. package/src/runtime/drag/DragActionHandler.ts +71 -20
  128. package/src/runtime/drag/FrameDragAction.ts +202 -0
  129. package/src/runtime/drag/SplitAction.ts +106 -34
  130. package/src/runtime/drag/createDefaultHandlers.ts +19 -0
  131. package/src/runtime/drag/defaultDragActions.ts +19 -0
  132. package/src/runtime/drag/types.ts +90 -20
  133. package/src/runtime/helpers/createZoneSideClipPath.ts +41 -0
  134. package/src/runtime/helpers/doEdgesOverlap.ts +11 -5
  135. package/src/runtime/helpers/getDockBoundaries.ts +36 -0
  136. package/src/runtime/helpers/getEdgeLength.ts +10 -0
  137. package/src/runtime/helpers/getIntersections.ts +2 -2
  138. package/src/runtime/helpers/getIntersectionsCss.ts +2 -2
  139. package/src/runtime/helpers/getMoveEdgeInfo.ts +2 -2
  140. package/src/runtime/helpers/getResizeLimit.ts +2 -2
  141. package/src/runtime/helpers/getShapeSquareCss.ts +2 -2
  142. package/src/runtime/helpers/getVisualEdgeCss.ts +2 -2
  143. package/src/runtime/helpers/getVisualEdges.ts +5 -4
  144. package/src/runtime/helpers/index.ts +4 -0
  145. package/src/runtime/helpers/isEdgeEqual.ts +2 -4
  146. package/src/runtime/helpers/isWindowEdge.ts +2 -2
  147. package/src/runtime/helpers/isWindowEdgePoint.ts +2 -2
  148. package/src/runtime/helpers/moveEdge.ts +2 -2
  149. package/src/runtime/helpers/numberToScaledPercent.ts +3 -3
  150. package/src/runtime/helpers/numberToScaledSize.ts +2 -2
  151. package/src/runtime/helpers/rotateFrames.ts +45 -0
  152. package/src/runtime/helpers/scaledPointToPx.ts +13 -0
  153. package/src/runtime/helpers/toWindowCoord.ts +2 -2
  154. package/src/runtime/layout/applyFrameChanges.ts +39 -0
  155. package/src/runtime/layout/createSplitDecoFromDrag.ts +12 -6
  156. package/src/runtime/layout/{createSplitDecoEdge.ts → createSplitDecoShapes.ts} +17 -7
  157. package/src/runtime/layout/debugFrame.ts +1 -1
  158. package/src/runtime/layout/findSafeSplitEdge.ts +3 -3
  159. package/src/runtime/layout/frameCreate.ts +2 -2
  160. package/src/runtime/layout/getCloseFrameInfo.ts +21 -8
  161. package/src/runtime/layout/getDragZones.ts +48 -0
  162. package/src/runtime/layout/getFillEmptySpaceInfo.ts +177 -0
  163. package/src/runtime/layout/getFrameCollapseInfo.ts +164 -0
  164. package/src/runtime/layout/getFrameDockInfo.ts +126 -0
  165. package/src/runtime/layout/getFrameDragZones.ts +100 -0
  166. package/src/runtime/layout/getFrameRearrangeInfo.ts +261 -0
  167. package/src/runtime/layout/getFrameSplitInfo.ts +21 -8
  168. package/src/runtime/layout/getFrameSwapInfo.ts +45 -0
  169. package/src/runtime/layout/getFrameTo.ts +2 -2
  170. package/src/runtime/layout/getFrameUncollapseInfo.ts +160 -0
  171. package/src/runtime/layout/getFrameUndockInfo.ts +97 -0
  172. package/src/runtime/layout/getFramesRedistributeInfo.ts +98 -0
  173. package/src/runtime/layout/getWindowDragZones.ts +59 -0
  174. package/src/runtime/layout/index.ts +14 -5
  175. package/src/runtime/layout/isPointInRect.ts +7 -0
  176. package/src/runtime/layout/resizeFrame.ts +2 -2
  177. package/src/runtime/settings.ts +69 -49
  178. package/src/runtime/types/index.ts +143 -28
  179. package/dist/runtime/layout/closeFrame.d.ts +0 -5
  180. package/dist/runtime/layout/closeFrame.js +0 -13
  181. package/dist/runtime/layout/closeFrames.d.ts +0 -2
  182. package/dist/runtime/layout/closeFrames.js +0 -8
  183. package/dist/runtime/layout/createSplitDecoEdge.d.ts +0 -2
  184. package/dist/runtime/layout/frameSplit.d.ts +0 -16
  185. package/dist/runtime/layout/frameSplit.js +0 -9
  186. package/dist/runtime/layout/isPointInFrame.d.ts +0 -2
  187. package/src/runtime/layout/closeFrame.ts +0 -33
  188. package/src/runtime/layout/closeFrames.ts +0 -14
  189. package/src/runtime/layout/frameSplit.ts +0 -31
  190. 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 `SCALE` and `SNAP_PERCENT_{X/Y}`.
115
+ There are a few variables that need to be used nearly everywhere internally such as `settings.scale`.
116
116
 
117
- While all function that need them, can also be called with params to override them, it's much easier to just manage them globally.
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
- setScale(3)
124
+ settings.scale = 3 // setter forces recacl of other values
125
+ settings.maxInt; // 100000 (100 * (10 ** 3))
135
126
  // snap to 1%
136
- setSnapPercentage(1)
127
+ settings.snapPoint = 1
137
128
  // snap x/y differently
138
- setSnapPercentage({ x: 1, y: 2 })
139
- setMarginPercentage(1)
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 margins to a bigger value, old layouts will become "invalid".** The should still load and you should be able to close frames, but it's not guaranteed they'll function correctly.
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.1.2",
4
+ "version": "0.2.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -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 { type CloseDeco, type LayoutFrames, type SplitDeco } from "../types/index.js";
1
+ import type { LayoutShape } from "../types/index.js";
2
2
  type __VLS_Props = {
3
- frames: LayoutFrames;
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="(deco) of splitDecos"
4
- :key="deco.id"
3
+ v-for="(shape, i) of shapes"
4
+ :key="`${shape.type}-${i}`"
5
5
  >
6
6
  <LayoutShapeSquare
7
- class="
8
- deco-split-new-frame
9
- bg-blue-500/50
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
- class="
15
- deco-split-edge
16
- bg-red-500
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
- import {} from "../types/index.js";
40
- const props = defineProps({
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 { type CloseDeco, type LayoutFrames, type SplitDeco } from "../types/index.js";
1
+ import type { LayoutShape } from "../types/index.js";
2
2
  type __VLS_Props = {
3
- frames: LayoutFrames;
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 { type Edge, type IntersectionEntry, type LayoutEdgesProps } from "../types/index.js";
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, args_1: {
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, args_1: {
8
+ onDragStart?: ((e: PointerEvent, type: "edge", opts: {
9
9
  edge?: Edge;
10
10
  intersection?: IntersectionEntry;
11
11
  }) => any) | undefined;
@@ -14,7 +14,7 @@
14
14
  )"
15
15
  v-bind="{ ...$attrs, class: void 0 }"
16
16
  />
17
-
17
+
18
18
  <template
19
19
  v-for="css, i of cssDragEdges"
20
20
  :key="i"
@@ -27,9 +27,9 @@
27
27
  hover:cursor-pointer
28
28
  [&:hover+.edge]:bg-blue-500/50
29
29
  `)"
30
- @pointerdown="emit('dragStart', $event, { edge: edges[i] })"
30
+ @pointerdown="emit('dragStart', $event, 'edge', { edge: edges[i] })"
31
31
  />
32
- <LayoutShapeSquare
32
+ <LayoutShapeSquare
33
33
  :css="css.thin"
34
34
  :class="twMerge(`
35
35
  pointer-events-none
@@ -48,7 +48,10 @@
48
48
  v-for="css, i of cssDragEdge"
49
49
  :key="i"
50
50
  />
51
- <template v-for="css, i of cssDragIntersections" :key="i">
51
+ <template
52
+ v-for="css, i of cssDragIntersections"
53
+ :key="i"
54
+ >
52
55
  <LayoutShapeSquare
53
56
  :css="css.thick"
54
57
  :class="twMerge(
@@ -60,7 +63,7 @@
60
63
  [&:hover+.intersection]:bg-blue-500/50
61
64
  `
62
65
  )"
63
- @pointerdown="emit('dragStart', $event, { intersection: wantedIntersections[i] })"
66
+ @pointerdown="emit('dragStart', $event, 'edge', { intersection: wantedIntersections[i] })"
64
67
  />
65
68
  <LayoutShapeSquare
66
69
  :css="css.thin"
@@ -85,8 +88,6 @@ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
85
88
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss.js";
86
89
  import { getVisualEdgesCss } from "../helpers/getVisualEdgesCss.js";
87
90
  import { isEdgeEqual } from "../helpers/isEdgeEqual.js";
88
- import {
89
- } from "../types/index.js";
90
91
  const $attrs = useAttrs();
91
92
  defineOptions({
92
93
  inheritAttrs: false
@@ -99,9 +100,7 @@ const props = defineProps({
99
100
  activeFrame: { type: Object, required: false, default: void 0 },
100
101
  draggingEdge: { type: null, required: false, default: void 0 },
101
102
  draggingIntersection: { type: Object, required: false, default: void 0 },
102
- css: { type: Object, required: false },
103
- style: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
104
- class: { type: String, required: false }
103
+ css: { type: Object, required: false }
105
104
  });
106
105
  const cssDragEdges = computed(() => {
107
106
  const thickEdges = getVisualEdgesCss(
@@ -1,11 +1,11 @@
1
- import { type Edge, type IntersectionEntry, type LayoutEdgesProps } from "../types/index.js";
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, args_1: {
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, args_1: {
8
+ onDragStart?: ((e: PointerEvent, type: "edge", opts: {
9
9
  edge?: Edge;
10
10
  intersection?: IntersectionEntry;
11
11
  }) => any) | undefined;
@@ -1,4 +1,4 @@
1
- import { type LayoutFrameProps } from "../types/index.js";
1
+ import type { LayoutFrameProps } from "../types/index.js";
2
2
  declare var __VLS_8: {};
3
3
  type __VLS_Slots = {} & {
4
4
  default?: (props: typeof __VLS_8) => any;
@@ -33,13 +33,10 @@ 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 },
40
39
  isActiveFrame: { type: Boolean, required: true },
41
- css: { type: Object, required: false },
42
- style: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
43
- class: { type: String, required: false }
40
+ css: { type: Object, required: false }
44
41
  });
45
42
  </script>
@@ -1,4 +1,4 @@
1
- import { type LayoutFrameProps } from "../types/index.js";
1
+ import type { LayoutFrameProps } from "../types/index.js";
2
2
  declare var __VLS_8: {};
3
3
  type __VLS_Slots = {} & {
4
4
  default?: (props: typeof __VLS_8) => any;
@@ -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<LayoutShapeSquareProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LayoutShapeSquareProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
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,12 +1,12 @@
1
1
  <template>
2
2
  <div
3
- :style="`
3
+ :style="[`
4
4
  --posX:${css.x};
5
5
  --posY:${css.y};
6
6
  --width:${css.width};
7
7
  --height:${css.height};
8
8
  ${css.translate ? `--translate:${css.translate}` : ``}
9
- ` + style"
9
+ `, $attrs.style]"
10
10
  :class="twMerge(
11
11
  `
12
12
  absolute
@@ -32,8 +32,6 @@ defineOptions({
32
32
  inheritAttrs: false
33
33
  });
34
34
  const props = defineProps({
35
- css: { type: Object, required: true },
36
- style: { type: [Boolean, null, String, Object, Array], required: false, skipCheck: true },
37
- class: { type: String, required: false }
35
+ css: { type: Object, required: true }
38
36
  });
39
37
  </script>
@@ -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<LayoutShapeSquareProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<LayoutShapeSquareProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
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 { type LayoutEdgesProps, type LayoutFrameProps, type LayoutWindow } from "../types/index.js";
3
+ import type { LayoutEdgesProps, LayoutFrameProps, LayoutWindow } from "../types/index.js";
3
4
  type __VLS_Props = {
4
- additionalDragActions?: IDragAction[];
5
- splitKeyHandler?: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
6
- closeKeyHandler?: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
7
- usageInstructions?: Record<string, string | undefined>;
8
- instructionsTeleportTo: string | undefined;
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: boolean;
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
- additionalDragActions: IDragAction[];
99
- splitKeyHandler: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
100
- closeKeyHandler: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
101
- usageInstructions: Record<string, string | undefined>;
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>;