@witchcraft/layout 1.0.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 (336) hide show
  1. package/README.md +474 -0
  2. package/dist/module.d.mts +14 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +26 -0
  5. package/dist/runtime/components/LayoutDecos.d.vue.ts +0 -0
  6. package/dist/runtime/components/LayoutDecos.vue +54 -0
  7. package/dist/runtime/components/LayoutDecos.vue.d.ts +0 -0
  8. package/dist/runtime/components/LayoutEdges.d.vue.ts +0 -0
  9. package/dist/runtime/components/LayoutEdges.vue +145 -0
  10. package/dist/runtime/components/LayoutEdges.vue.d.ts +0 -0
  11. package/dist/runtime/components/LayoutFrame.d.vue.ts +0 -0
  12. package/dist/runtime/components/LayoutFrame.vue +41 -0
  13. package/dist/runtime/components/LayoutFrame.vue.d.ts +0 -0
  14. package/dist/runtime/components/LayoutShapeSquare.d.vue.ts +0 -0
  15. package/dist/runtime/components/LayoutShapeSquare.vue +36 -0
  16. package/dist/runtime/components/LayoutShapeSquare.vue.d.ts +0 -0
  17. package/dist/runtime/components/LayoutWindow.d.vue.ts +0 -0
  18. package/dist/runtime/components/LayoutWindow.vue +183 -0
  19. package/dist/runtime/components/LayoutWindow.vue.d.ts +0 -0
  20. package/dist/runtime/composables/useFrames.d.ts +0 -0
  21. package/dist/runtime/composables/useFrames.js +184 -0
  22. package/dist/runtime/demo/App.d.vue.ts +0 -0
  23. package/dist/runtime/demo/App.vue +123 -0
  24. package/dist/runtime/demo/App.vue.d.ts +0 -0
  25. package/dist/runtime/demo/DemoControls.d.vue.ts +0 -0
  26. package/dist/runtime/demo/DemoControls.vue +14 -0
  27. package/dist/runtime/demo/DemoControls.vue.d.ts +0 -0
  28. package/dist/runtime/demo/README.md +1 -0
  29. package/dist/runtime/demo/main.d.ts +0 -0
  30. package/dist/runtime/demo/main.js +4 -0
  31. package/dist/runtime/demo/sharedLayoutInstance.d.ts +0 -0
  32. package/dist/runtime/demo/sharedLayoutInstance.js +5 -0
  33. package/dist/runtime/demo/tailwind.css +1 -0
  34. package/dist/runtime/drag/CloseAction.d.ts +0 -0
  35. package/dist/runtime/drag/CloseAction.js +121 -0
  36. package/dist/runtime/drag/DragActionHandler.d.ts +0 -0
  37. package/dist/runtime/drag/DragActionHandler.js +83 -0
  38. package/dist/runtime/drag/DragDirectionStore.d.ts +0 -0
  39. package/dist/runtime/drag/DragDirectionStore.js +45 -0
  40. package/dist/runtime/drag/SplitAction.d.ts +0 -0
  41. package/dist/runtime/drag/SplitAction.js +110 -0
  42. package/dist/runtime/drag/types.d.ts +0 -0
  43. package/dist/runtime/drag/types.js +0 -0
  44. package/dist/runtime/helpers/addPointsToIntersection.d.ts +0 -0
  45. package/dist/runtime/helpers/addPointsToIntersection.js +7 -0
  46. package/dist/runtime/helpers/assertEdgeSorted.d.ts +0 -0
  47. package/dist/runtime/helpers/assertEdgeSorted.js +7 -0
  48. package/dist/runtime/helpers/assertItemIn.d.ts +0 -0
  49. package/dist/runtime/helpers/assertItemIn.js +8 -0
  50. package/dist/runtime/helpers/assertItemNotIn.d.ts +0 -0
  51. package/dist/runtime/helpers/assertItemNotIn.js +7 -0
  52. package/dist/runtime/helpers/assertLayoutHasActiveWindow.d.ts +0 -0
  53. package/dist/runtime/helpers/assertLayoutHasActiveWindow.js +7 -0
  54. package/dist/runtime/helpers/assertValidWinAndFrame.d.ts +0 -0
  55. package/dist/runtime/helpers/assertValidWinAndFrame.js +5 -0
  56. package/dist/runtime/helpers/assertValidWinAndFrameIds.d.ts +0 -0
  57. package/dist/runtime/helpers/assertValidWinAndFrameIds.js +6 -0
  58. package/dist/runtime/helpers/assertWindowHasActiveFrame.d.ts +0 -0
  59. package/dist/runtime/helpers/assertWindowHasActiveFrame.js +7 -0
  60. package/dist/runtime/helpers/clampNumber.d.ts +0 -0
  61. package/dist/runtime/helpers/clampNumber.js +3 -0
  62. package/dist/runtime/helpers/cloneFrame.d.ts +0 -0
  63. package/dist/runtime/helpers/cloneFrame.js +3 -0
  64. package/dist/runtime/helpers/cloneFrames.d.ts +0 -0
  65. package/dist/runtime/helpers/cloneFrames.js +16 -0
  66. package/dist/runtime/helpers/containsEdge.d.ts +0 -0
  67. package/dist/runtime/helpers/containsEdge.js +13 -0
  68. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.d.ts +0 -0
  69. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.js +10 -0
  70. package/dist/runtime/helpers/copySize.d.ts +0 -0
  71. package/dist/runtime/helpers/copySize.js +5 -0
  72. package/dist/runtime/helpers/createEdge.d.ts +0 -0
  73. package/dist/runtime/helpers/createEdge.js +13 -0
  74. package/dist/runtime/helpers/dirToOrientation.d.ts +0 -0
  75. package/dist/runtime/helpers/dirToOrientation.js +10 -0
  76. package/dist/runtime/helpers/dirToSide.d.ts +0 -0
  77. package/dist/runtime/helpers/dirToSide.js +5 -0
  78. package/dist/runtime/helpers/doEdgesOverlap.d.ts +0 -0
  79. package/dist/runtime/helpers/doEdgesOverlap.js +22 -0
  80. package/dist/runtime/helpers/doesEdgeContinueEdge.d.ts +0 -0
  81. package/dist/runtime/helpers/doesEdgeContinueEdge.js +17 -0
  82. package/dist/runtime/helpers/edgeToPoints.d.ts +0 -0
  83. package/dist/runtime/helpers/edgeToPoints.js +3 -0
  84. package/dist/runtime/helpers/findDraggableEdge.d.ts +0 -0
  85. package/dist/runtime/helpers/findDraggableEdge.js +13 -0
  86. package/dist/runtime/helpers/findFrameDraggableEdges.d.ts +0 -0
  87. package/dist/runtime/helpers/findFrameDraggableEdges.js +18 -0
  88. package/dist/runtime/helpers/frameToEdges.d.ts +0 -0
  89. package/dist/runtime/helpers/frameToEdges.js +21 -0
  90. package/dist/runtime/helpers/frameToPoints.d.ts +0 -0
  91. package/dist/runtime/helpers/frameToPoints.js +7 -0
  92. package/dist/runtime/helpers/getEdgeOrientation.d.ts +0 -0
  93. package/dist/runtime/helpers/getEdgeOrientation.js +4 -0
  94. package/dist/runtime/helpers/getEdgeSharedDirection.d.ts +0 -0
  95. package/dist/runtime/helpers/getEdgeSharedDirection.js +7 -0
  96. package/dist/runtime/helpers/getEdgeSide.d.ts +0 -0
  97. package/dist/runtime/helpers/getEdgeSide.js +16 -0
  98. package/dist/runtime/helpers/getFrameById.d.ts +0 -0
  99. package/dist/runtime/helpers/getFrameById.js +5 -0
  100. package/dist/runtime/helpers/getFrameConstant.d.ts +0 -0
  101. package/dist/runtime/helpers/getFrameConstant.js +15 -0
  102. package/dist/runtime/helpers/getIntersections.d.ts +0 -0
  103. package/dist/runtime/helpers/getIntersections.js +63 -0
  104. package/dist/runtime/helpers/getIntersectionsCss.d.ts +0 -0
  105. package/dist/runtime/helpers/getIntersectionsCss.js +56 -0
  106. package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +0 -0
  107. package/dist/runtime/helpers/getMoveEdgeInfo.js +42 -0
  108. package/dist/runtime/helpers/getResizeLimit.d.ts +0 -0
  109. package/dist/runtime/helpers/getResizeLimit.js +39 -0
  110. package/dist/runtime/helpers/getShapeSquareCss.d.ts +0 -0
  111. package/dist/runtime/helpers/getShapeSquareCss.js +17 -0
  112. package/dist/runtime/helpers/getSideTouching.d.ts +0 -0
  113. package/dist/runtime/helpers/getSideTouching.js +7 -0
  114. package/dist/runtime/helpers/getVisualEdgeCss.d.ts +0 -0
  115. package/dist/runtime/helpers/getVisualEdgeCss.js +40 -0
  116. package/dist/runtime/helpers/getVisualEdges.d.ts +0 -0
  117. package/dist/runtime/helpers/getVisualEdges.js +89 -0
  118. package/dist/runtime/helpers/getVisualEdgesCss.d.ts +0 -0
  119. package/dist/runtime/helpers/getVisualEdgesCss.js +4 -0
  120. package/dist/runtime/helpers/getWinAndFrameById.d.ts +0 -0
  121. package/dist/runtime/helpers/getWinAndFrameById.js +14 -0
  122. package/dist/runtime/helpers/getWinByFrameUuid.d.ts +0 -0
  123. package/dist/runtime/helpers/getWinByFrameUuid.js +13 -0
  124. package/dist/runtime/helpers/getWinById.d.ts +0 -0
  125. package/dist/runtime/helpers/getWinById.js +5 -0
  126. package/dist/runtime/helpers/getWindowConstant.d.ts +0 -0
  127. package/dist/runtime/helpers/getWindowConstant.js +14 -0
  128. package/dist/runtime/helpers/inRange.d.ts +0 -0
  129. package/dist/runtime/helpers/inRange.js +3 -0
  130. package/dist/runtime/helpers/index.d.ts +0 -0
  131. package/dist/runtime/helpers/index.js +62 -0
  132. package/dist/runtime/helpers/isEdgeEqual.d.ts +0 -0
  133. package/dist/runtime/helpers/isEdgeEqual.js +11 -0
  134. package/dist/runtime/helpers/isEdgeParallel.d.ts +0 -0
  135. package/dist/runtime/helpers/isEdgeParallel.js +7 -0
  136. package/dist/runtime/helpers/isPointEqual.d.ts +0 -0
  137. package/dist/runtime/helpers/isPointEqual.js +3 -0
  138. package/dist/runtime/helpers/isSizeAboveMin.d.ts +0 -0
  139. package/dist/runtime/helpers/isSizeAboveMin.js +3 -0
  140. package/dist/runtime/helpers/isSizeEqual.d.ts +0 -0
  141. package/dist/runtime/helpers/isSizeEqual.js +3 -0
  142. package/dist/runtime/helpers/isWindowEdge.d.ts +0 -0
  143. package/dist/runtime/helpers/isWindowEdge.js +7 -0
  144. package/dist/runtime/helpers/isWindowEdgePoint.d.ts +0 -0
  145. package/dist/runtime/helpers/isWindowEdgePoint.js +5 -0
  146. package/dist/runtime/helpers/moveEdge.d.ts +0 -0
  147. package/dist/runtime/helpers/moveEdge.js +8 -0
  148. package/dist/runtime/helpers/numberToScaledPercent.d.ts +0 -0
  149. package/dist/runtime/helpers/numberToScaledPercent.js +5 -0
  150. package/dist/runtime/helpers/numberToScaledSize.d.ts +0 -0
  151. package/dist/runtime/helpers/numberToScaledSize.js +19 -0
  152. package/dist/runtime/helpers/oppositeSide.d.ts +0 -0
  153. package/dist/runtime/helpers/oppositeSide.js +30 -0
  154. package/dist/runtime/helpers/resizeByEdge.d.ts +0 -0
  155. package/dist/runtime/helpers/resizeByEdge.js +29 -0
  156. package/dist/runtime/helpers/sideToDirection.d.ts +0 -0
  157. package/dist/runtime/helpers/sideToDirection.js +11 -0
  158. package/dist/runtime/helpers/sideToOrientation.d.ts +0 -0
  159. package/dist/runtime/helpers/sideToOrientation.js +10 -0
  160. package/dist/runtime/helpers/splitEdge.d.ts +0 -0
  161. package/dist/runtime/helpers/splitEdge.js +20 -0
  162. package/dist/runtime/helpers/toCoord.d.ts +0 -0
  163. package/dist/runtime/helpers/toCoord.js +10 -0
  164. package/dist/runtime/helpers/toId.d.ts +0 -0
  165. package/dist/runtime/helpers/toId.js +4 -0
  166. package/dist/runtime/helpers/toWindowCoord.d.ts +0 -0
  167. package/dist/runtime/helpers/toWindowCoord.js +14 -0
  168. package/dist/runtime/helpers/unionEdges.d.ts +0 -0
  169. package/dist/runtime/helpers/unionEdges.js +8 -0
  170. package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +0 -0
  171. package/dist/runtime/helpers/updateWindowSizeWithEvent.js +8 -0
  172. package/dist/runtime/index.d.ts +0 -0
  173. package/dist/runtime/index.js +5 -0
  174. package/dist/runtime/layout/closeFrame.d.ts +0 -0
  175. package/dist/runtime/layout/closeFrame.js +13 -0
  176. package/dist/runtime/layout/closeFrames.d.ts +0 -0
  177. package/dist/runtime/layout/closeFrames.js +8 -0
  178. package/dist/runtime/layout/createSplitDecoEdge.d.ts +0 -0
  179. package/dist/runtime/layout/createSplitDecoEdge.js +24 -0
  180. package/dist/runtime/layout/createSplitDecoFromDrag.d.ts +0 -0
  181. package/dist/runtime/layout/createSplitDecoFromDrag.js +14 -0
  182. package/dist/runtime/layout/debugFrame.d.ts +0 -0
  183. package/dist/runtime/layout/debugFrame.js +4 -0
  184. package/dist/runtime/layout/findFramesTouchingEdge.d.ts +0 -0
  185. package/dist/runtime/layout/findFramesTouchingEdge.js +33 -0
  186. package/dist/runtime/layout/findSafeSplitEdge.d.ts +0 -0
  187. package/dist/runtime/layout/findSafeSplitEdge.js +20 -0
  188. package/dist/runtime/layout/findVisualEdge.d.ts +0 -0
  189. package/dist/runtime/layout/findVisualEdge.js +9 -0
  190. package/dist/runtime/layout/frameCreate.d.ts +0 -0
  191. package/dist/runtime/layout/frameCreate.js +13 -0
  192. package/dist/runtime/layout/frameSplit.d.ts +0 -0
  193. package/dist/runtime/layout/frameSplit.js +9 -0
  194. package/dist/runtime/layout/getCloseFrameInfo.d.ts +0 -0
  195. package/dist/runtime/layout/getCloseFrameInfo.js +103 -0
  196. package/dist/runtime/layout/getFrameSplitInfo.d.ts +0 -0
  197. package/dist/runtime/layout/getFrameSplitInfo.js +40 -0
  198. package/dist/runtime/layout/getFrameTo.d.ts +0 -0
  199. package/dist/runtime/layout/getFrameTo.js +47 -0
  200. package/dist/runtime/layout/index.d.ts +0 -0
  201. package/dist/runtime/layout/index.js +22 -0
  202. package/dist/runtime/layout/isPointInFrame.d.ts +0 -0
  203. package/dist/runtime/layout/isPointInFrame.js +4 -0
  204. package/dist/runtime/layout/layoutAddWindow.d.ts +0 -0
  205. package/dist/runtime/layout/layoutAddWindow.js +4 -0
  206. package/dist/runtime/layout/layoutCreate.d.ts +0 -0
  207. package/dist/runtime/layout/layoutCreate.js +7 -0
  208. package/dist/runtime/layout/layoutRemoveWindow.d.ts +0 -0
  209. package/dist/runtime/layout/layoutRemoveWindow.js +5 -0
  210. package/dist/runtime/layout/resizeFrame.d.ts +0 -0
  211. package/dist/runtime/layout/resizeFrame.js +69 -0
  212. package/dist/runtime/layout/windowAddFrame.d.ts +0 -0
  213. package/dist/runtime/layout/windowAddFrame.js +4 -0
  214. package/dist/runtime/layout/windowCreate.d.ts +0 -0
  215. package/dist/runtime/layout/windowCreate.js +13 -0
  216. package/dist/runtime/layout/windowRemoveFrame.d.ts +0 -0
  217. package/dist/runtime/layout/windowRemoveFrame.js +5 -0
  218. package/dist/runtime/layout/windowSetActiveFrame.d.ts +0 -0
  219. package/dist/runtime/layout/windowSetActiveFrame.js +5 -0
  220. package/dist/runtime/settings.d.ts +0 -0
  221. package/dist/runtime/settings.js +54 -0
  222. package/dist/runtime/types/index.d.ts +0 -0
  223. package/dist/runtime/types/index.js +120 -0
  224. package/dist/runtime/utils/KnownError.d.ts +0 -0
  225. package/dist/runtime/utils/KnownError.js +9 -0
  226. package/dist/types.d.mts +5 -0
  227. package/package.json +153 -0
  228. package/src/module.ts +43 -0
  229. package/src/runtime/components/LayoutDecos.vue +62 -0
  230. package/src/runtime/components/LayoutEdges.vue +172 -0
  231. package/src/runtime/components/LayoutFrame.vue +47 -0
  232. package/src/runtime/components/LayoutShapeSquare.vue +38 -0
  233. package/src/runtime/components/LayoutWindow.vue +223 -0
  234. package/src/runtime/composables/useFrames.ts +251 -0
  235. package/src/runtime/demo/App.vue +140 -0
  236. package/src/runtime/demo/DemoControls.vue +17 -0
  237. package/src/runtime/demo/README.md +1 -0
  238. package/src/runtime/demo/main.ts +9 -0
  239. package/src/runtime/demo/sharedLayoutInstance.ts +7 -0
  240. package/src/runtime/demo/tailwind.css +4 -0
  241. package/src/runtime/drag/CloseAction.ts +158 -0
  242. package/src/runtime/drag/DragActionHandler.ts +146 -0
  243. package/src/runtime/drag/DragDirectionStore.ts +63 -0
  244. package/src/runtime/drag/SplitAction.ts +147 -0
  245. package/src/runtime/drag/types.ts +107 -0
  246. package/src/runtime/helpers/addPointsToIntersection.ts +9 -0
  247. package/src/runtime/helpers/assertEdgeSorted.ts +11 -0
  248. package/src/runtime/helpers/assertItemIn.ts +13 -0
  249. package/src/runtime/helpers/assertItemNotIn.ts +10 -0
  250. package/src/runtime/helpers/assertLayoutHasActiveWindow.ts +9 -0
  251. package/src/runtime/helpers/assertValidWinAndFrame.ts +16 -0
  252. package/src/runtime/helpers/assertValidWinAndFrameIds.ts +9 -0
  253. package/src/runtime/helpers/assertWindowHasActiveFrame.ts +9 -0
  254. package/src/runtime/helpers/clampNumber.ts +9 -0
  255. package/src/runtime/helpers/cloneFrame.ts +5 -0
  256. package/src/runtime/helpers/cloneFrames.ts +20 -0
  257. package/src/runtime/helpers/containsEdge.ts +16 -0
  258. package/src/runtime/helpers/convertLayoutWindowToWorkspace.ts +18 -0
  259. package/src/runtime/helpers/copySize.ts +7 -0
  260. package/src/runtime/helpers/createEdge.ts +19 -0
  261. package/src/runtime/helpers/dirToOrientation.ts +12 -0
  262. package/src/runtime/helpers/dirToSide.ts +7 -0
  263. package/src/runtime/helpers/doEdgesOverlap.ts +25 -0
  264. package/src/runtime/helpers/doesEdgeContinueEdge.ts +20 -0
  265. package/src/runtime/helpers/edgeToPoints.ts +5 -0
  266. package/src/runtime/helpers/findDraggableEdge.ts +24 -0
  267. package/src/runtime/helpers/findFrameDraggableEdges.ts +32 -0
  268. package/src/runtime/helpers/frameToEdges.ts +32 -0
  269. package/src/runtime/helpers/frameToPoints.ts +14 -0
  270. package/src/runtime/helpers/getEdgeOrientation.ts +6 -0
  271. package/src/runtime/helpers/getEdgeSharedDirection.ts +10 -0
  272. package/src/runtime/helpers/getEdgeSide.ts +27 -0
  273. package/src/runtime/helpers/getFrameById.ts +15 -0
  274. package/src/runtime/helpers/getFrameConstant.ts +22 -0
  275. package/src/runtime/helpers/getIntersections.ts +87 -0
  276. package/src/runtime/helpers/getIntersectionsCss.ts +65 -0
  277. package/src/runtime/helpers/getMoveEdgeInfo.ts +69 -0
  278. package/src/runtime/helpers/getResizeLimit.ts +60 -0
  279. package/src/runtime/helpers/getShapeSquareCss.ts +28 -0
  280. package/src/runtime/helpers/getSideTouching.ts +9 -0
  281. package/src/runtime/helpers/getVisualEdgeCss.ts +53 -0
  282. package/src/runtime/helpers/getVisualEdges.ts +155 -0
  283. package/src/runtime/helpers/getVisualEdgesCss.ts +13 -0
  284. package/src/runtime/helpers/getWinAndFrameById.ts +28 -0
  285. package/src/runtime/helpers/getWinByFrameUuid.ts +19 -0
  286. package/src/runtime/helpers/getWinById.ts +12 -0
  287. package/src/runtime/helpers/getWindowConstant.ts +21 -0
  288. package/src/runtime/helpers/inRange.ts +5 -0
  289. package/src/runtime/helpers/index.ts +64 -0
  290. package/src/runtime/helpers/isEdgeEqual.ts +14 -0
  291. package/src/runtime/helpers/isEdgeParallel.ts +10 -0
  292. package/src/runtime/helpers/isPointEqual.ts +5 -0
  293. package/src/runtime/helpers/isSizeAboveMin.ts +8 -0
  294. package/src/runtime/helpers/isSizeEqual.ts +5 -0
  295. package/src/runtime/helpers/isWindowEdge.ts +11 -0
  296. package/src/runtime/helpers/isWindowEdgePoint.ts +8 -0
  297. package/src/runtime/helpers/moveEdge.ts +21 -0
  298. package/src/runtime/helpers/numberToScaledPercent.ts +19 -0
  299. package/src/runtime/helpers/numberToScaledSize.ts +28 -0
  300. package/src/runtime/helpers/oppositeSide.ts +45 -0
  301. package/src/runtime/helpers/resizeByEdge.ts +45 -0
  302. package/src/runtime/helpers/sideToDirection.ts +15 -0
  303. package/src/runtime/helpers/sideToOrientation.ts +12 -0
  304. package/src/runtime/helpers/splitEdge.ts +23 -0
  305. package/src/runtime/helpers/toCoord.ts +13 -0
  306. package/src/runtime/helpers/toId.ts +9 -0
  307. package/src/runtime/helpers/toWindowCoord.ts +23 -0
  308. package/src/runtime/helpers/unionEdges.ts +11 -0
  309. package/src/runtime/helpers/updateWindowSizeWithEvent.ts +10 -0
  310. package/src/runtime/index.ts +5 -0
  311. package/src/runtime/layout/closeFrame.ts +33 -0
  312. package/src/runtime/layout/closeFrames.ts +14 -0
  313. package/src/runtime/layout/createSplitDecoEdge.ts +34 -0
  314. package/src/runtime/layout/createSplitDecoFromDrag.ts +24 -0
  315. package/src/runtime/layout/debugFrame.ts +6 -0
  316. package/src/runtime/layout/findFramesTouchingEdge.ts +92 -0
  317. package/src/runtime/layout/findSafeSplitEdge.ts +39 -0
  318. package/src/runtime/layout/findVisualEdge.ts +11 -0
  319. package/src/runtime/layout/frameCreate.ts +23 -0
  320. package/src/runtime/layout/frameSplit.ts +31 -0
  321. package/src/runtime/layout/getCloseFrameInfo.ts +193 -0
  322. package/src/runtime/layout/getFrameSplitInfo.ts +65 -0
  323. package/src/runtime/layout/getFrameTo.ts +65 -0
  324. package/src/runtime/layout/index.ts +24 -0
  325. package/src/runtime/layout/isPointInFrame.ts +7 -0
  326. package/src/runtime/layout/layoutAddWindow.ts +6 -0
  327. package/src/runtime/layout/layoutCreate.ts +12 -0
  328. package/src/runtime/layout/layoutRemoveWindow.ts +7 -0
  329. package/src/runtime/layout/resizeFrame.ts +106 -0
  330. package/src/runtime/layout/windowAddFrame.ts +10 -0
  331. package/src/runtime/layout/windowCreate.ts +18 -0
  332. package/src/runtime/layout/windowRemoveFrame.ts +7 -0
  333. package/src/runtime/layout/windowSetActiveFrame.ts +7 -0
  334. package/src/runtime/settings.ts +63 -0
  335. package/src/runtime/types/index.ts +293 -0
  336. package/src/runtime/utils/KnownError.ts +24 -0
@@ -0,0 +1,120 @@
1
+ import { enumFromArray } from "@alanscodelog/utils/enumFromArray";
2
+ import { z } from "zod";
3
+ export * from "../drag/types.js";
4
+ import { getMaxInt } from "../settings.js";
5
+ export const zUuid = z.uuid();
6
+ export const zWindowIdConstants = z.enum(["ACTIVE"]);
7
+ export const zWinId = z.uuid().or(zWindowIdConstants);
8
+ export const zFrameIdConstants = z.enum(["ACTIVE"]);
9
+ export const zFrameId = z.uuid().or(zFrameIdConstants);
10
+ export const zScaledIntPercentage = z.number().int().min(0).max(getMaxInt()).nonnegative();
11
+ const zPx = z.number().int().nonnegative();
12
+ export const zPos = z.object({
13
+ x: zScaledIntPercentage,
14
+ y: zScaledIntPercentage
15
+ });
16
+ export const zSize = z.object({
17
+ width: zScaledIntPercentage,
18
+ height: zScaledIntPercentage
19
+ });
20
+ export const zPoint = z.object({
21
+ x: zScaledIntPercentage,
22
+ y: zScaledIntPercentage
23
+ });
24
+ export const zPxPos = z.object({
25
+ pxX: zPx,
26
+ pxY: zPx
27
+ });
28
+ export const zPxSize = z.object({
29
+ pxWidth: zPx,
30
+ pxHeight: zPx
31
+ });
32
+ export const zEdge = z.object({
33
+ startX: zScaledIntPercentage,
34
+ startY: zScaledIntPercentage,
35
+ endX: zScaledIntPercentage,
36
+ endY: zScaledIntPercentage
37
+ });
38
+ export const zDirection = z.enum(["up", "down", "left", "right"]);
39
+ export const zExtendedDirection = z.union([zDirection, z.enum(["horizontal", "vertical"])]);
40
+ export const zSide = z.enum(["top", "bottom", "left", "right"]);
41
+ export const zOrientation = z.enum(["horizontal", "vertical"]);
42
+ export const zExtendedSide = z.union([zSide, zOrientation]);
43
+ export const zBaseSquare = zSize.extend(zPos.shape);
44
+ export const zLayoutFrame = z.looseObject({
45
+ id: z.uuid()
46
+ }).extend(zBaseSquare.shape);
47
+ export const zLayoutFramePassthrough = zLayoutFrame.passthrough();
48
+ const baseLayoutWindow = z.object({
49
+ id: z.uuid(),
50
+ activeFrame: z.string().optional(),
51
+ frames: z.record(z.string(), zLayoutFrame)
52
+ }).extend(zPxSize.shape).extend(zPxPos.shape);
53
+ export const zLayoutWindow = baseLayoutWindow.strict();
54
+ export const zLayoutWindowPassthrough = baseLayoutWindow;
55
+ const baseWorkspace = zLayoutWindow.pick({ activeFrame: true, frames: true });
56
+ export const zWorkspace = baseWorkspace.strict();
57
+ export const zWorkspacePassthrough = zWorkspace.passthrough();
58
+ const baseLayout = z.looseObject({
59
+ activeWindow: z.string().optional(),
60
+ windows: z.record(z.string(), zLayoutWindow)
61
+ });
62
+ export const zLayout = baseLayout.strict();
63
+ export const zInitializedLayout = zLayout.required({
64
+ activeWindow: true
65
+ }).refine((layout) => {
66
+ if (layout.windows[layout.activeWindow] === void 0) {
67
+ return false;
68
+ }
69
+ return zLayoutWindow.safeParse(layout.windows[layout.activeWindow]).success;
70
+ }, { message: "An initialized layout's active window must exist and be valid." });
71
+ export const zSplitDecoShapes = z.object({
72
+ edge: zEdge,
73
+ newFrame: zBaseSquare
74
+ }).strict();
75
+ export const zSplitDeco = z.object({
76
+ id: z.uuid(),
77
+ type: z.literal("split"),
78
+ position: zScaledIntPercentage,
79
+ direction: zDirection,
80
+ shapes: zSplitDecoShapes
81
+ }).strict();
82
+ export const zRawSplitDeco = zSplitDeco.omit({ shapes: true });
83
+ const zCloseDeco = z.object({
84
+ id: z.uuid(),
85
+ type: z.literal("close"),
86
+ force: z.boolean().optional()
87
+ }).strict();
88
+ const zDropDeco = z.object({
89
+ id: z.uuid(),
90
+ type: z.literal("drop"),
91
+ position: zSide.or(z.enum(["center"]))
92
+ }).strict();
93
+ export const zDeco = z.union([
94
+ zSplitDeco,
95
+ zCloseDeco,
96
+ zDropDeco
97
+ ]);
98
+ export const LAYOUT_ERROR = enumFromArray([
99
+ "INVALID_ID",
100
+ "ID_ALREADY_EXISTS",
101
+ "CANT_RESIZE",
102
+ "NO_ACTIVE_WINDOW",
103
+ "NO_ACTIVE_FRAME",
104
+ "CANT_CLOSE_NO_DRAG_EDGE",
105
+ "CANT_CLOSE_NEARBY_FRAMES_TOO_SMALL",
106
+ "CANT_CLOSE_SINGLE_FRAME",
107
+ "CANT_SPLIT_FRAME_TOO_SMALL",
108
+ "CANT_CLOSE_WITHOUT_FORCE"
109
+ ]);
110
+ export const zWindowCreate = zLayoutWindowPassthrough.partial({ id: true, pxWidth: true, pxHeight: true, pxX: true, pxY: true }).extend({ frames: zLayoutWindow.shape.frames.optional() });
111
+ export const zLayoutCreate = baseLayout.extend({
112
+ windows: zLayout.shape.windows.optional()
113
+ });
114
+ export const zFrameCreate = zLayoutFrame.partial({
115
+ id: true,
116
+ x: true,
117
+ y: true,
118
+ width: true,
119
+ height: true
120
+ });
File without changes
@@ -0,0 +1,9 @@
1
+ export class KnownError extends Error {
2
+ code;
3
+ info;
4
+ constructor(code, str, info) {
5
+ super(str);
6
+ this.code = code;
7
+ this.info = info;
8
+ }
9
+ }
@@ -0,0 +1,5 @@
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
4
+
5
+ export * from '../dist/runtime/index.js'
package/package.json ADDED
@@ -0,0 +1,153 @@
1
+ {
2
+ "name": "@witchcraft/layout",
3
+ "description": "Headless layout manager.",
4
+ "version": "1.0.0",
5
+ "main": "./dist/runtime/index.js",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/runtime/index.d.ts",
11
+ "import": "./dist/runtime/index.js"
12
+ },
13
+ "./components/*": {
14
+ "types": "./dist/runtime/components/*.vue.d.ts",
15
+ "import": "./dist/runtime/components/*.vue"
16
+ },
17
+ "./types": {
18
+ "types": "./dist/runtime/types/index.d.ts",
19
+ "import": "./dist/runtime/types/index.js"
20
+ },
21
+ "./*": {
22
+ "types": "./dist/runtime/*.d.ts",
23
+ "import": "./dist/runtime/*.js"
24
+ },
25
+ "./nuxt": {
26
+ "types": "./dist/types.d.mts",
27
+ "import": "./dist/module.mjs"
28
+ }
29
+ },
30
+ "scripts": {
31
+ "//prepare": "echo Needed so that if we pull the package from git it will get built and installed properly.",
32
+ "prepare": "husky && cd playground && pnpm i",
33
+ "build": "nuxt-module-build prepare && nuxt-module-build build && nuxi generate playground",
34
+ "build:only": "nuxt-module-build build",
35
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
36
+ "dev:playground": "nuxi dev playground",
37
+ "//dev:vite": "check everything is working when using vite",
38
+ "dev:vite": "vite --mode development --config vite.dev.config.ts",
39
+ "//dev": "The module needs to be build, not stubbed, for vite's dev to work.",
40
+ "dev": "pnpm dev:vite",
41
+ "lint:eslint": "eslint \"{src,tests,bin}/**/*.{cjs,js,ts}\" \"*.{cjs,js,ts}\" --max-warnings=3 --report-unused-disable-directives",
42
+ "lint:commits": "commitlint --from-last-tag --to HEAD --verbose",
43
+ "lint:imports": "echo disabled madge --circular --extensions ts ./src",
44
+ "lint": "pnpm lint:imports && pnpm lint:eslint && pnpm lint:types",
45
+ "lint:types": "vue-tsc --noEmit && cd playground",
46
+ "coverage": "vitest --coverage",
47
+ "coverage:dev": "vitest --watch --coverage",
48
+ "test": "echo no tests yet",
49
+ "test:watch": "vitest --watch",
50
+ "doc": "typedoc --options typedoc.config.js",
51
+ "doc:watch": "onchange -i \"src/**/*.ts\" \"typedoc.config.cjs\" -- pnpm doc",
52
+ "doc:serve": "http-server docs --port=5001",
53
+ "doc:dev": "concurrently \"pnpm doc:watch\" \"pnpm doc:serve\"",
54
+ "doc:check-invalid": "typedoc --options typedoc.config.cjs --listInvalidSymbolLinks",
55
+ "actions:debug": "act -r -v -j release",
56
+ "gen:exports": "indexit update --ignore **/*.d.ts **.vue src/assets/** -o '${path}.js'"
57
+ },
58
+ "dependencies": {
59
+ "@alanscodelog/utils": "^6.0.1",
60
+ "@iconify/json": "^2.2.383",
61
+ "es-toolkit": "^1.39.10"
62
+ },
63
+ "peerDependencies": {
64
+ "@witchcraft/nuxt-utils": "^0.2.1",
65
+ "@witchcraft/ui": "^0.2.1"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@witchcraft/ui": {
69
+ "optional": true
70
+ },
71
+ "@witchcraft/nuxt-utils": {
72
+ "optional": true
73
+ }
74
+ },
75
+ "devDependencies": {
76
+ "@alanscodelog/commitlint-config": "^3.1.2",
77
+ "@alanscodelog/eslint-config": "^6.3.0",
78
+ "@alanscodelog/semantic-release-config": "^5.0.4",
79
+ "@alanscodelog/tsconfigs": "^6.1.0",
80
+ "@alanscodelog/vite-config": "^0.0.6",
81
+ "@commitlint/cli": "^19.8.1",
82
+ "@nuxt/eslint-config": "^1.9.0",
83
+ "@nuxt/kit": "^4.1.2",
84
+ "@nuxt/module-builder": "^1.0.2",
85
+ "@nuxt/schema": "^4.1.2",
86
+ "@nuxt/types": "^2.18.1",
87
+ "@tailwindcss/vite": "^4.1.12",
88
+ "@types/node": "^24.3.3",
89
+ "@vitejs/plugin-vue": "^6.0.1",
90
+ "@vitest/coverage-c8": "^0.33.0",
91
+ "@witchcraft/nuxt-utils": "^0.3.2",
92
+ "@witchcraft/ui": "^0.2.1",
93
+ "concurrently": "^9.2.1",
94
+ "cross-env": "^10.0.0",
95
+ "fast-glob": "^3.3.3",
96
+ "http-server": "^14.1.1",
97
+ "husky": "^9.1.7",
98
+ "indexit": "2.1.0-beta.3",
99
+ "madge": "^8.0.0",
100
+ "nuxt": "^4.1.2",
101
+ "onchange": "^7.1.0",
102
+ "semantic-release": "^24.2.8",
103
+ "tailwindcss": "^4.1.12",
104
+ "typedoc": "0.28.12",
105
+ "typescript": "^5.8.3",
106
+ "unplugin-icons": "^22.3.0",
107
+ "unplugin-vue-components": "^29.0.0",
108
+ "uuid": "^13.0.0",
109
+ "vite": "^7.1.5",
110
+ "vitest": "^3.2.4",
111
+ "vue": "^3.5.20",
112
+ "vue-tsc": "^3.0.7",
113
+ "zod": "^4.1.8"
114
+ },
115
+ "author": "Alan <alanscodelog@gmail.com>",
116
+ "repository": "https://github.com/witchcraftjs/layout",
117
+ "license": "MIT",
118
+ "files": [
119
+ "src",
120
+ "dist"
121
+ ],
122
+ "release": {
123
+ "extends": [
124
+ "@alanscodelog/semantic-release-config"
125
+ ]
126
+ },
127
+ "commitlint": {
128
+ "extends": [
129
+ "@alanscodelog"
130
+ ]
131
+ },
132
+ "madge": {
133
+ "detectiveOptions": {
134
+ "ts": {
135
+ "skipTypeImports": true
136
+ }
137
+ }
138
+ },
139
+ "browserslist": "defaults and supports es6-module,maintained node versions",
140
+ "engines": {
141
+ "node": ">=20.0.0"
142
+ },
143
+ "@comments": {
144
+ "scripts": {
145
+ "test:inspect-errors": "For use with my inspect_error utility function from @alanscodelog/utils",
146
+ "prepare": "Needed so that if we pull the package from git it will get built and installed properly.",
147
+ "actions:debug": "For debugging github build action locally with nektos/act. Requires act and docker. Note: Cache will never work locally because of https://github.com/nektos/act/issues/285"
148
+ }
149
+ },
150
+ "publishConfig": {
151
+ "access": "public"
152
+ }
153
+ }
package/src/module.ts ADDED
@@ -0,0 +1,43 @@
1
+ import {
2
+ addComponentsDir,
3
+ addTemplate,
4
+ createResolver,
5
+ defineNuxtModule
6
+ } from "@nuxt/kit"
7
+
8
+ export * from "./runtime/index.js"
9
+
10
+ declare module "@nuxt/schema" {
11
+ interface PublicRuntimeConfig {
12
+ }
13
+ }
14
+
15
+ export interface ModuleOptions {
16
+ debug?: boolean
17
+ }
18
+
19
+ export default defineNuxtModule<ModuleOptions>({
20
+ meta: {
21
+ name: "@witchcraft/layout",
22
+ configKey: "witchcraftLayout"
23
+ },
24
+ defaults: {
25
+ debug: false
26
+ },
27
+ async setup(_options, nuxt) {
28
+ const { resolve } = createResolver(import.meta.url)
29
+ // const logger = useLogger(moduleName, { level: options.debug ? 10 : 0 })
30
+
31
+ addComponentsDir({
32
+ path: resolve("runtime/components")
33
+ })
34
+
35
+ addTemplate({
36
+ filename: "witchcraft-layout.css",
37
+ write: true,
38
+ getContents: () => `@source "${resolve("runtime/components")}";`
39
+ })
40
+
41
+ nuxt.options.alias["#witchcraft-layout"] = resolve("runtime")
42
+ }
43
+ })
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <!-- <div -->
3
+ <!-- v-bind="$attrs" -->
4
+ <!-- class="decos" -->
5
+ <!-- > -->
6
+ <template
7
+ v-for="(deco) of splitDecos"
8
+ :key="deco.id"
9
+ >
10
+ <LayoutShapeSquare
11
+ class="
12
+ deco-split-new-frame
13
+ bg-blue-500/50
14
+ "
15
+ :css="getShapeSquareCss( deco.shapes.newFrame, `var(--layoutEdgeWidth,2px)`)"
16
+ />
17
+ <LayoutShapeSquare
18
+ class="
19
+ deco-split-edge
20
+ bg-red-500
21
+ "
22
+ :css="getVisualEdgeCss(deco.shapes.edge, {padLongAxis:`var(--layoutEdgeWidth,2px)`})"
23
+ />
24
+ </template>
25
+ <template
26
+ v-for="deco of closeDecos"
27
+ :key="deco.id"
28
+ >
29
+ <LayoutShapeSquare
30
+ :class="`
31
+ ${deco.force ? 'deco-close-force-frame' : 'deco-close-frame'}
32
+ bg-red-500/50
33
+ `"
34
+ :css="getShapeSquareCss( frames[deco.id], `var(--layoutEdgeWidth,2px)`)"
35
+ />
36
+ </template>
37
+ <!-- </div> -->
38
+ </template>
39
+ <script lang="ts" setup>
40
+ import { twMerge } from "@witchcraft/ui/utils/twMerge"
41
+ import type { PropType } from "vue"
42
+ import { computed, inject, ref, useAttrs } from "vue"
43
+
44
+ import LayoutShapeSquare from "./LayoutShapeSquare.vue"
45
+
46
+ import { dirToOrientation } from "../helpers/dirToOrientation.js"
47
+ import { getShapeSquareCss } from "../helpers/getShapeSquareCss"
48
+ import { getVisualEdgeCss } from "../helpers/getVisualEdgeCss"
49
+ import { type CloseDeco, type LayoutFrames, type Size, type SplitDeco } from "../types/index.js"
50
+
51
+ const $attrs = useAttrs()
52
+
53
+ const props = withDefaults(defineProps<{
54
+ frames: LayoutFrames
55
+ splitDecos: SplitDeco[]
56
+ closeDecos: CloseDeco[]
57
+ } >(),{
58
+ })
59
+
60
+
61
+ </script>
62
+
@@ -0,0 +1,172 @@
1
+ <template>
2
+ <LayoutShapeSquare
3
+ v-if="activeFrame"
4
+ :css="getShapeSquareCss(activeFrame, `var(--layoutEdgeWidth,2px)`)"
5
+ :class="twMerge(`
6
+ active-frame-edge
7
+ pointer-events-none
8
+ z-0
9
+ border-blue-500
10
+ border
11
+ `,
12
+ )"
13
+ />
14
+
15
+ <template
16
+ v-for="css, i of cssDragEdges"
17
+ :key="i"
18
+ >
19
+ <LayoutShapeSquare
20
+ :css="css.thick"
21
+ :class="twMerge(`
22
+ drag-edge
23
+ z-20
24
+ hover:cursor-pointer
25
+ [&:hover+.edge]:bg-blue-500/50
26
+ `)"
27
+ @pointerdown="emit('dragStart', $event, {edge:edges[i]})"
28
+ />
29
+ <LayoutShapeSquare
30
+ :css="css.thin"
31
+ :class="twMerge(`
32
+ pointer-events-none
33
+ edge
34
+ `)"
35
+ />
36
+ </template>
37
+ <LayoutShapeSquare
38
+ :css="css"
39
+ :class="twMerge(`
40
+ grabbed-edge
41
+ z-20
42
+ bg-blue-500/50
43
+ cursor-pointer
44
+ `)"
45
+ v-for="css, i of cssDragEdge"
46
+ :key="i"
47
+ />
48
+ <template v-for="css, i of cssDragIntersections" :key="i">
49
+ <LayoutShapeSquare
50
+ :css="css.thick"
51
+ :class="twMerge(`
52
+ drag-intersection
53
+ z-30
54
+ rounded-full
55
+ hover:cursor-pointer
56
+ [&:hover+.intersection]:bg-blue-500/50
57
+ `,
58
+ )"
59
+ @pointerdown="emit('dragStart', $event, { intersection:wantedIntersections[i]})"
60
+ />
61
+ <LayoutShapeSquare
62
+ :css="css.thin"
63
+ :class="twMerge(`
64
+ intersection
65
+ z-30
66
+ rounded-full
67
+ pointer-events-none
68
+ `,
69
+ css.thin._shifted && `w-[7px] h-[7px]`,
70
+ )"
71
+ />
72
+ </template>
73
+ </template>
74
+ <script lang="ts" setup>
75
+ import { twMerge } from "@witchcraft/ui/utils/twMerge"
76
+ import { computed,type PropType, ref,useAttrs } from "vue"
77
+
78
+ import LayoutShapeSquare from "./LayoutShapeSquare.vue"
79
+
80
+ import { frameToEdges } from "../helpers/frameToEdges.js"
81
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js"
82
+ import { getShapeSquareCss } from "../helpers/getShapeSquareCss.js"
83
+ import { getVisualEdgesCss } from "../helpers/getVisualEdgesCss.js"
84
+ import { isEdgeEqual } from "../helpers/isEdgeEqual.js"
85
+ import { toWindowCoord } from "../helpers/toWindowCoord.js"
86
+ import {
87
+ type Edge,
88
+ type EdgeCss,
89
+ type IntersectionEntry,
90
+ type LayoutFrame,
91
+ type LayoutWindow,
92
+ type Point,
93
+ } from "../types/index.js"
94
+ const $attrs = useAttrs()
95
+
96
+ const emit = defineEmits<{
97
+ dragStart: [e: PointerEvent, { edge?: Edge, intersection?: IntersectionEntry }]
98
+ }>()
99
+ const props = withDefaults(defineProps< {
100
+ edges: Edge[]
101
+ intersections: IntersectionEntry[]
102
+ /** The owning window, needed so we can correctly scale coordinates. */
103
+ win: LayoutWindow
104
+ /** The active frame, used to render the active edges. Calculate it from the `frames` returned by `useFrames` composable because otherwise it will be the wrong size while dragging. */
105
+ activeFrame?: LayoutFrame
106
+ draggingEdge?: Edge
107
+ draggingIntersection?: IntersectionEntry
108
+ }>(), {
109
+ activeFrame: undefined,
110
+ draggingEdge: undefined,
111
+ draggingIntersection: undefined,
112
+ })
113
+
114
+
115
+ const activeFrameCssEdges = computed(() => {
116
+ if (!props.activeFrame) return []
117
+ return getVisualEdgesCss(Object.values(frameToEdges(props.activeFrame)), {
118
+ edgeWidth: `var(--layoutEdgeWidth, 2px)`,
119
+ })
120
+ })
121
+
122
+ const cssDragEdges = computed(() => {
123
+ const thickEdges = getVisualEdgesCss(
124
+ props.draggingEdge
125
+ ? props.edges.filter(_ => !isEdgeEqual(props.draggingEdge!, _))
126
+ : props.edges,
127
+ {
128
+ edgeWidth: `var(--layoutHandleWidth, 8px)`,
129
+ padLongAxis: `var(--layoutEdgeWidth, 2px)`,
130
+ }
131
+ )
132
+ const thinEdges = getVisualEdgesCss(props.edges, {
133
+ edgeWidth: `var(--layoutEdgeWidth, 2px)`,
134
+ padLongAxis: `(var(--layoutEdgeWidth, 2px) + var(--layoutExtraDragEdgePadding, 0px))`,
135
+ })
136
+ const edges: { thin: EdgeCss, thick: EdgeCss }[] = []
137
+ for (let i = 0; i < thickEdges.length; i++) {
138
+ edges.push({ thin: thinEdges[i], thick: thickEdges[i] })
139
+ }
140
+ return edges
141
+ })
142
+
143
+ const cssDragEdge = computed(() => {
144
+ if (!props.draggingEdge) return []
145
+ return getVisualEdgesCss([props.draggingEdge], {
146
+ edgeWidth: `var(--layoutEdgeWidth, 2px)`,
147
+ padLongAxis: `(var(--layoutEdgeWidth, 2px) + var(--layoutExtraDragEdgePadding, 0px))`,
148
+ })
149
+ })
150
+
151
+
152
+ const wantedIntersections = computed(() => props.intersections
153
+ .filter(_ => !_.isWindowEdge && (_.count === 4 || (_.count === 1 && _.sharesEdge)))
154
+ )
155
+ const cssDragIntersections = computed(() => {
156
+ const intersections: {
157
+ thick: ReturnType<typeof getIntersectionsCss>[number]
158
+ thin: ReturnType<typeof getIntersectionsCss>[number]
159
+ }[] = []
160
+ const thick = getIntersectionsCss(wantedIntersections.value, {
161
+ intersectionWidth: `var(--layoutIntersectionWidth, 15px)`,
162
+ })
163
+ const thin = getIntersectionsCss(wantedIntersections.value, {
164
+ })
165
+ for (let i = 0; i < thick.length; i++) {
166
+ intersections.push({ thick: thick[i], thin: thin[i] })
167
+ }
168
+ return intersections
169
+ })
170
+
171
+ </script>
172
+
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <!-- @vue-expect-error just let it inherit extra attrs -->
3
+ <!-- overflow-hidden is just in case, if the frame's css is not properly set to h-full, overflow-auto, or the border/padding are too large, we can still get overflows -->
4
+ <LayoutShapeSquare
5
+ tabindex="0"
6
+ :css="getShapeSquareCss(frame)"
7
+ :class="twMerge(`
8
+ frame
9
+ p-[var(--layoutEdgeWidth,_2px)]
10
+ overflow-hidden
11
+ `,
12
+ $attrs.class
13
+ )"
14
+ v-bind="{...$attrs, class: undefined}"
15
+ @focus="emit('focus')"
16
+ >
17
+ <slot>
18
+ <div class="p-2 text-xs bg-neutral-500">
19
+ {{ debugFrame(frame) }}
20
+ </div>
21
+ <div>No slot found for `frame-{{ frame.id }}`. </div>
22
+ </slot>
23
+ </LayoutShapeSquare>
24
+ </template>
25
+ <script lang="ts" setup>
26
+ import { twMerge } from "@witchcraft/ui/utils/twMerge"
27
+ import { type PropType } from "vue"
28
+ import { useAttrs } from "vue"
29
+ const $attrs = useAttrs()
30
+
31
+ import LayoutShapeSquare from "./LayoutShapeSquare.vue"
32
+
33
+ import { getShapeSquareCss } from "../helpers/getShapeSquareCss"
34
+ import { debugFrame } from "../layout/debugFrame.js"
35
+ import { type LayoutFrame } from "../types/index.js"
36
+
37
+
38
+ const emit = defineEmits<{
39
+ /** Documentation #todo */
40
+ (e: "focus"): void
41
+ }>()
42
+
43
+ /* const props = */defineProps({
44
+ frame: { type: Object as PropType<LayoutFrame>, required: true },
45
+ isActiveFrame: { type: Boolean, required: true },
46
+ })
47
+ </script>
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <div
3
+ :style="`
4
+ --posX:${css.x};
5
+ --posY:${css.y};
6
+ --width:${css.width};
7
+ --height:${css.height};
8
+ ${css.translate ? `--translate:${css.translate}`: ``}
9
+ ` + style"
10
+ :class="twMerge(`
11
+ absolute
12
+ w-[var(--width)]
13
+ h-[var(--height)]
14
+ top-[var(--posY)]
15
+ left-[var(--posX)]
16
+ `,
17
+ css.translate && `[transform:var(--translate)]`,
18
+ $attrs.class as any
19
+ )"
20
+ v-bind="{...$attrs, class: undefined}"
21
+ >
22
+ <slot/>
23
+ </div>
24
+ </template>
25
+ <script setup lang="ts">
26
+ import { twMerge } from "@witchcraft/ui/utils/twMerge"
27
+ import { type PropType } from "vue"
28
+ import { useAttrs } from "vue"
29
+
30
+ import type { BaseSquareCss } from "../types/index.js"
31
+ const $attrs = useAttrs()
32
+
33
+
34
+ const props = defineProps({
35
+ style: { type: String, required: false, default: "" },
36
+ css: { type: Object as PropType<BaseSquareCss>, required: true },
37
+ })
38
+ </script>