@witchcraft/layout 0.3.1 → 0.4.1

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 (169) hide show
  1. package/README.md +62 -70
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +6 -1
  4. package/dist/runtime/components/FrameDragHandle.vue +1 -1
  5. package/dist/runtime/components/LayoutDecosEdges.d.vue.ts +15 -0
  6. package/dist/runtime/components/LayoutDecosEdges.vue +34 -0
  7. package/dist/runtime/components/LayoutDecosEdges.vue.d.ts +15 -0
  8. package/dist/runtime/components/LayoutDecosRects.d.vue.ts +15 -0
  9. package/dist/runtime/components/LayoutDecosRects.vue +37 -0
  10. package/dist/runtime/components/LayoutDecosRects.vue.d.ts +15 -0
  11. package/dist/runtime/components/LayoutDragEdgeGrabbed.d.vue.ts +2 -0
  12. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue +43 -0
  13. package/dist/runtime/components/LayoutDragEdgeGrabbed.vue.d.ts +2 -0
  14. package/dist/runtime/components/LayoutDragEdgeHandle.d.vue.ts +9 -0
  15. package/dist/runtime/components/LayoutDragEdgeHandle.vue +44 -0
  16. package/dist/runtime/components/LayoutDragEdgeHandle.vue.d.ts +9 -0
  17. package/dist/runtime/components/{LayoutDecos.d.vue.ts → LayoutDragEdgeVisible.d.vue.ts} +3 -2
  18. package/dist/runtime/components/LayoutDragEdgeVisible.vue +38 -0
  19. package/dist/runtime/components/{LayoutDecos.vue.d.ts → LayoutDragEdgeVisible.vue.d.ts} +3 -2
  20. package/dist/runtime/components/LayoutDragEdges.d.vue.ts +21 -0
  21. package/dist/runtime/components/LayoutDragEdges.vue +67 -0
  22. package/dist/runtime/components/LayoutDragEdges.vue.d.ts +21 -0
  23. package/dist/runtime/components/LayoutEdgesActiveFrame.d.vue.ts +2 -0
  24. package/dist/runtime/components/LayoutEdgesActiveFrame.vue +35 -0
  25. package/dist/runtime/components/LayoutEdgesActiveFrame.vue.d.ts +2 -0
  26. package/dist/runtime/components/LayoutFrame.d.vue.ts +7 -6
  27. package/dist/runtime/components/LayoutFrame.vue +18 -14
  28. package/dist/runtime/components/LayoutFrame.vue.d.ts +7 -6
  29. package/dist/runtime/components/LayoutIntersectionHandle.d.vue.ts +10 -0
  30. package/dist/runtime/components/LayoutIntersectionHandle.vue +36 -0
  31. package/dist/runtime/components/LayoutIntersectionHandle.vue.d.ts +10 -0
  32. package/dist/runtime/components/LayoutIntersectionVisible.d.vue.ts +6 -0
  33. package/dist/runtime/components/LayoutIntersectionVisible.vue +34 -0
  34. package/dist/runtime/components/LayoutIntersectionVisible.vue.d.ts +6 -0
  35. package/dist/runtime/components/LayoutIntersections.d.vue.ts +21 -0
  36. package/dist/runtime/components/LayoutIntersections.vue +52 -0
  37. package/dist/runtime/components/LayoutIntersections.vue.d.ts +21 -0
  38. package/dist/runtime/components/{LayoutShapeSquare.d.vue.ts → LayoutShapeRect.d.vue.ts} +2 -2
  39. package/dist/runtime/components/{LayoutShapeSquare.vue.d.ts → LayoutShapeRect.vue.d.ts} +2 -2
  40. package/dist/runtime/components/LayoutWindow.d.vue.ts +252 -14
  41. package/dist/runtime/components/LayoutWindow.vue +27 -48
  42. package/dist/runtime/components/LayoutWindow.vue.d.ts +252 -14
  43. package/dist/runtime/composables/useFrames.d.ts +859 -2
  44. package/dist/runtime/composables/useFrames.js +2 -0
  45. package/dist/runtime/demo/App.vue +122 -74
  46. package/dist/runtime/demo/DemoControls.vue +7 -5
  47. package/dist/runtime/demo/index.html +12 -0
  48. package/dist/runtime/demo/tailwind.css +1 -1
  49. package/dist/runtime/drag/CloseAction.d.ts +1 -2
  50. package/dist/runtime/drag/CloseAction.js +1 -1
  51. package/dist/runtime/drag/DragActionHandler.d.ts +5 -3
  52. package/dist/runtime/drag/DragActionHandler.js +40 -6
  53. package/dist/runtime/drag/FrameDragAction.js +6 -7
  54. package/dist/runtime/drag/SplitAction.d.ts +1 -2
  55. package/dist/runtime/drag/SplitAction.js +1 -1
  56. package/dist/runtime/drag/createDefaultHandlers.d.ts +1 -1
  57. package/dist/runtime/drag/defaultDragActions.d.ts +1 -1
  58. package/dist/runtime/helpers/consoleDebugWindow.d.ts +43 -0
  59. package/dist/runtime/helpers/consoleDebugWindow.js +222 -0
  60. package/dist/runtime/helpers/convertLayoutWindowToWorkspace.js +2 -2
  61. package/dist/runtime/helpers/framesRedistributeFix.d.ts +87 -0
  62. package/dist/runtime/helpers/framesRedistributeFix.js +54 -0
  63. package/dist/runtime/helpers/getMoveEdgeInfo.d.ts +6 -2
  64. package/dist/runtime/helpers/getMoveEdgeInfo.js +11 -2
  65. package/dist/runtime/helpers/getPinnedEdgesForCollapsedFrames.d.ts +5 -0
  66. package/dist/runtime/helpers/getPinnedEdgesForCollapsedFrames.js +18 -0
  67. package/dist/runtime/helpers/getShapeRectCss.d.ts +7 -0
  68. package/dist/runtime/helpers/{getShapeSquareCss.js → getShapeRectCss.js} +1 -1
  69. package/dist/runtime/helpers/index.d.ts +3 -3
  70. package/dist/runtime/helpers/index.js +3 -3
  71. package/dist/runtime/helpers/moveEdge.js +3 -1
  72. package/dist/runtime/helpers/pxSizeToScaledSize.d.ts +2 -0
  73. package/dist/runtime/helpers/{numberToScaledSize.js → pxSizeToScaledSize.js} +1 -1
  74. package/dist/runtime/helpers/updateWindowSizeWithEvent.d.ts +3 -0
  75. package/dist/runtime/helpers/validateLayoutShape.d.ts +5 -0
  76. package/dist/runtime/helpers/validateLayoutShape.js +28 -0
  77. package/dist/runtime/layout/applyFrameChanges.js +6 -0
  78. package/dist/runtime/layout/createSplitDecoShapes.js +1 -1
  79. package/dist/runtime/layout/getFrameCollapseInfo.d.ts +5 -2
  80. package/dist/runtime/layout/getFrameCollapseInfo.js +16 -46
  81. package/dist/runtime/layout/getFrameDockInfo.d.ts +1 -1
  82. package/dist/runtime/layout/getFrameDockInfo.js +5 -1
  83. package/dist/runtime/layout/getFrameUncollapseInfo.d.ts +5 -2
  84. package/dist/runtime/layout/getFrameUncollapseInfo.js +16 -50
  85. package/dist/runtime/layout/getFrameUndockInfo.js +4 -1
  86. package/dist/runtime/layout/getFramesRedistributeInfo.d.ts +20 -4
  87. package/dist/runtime/layout/getFramesRedistributeInfo.js +31 -2
  88. package/dist/runtime/layout/getRelaxFramesInfo.d.ts +7 -0
  89. package/dist/runtime/layout/getRelaxFramesInfo.js +91 -0
  90. package/dist/runtime/layout/getUpdateWindowSizeInfo.d.ts +13 -0
  91. package/dist/runtime/layout/getUpdateWindowSizeInfo.js +65 -0
  92. package/dist/runtime/layout/index.d.ts +1 -0
  93. package/dist/runtime/layout/index.js +1 -0
  94. package/dist/runtime/layout/resizeFrame.js +1 -3
  95. package/dist/runtime/settings.d.ts +26 -19
  96. package/dist/runtime/settings.js +57 -22
  97. package/dist/runtime/types/index.d.ts +1243 -30
  98. package/dist/runtime/types/index.js +22 -8
  99. package/dist/runtime/types/vue.d.ts +41 -0
  100. package/dist/runtime/{drag/types.js → types/vue.js} +1 -0
  101. package/dist/runtime/utils/cssToKey.d.ts +5 -0
  102. package/dist/runtime/utils/cssToKey.js +3 -0
  103. package/package.json +11 -12
  104. package/src/module.ts +6 -1
  105. package/src/runtime/components/FrameDragHandle.vue +1 -1
  106. package/src/runtime/components/LayoutDecosEdges.vue +38 -0
  107. package/src/runtime/components/LayoutDecosRects.vue +42 -0
  108. package/src/runtime/components/LayoutDragEdgeGrabbed.vue +50 -0
  109. package/src/runtime/components/LayoutDragEdgeHandle.vue +52 -0
  110. package/src/runtime/components/LayoutDragEdgeVisible.vue +45 -0
  111. package/src/runtime/components/LayoutDragEdges.vue +78 -0
  112. package/src/runtime/components/LayoutEdgesActiveFrame.vue +43 -0
  113. package/src/runtime/components/LayoutFrame.vue +22 -15
  114. package/src/runtime/components/LayoutIntersectionHandle.vue +45 -0
  115. package/src/runtime/components/LayoutIntersectionVisible.vue +41 -0
  116. package/src/runtime/components/LayoutIntersections.vue +64 -0
  117. package/src/runtime/components/{LayoutShapeSquare.vue → LayoutShapeRect.vue} +2 -2
  118. package/src/runtime/components/LayoutWindow.vue +29 -49
  119. package/src/runtime/composables/useFrames.ts +7 -2
  120. package/src/runtime/demo/App.vue +128 -78
  121. package/src/runtime/demo/DemoControls.vue +7 -5
  122. package/src/runtime/demo/index.html +12 -0
  123. package/src/runtime/demo/tailwind.css +3 -0
  124. package/src/runtime/drag/CloseAction.ts +2 -3
  125. package/src/runtime/drag/DragActionHandler.ts +48 -10
  126. package/src/runtime/drag/FrameDragAction.ts +4 -5
  127. package/src/runtime/drag/SplitAction.ts +4 -3
  128. package/src/runtime/drag/createDefaultHandlers.ts +2 -1
  129. package/src/runtime/drag/defaultDragActions.ts +2 -1
  130. package/src/runtime/helpers/consoleDebugWindow.ts +331 -0
  131. package/src/runtime/helpers/convertLayoutWindowToWorkspace.ts +2 -2
  132. package/src/runtime/helpers/framesRedistributeFix.ts +162 -0
  133. package/src/runtime/helpers/getMoveEdgeInfo.ts +22 -5
  134. package/src/runtime/helpers/getPinnedEdgesForCollapsedFrames.ts +29 -0
  135. package/src/runtime/helpers/{getShapeSquareCss.ts → getShapeRectCss.ts} +3 -3
  136. package/src/runtime/helpers/index.ts +4 -3
  137. package/src/runtime/helpers/moveEdge.ts +3 -1
  138. package/src/runtime/helpers/{numberToScaledSize.ts → pxSizeToScaledSize.ts} +2 -2
  139. package/src/runtime/helpers/updateWindowSizeWithEvent.ts +3 -0
  140. package/src/runtime/helpers/validateLayoutShape.ts +46 -0
  141. package/src/runtime/layout/applyFrameChanges.ts +5 -0
  142. package/src/runtime/layout/createSplitDecoShapes.ts +1 -1
  143. package/src/runtime/layout/getFrameCollapseInfo.ts +26 -85
  144. package/src/runtime/layout/getFrameDockInfo.ts +8 -1
  145. package/src/runtime/layout/getFrameUncollapseInfo.ts +29 -96
  146. package/src/runtime/layout/getFrameUndockInfo.ts +7 -1
  147. package/src/runtime/layout/getFramesRedistributeInfo.ts +60 -5
  148. package/src/runtime/layout/getRelaxFramesInfo.ts +139 -0
  149. package/src/runtime/layout/getUpdateWindowSizeInfo.ts +105 -0
  150. package/src/runtime/layout/index.ts +1 -0
  151. package/src/runtime/layout/resizeFrame.ts +4 -3
  152. package/src/runtime/settings.ts +78 -25
  153. package/src/runtime/types/index.ts +205 -33
  154. package/src/runtime/types/vue.ts +41 -0
  155. package/src/runtime/utils/cssToKey.ts +8 -0
  156. package/dist/runtime/components/LayoutDecos.vue +0 -26
  157. package/dist/runtime/components/LayoutEdges.d.vue.ts +0 -17
  158. package/dist/runtime/components/LayoutEdges.vue +0 -144
  159. package/dist/runtime/components/LayoutEdges.vue.d.ts +0 -17
  160. package/dist/runtime/drag/types.d.ts +0 -161
  161. package/dist/runtime/helpers/clampNumber.d.ts +0 -1
  162. package/dist/runtime/helpers/clampNumber.js +0 -3
  163. package/dist/runtime/helpers/getShapeSquareCss.d.ts +0 -7
  164. package/dist/runtime/helpers/numberToScaledSize.d.ts +0 -2
  165. package/src/runtime/components/LayoutDecos.vue +0 -28
  166. package/src/runtime/components/LayoutEdges.vue +0 -170
  167. package/src/runtime/drag/types.ts +0 -177
  168. package/src/runtime/helpers/clampNumber.ts +0 -9
  169. /package/dist/runtime/components/{LayoutShapeSquare.vue → LayoutShapeRect.vue} +0 -0
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <LayoutShapeRect
3
+ v-if="activeFrame"
4
+ :class="twMerge(
5
+ `
6
+ active-frame-edge
7
+ pointer-events-none
8
+ z-0
9
+ border-blue-500
10
+ border
11
+ rounded-md
12
+ `,
13
+ $attrs.class
14
+ )"
15
+ v-bind="{ ...$attrs, class: void 0 }"
16
+ :css="getShapeRectCss(activeFrame, `var(--layoutEdgeWidth,2px)`)"
17
+ />
18
+ </template>
19
+
20
+ <script setup>
21
+ import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js";
22
+ import { computed, inject, useAttrs } from "vue";
23
+ import { twMerge } from "@witchcraft/ui/utils/twMerge";
24
+ import LayoutShapeRect from "./LayoutShapeRect.vue";
25
+ import { getShapeRectCss } from "../helpers/getShapeRectCss.js";
26
+ const $attrs = useAttrs();
27
+ defineOptions({
28
+ inheritAttrs: false
29
+ });
30
+ const ctx = inject(layoutContextInjectionKey, void 0);
31
+ if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow");
32
+ const dragCtx = inject(dragContextInjectionKey, void 0);
33
+ if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow");
34
+ const activeFrame = computed(() => ctx.value.win.activeFrame ? dragCtx.frames.value[ctx.value.win.activeFrame] : void 0);
35
+ </script>
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ export default _default;
@@ -1,13 +1,14 @@
1
- import type { LayoutFrameProps } from "../types/index.js";
2
- declare var __VLS_8: {};
1
+ declare var __VLS_9: any, __VLS_10: {
2
+ frame: any;
3
+ };
3
4
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_8) => any;
5
+ [K in NonNullable<typeof __VLS_9>]?: (props: typeof __VLS_10) => any;
5
6
  };
6
- declare const __VLS_component: import("vue").DefineComponent<LayoutFrameProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
8
  focus: () => any;
8
- }, string, import("vue").PublicProps, Readonly<LayoutFrameProps> & Readonly<{
9
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
9
10
  onFocus?: (() => any) | undefined;
10
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
12
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
12
13
  export default _default;
13
14
  type __VLS_WithSlots<T, S> = T & {
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <!-- 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 -->
3
- <LayoutShapeSquare
3
+ <LayoutShapeRect
4
4
  tabindex="0"
5
- :css="getShapeSquareCss(frame)"
5
+ :css="getShapeRectCss(frame)"
6
6
  :class="twMerge(
7
7
  `
8
8
  frame
@@ -12,31 +12,35 @@
12
12
  $attrs.class
13
13
  )"
14
14
  v-bind="{ ...$attrs, class: void 0 }"
15
- @focus="emit('focus')"
15
+ @focus="ctx.onFocus(frame.id);
16
+ emit('focus')"
17
+ v-for="frame in frames"
18
+ :key="frame.id"
16
19
  >
17
- <slot>
20
+ <slot :name="`frame-${frame.id}`" v-bind="{ frame }">
18
21
  <div class="p-2 text-xs bg-neutral-500">
19
22
  {{ debugFrame(frame) }}
20
23
  </div>
21
24
  <div>No slot found for `frame-{{ frame.id }}`. </div>
22
25
  </slot>
23
- </LayoutShapeSquare>
26
+ </LayoutShapeRect>
24
27
  </template>
25
28
 
26
29
  <script setup>
30
+ import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js";
27
31
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
28
- import { useAttrs } from "vue";
32
+ import { useAttrs, inject, toRef } from "vue";
29
33
  const $attrs = useAttrs();
34
+ import LayoutShapeRect from "./LayoutShapeRect.vue";
35
+ import { getShapeRectCss } from "../helpers/getShapeRectCss";
36
+ import { debugFrame } from "../layout/debugFrame.js";
30
37
  defineOptions({
31
38
  inheritAttrs: false
32
39
  });
33
- import LayoutShapeSquare from "./LayoutShapeSquare.vue";
34
- import { getShapeSquareCss } from "../helpers/getShapeSquareCss";
35
- import { debugFrame } from "../layout/debugFrame.js";
36
40
  const emit = defineEmits(["focus"]);
37
- defineProps({
38
- frame: { type: Object, required: true },
39
- isActiveFrame: { type: Boolean, required: true },
40
- css: { type: Object, required: false }
41
- });
41
+ const ctx = inject(layoutContextInjectionKey, void 0);
42
+ if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow");
43
+ const dragCtx = inject(dragContextInjectionKey, void 0);
44
+ if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow");
45
+ const frames = toRef(dragCtx, "frames");
42
46
  </script>
@@ -1,13 +1,14 @@
1
- import type { LayoutFrameProps } from "../types/index.js";
2
- declare var __VLS_8: {};
1
+ declare var __VLS_9: any, __VLS_10: {
2
+ frame: any;
3
+ };
3
4
  type __VLS_Slots = {} & {
4
- default?: (props: typeof __VLS_8) => any;
5
+ [K in NonNullable<typeof __VLS_9>]?: (props: typeof __VLS_10) => any;
5
6
  };
6
- declare const __VLS_component: import("vue").DefineComponent<LayoutFrameProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
8
  focus: () => any;
8
- }, string, import("vue").PublicProps, Readonly<LayoutFrameProps> & Readonly<{
9
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
9
10
  onFocus?: (() => any) | undefined;
10
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
12
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
12
13
  export default _default;
13
14
  type __VLS_WithSlots<T, S> = T & {
@@ -0,0 +1,10 @@
1
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
2
+ import { type EdgeDragStartData } from "../types/index.js";
3
+ import type { IntersectionEntry } from "../types/index.js";
4
+ type __VLS_Props = {
5
+ css: ReturnType<typeof getIntersectionsCss>[number];
6
+ intersection: IntersectionEntry;
7
+ onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeDragStartData) => void;
8
+ };
9
+ 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>;
10
+ export default _default;
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <LayoutShapeRect
3
+ :css="css"
4
+ :class="twMerge(`
5
+ drag-intersection
6
+ z-30
7
+ rounded-full
8
+ hover:cursor-pointer
9
+ `, $attrs.class)"
10
+ v-bind="{ ...$attrs, class: void 0 }"
11
+ @pointerdown="onPointerDown?.($event, 'edge', { intersection })"
12
+ />
13
+ </template>
14
+
15
+ <script setup>
16
+ import { layoutContextInjectionKey } from "../types/vue.js";
17
+ import { useAttrs, inject } from "vue";
18
+ import { twMerge } from "@witchcraft/ui/utils/twMerge";
19
+ import LayoutShapeRect from "./LayoutShapeRect.vue";
20
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
21
+ import {} from "../types/index.js";
22
+ import { dragContextInjectionKey } from "../types/vue.js";
23
+ const $attrs = useAttrs();
24
+ defineOptions({
25
+ inheritAttrs: false
26
+ });
27
+ const props = defineProps({
28
+ css: { type: null, required: true },
29
+ intersection: { type: Object, required: true },
30
+ onPointerDown: { type: Function, required: false }
31
+ });
32
+ const ctx = inject(layoutContextInjectionKey, void 0);
33
+ if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow");
34
+ const dragCtx = inject(dragContextInjectionKey, void 0);
35
+ if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow");
36
+ </script>
@@ -0,0 +1,10 @@
1
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
2
+ import { type EdgeDragStartData } from "../types/index.js";
3
+ import type { IntersectionEntry } from "../types/index.js";
4
+ type __VLS_Props = {
5
+ css: ReturnType<typeof getIntersectionsCss>[number];
6
+ intersection: IntersectionEntry;
7
+ onPointerDown?: (e: PointerEvent, type: "edge", data: EdgeDragStartData) => void;
8
+ };
9
+ 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>;
10
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
2
+ type __VLS_Props = {
3
+ css: ReturnType<typeof getIntersectionsCss>[number];
4
+ };
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>;
6
+ export default _default;
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <LayoutShapeRect
3
+ :css="css"
4
+ :class="twMerge(
5
+ `
6
+ drag-intersection-visible
7
+ z-30
8
+ rounded-full
9
+ pointer-events-none
10
+ [.drag-intersection:hover+&]:bg-blue-500/50
11
+ `,
12
+ css._shifted && `w-[7px] h-[7px]`,
13
+ $attrs.class
14
+ )"
15
+ v-bind="{ ...$attrs, class: void 0 }"
16
+ />
17
+ </template>
18
+
19
+ <script setup>
20
+ import { twMerge } from "@witchcraft/ui/utils/twMerge";
21
+ import { inject, useAttrs } from "vue";
22
+ import LayoutShapeRect from "./LayoutShapeRect.vue";
23
+ import { layoutContextInjectionKey } from "../types/vue.js";
24
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
25
+ const $attrs = useAttrs();
26
+ defineOptions({
27
+ inheritAttrs: false
28
+ });
29
+ defineProps({
30
+ css: { type: null, required: true }
31
+ });
32
+ const ctx = inject(layoutContextInjectionKey, void 0);
33
+ if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow");
34
+ </script>
@@ -0,0 +1,6 @@
1
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
2
+ type __VLS_Props = {
3
+ css: ReturnType<typeof getIntersectionsCss>[number];
4
+ };
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>;
6
+ export default _default;
@@ -0,0 +1,21 @@
1
+ declare var __VLS_1: {
2
+ css: any;
3
+ onPointerDown: any;
4
+ intersection: any;
5
+ }, __VLS_6: {
6
+ css: any;
7
+ intersection: any;
8
+ };
9
+ type __VLS_Slots = {} & {
10
+ handler?: (props: typeof __VLS_1) => any;
11
+ } & {
12
+ indicator?: (props: typeof __VLS_6) => any;
13
+ };
14
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
16
+ export default _default;
17
+ type __VLS_WithSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <template
3
+ v-for="css, i of cssDragIntersections"
4
+ :key="cssToKey(css.handle)"
5
+ >
6
+ <slot name="handler" v-bind="{
7
+ css: css.handle,
8
+ onPointerDown: dragCtx.dragStart,
9
+ intersection: draggableIntersections[i]
10
+ }">
11
+ <LayoutIntersectionHandle
12
+ :css="css.handle"
13
+ :intersection="draggableIntersections[i]"
14
+ />
15
+ </slot>
16
+ <slot name="indicator" v-bind="{ css: css.visible, intersection: draggableIntersections[i] }">
17
+ <LayoutIntersectionVisible
18
+ :css="css.visible"
19
+ />
20
+ </slot>
21
+ </template>
22
+ </template>
23
+
24
+ <script setup>
25
+ import { dragContextInjectionKey, layoutContextInjectionKey } from "../types/vue.js";
26
+ import { computed, inject } from "vue";
27
+ import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
28
+ import { cssToKey } from "../utils/cssToKey.js";
29
+ import LayoutIntersectionHandle from "./LayoutIntersectionHandle.vue";
30
+ import LayoutIntersectionVisible from "./LayoutIntersectionVisible.vue";
31
+ defineOptions({
32
+ inheritAttrs: false
33
+ });
34
+ const ctx = inject(layoutContextInjectionKey, void 0);
35
+ if (!ctx) throw new Error("LayoutEdges must be used within a LayoutWindow");
36
+ const dragCtx = inject(dragContextInjectionKey, void 0);
37
+ if (!dragCtx) throw new Error("LayoutEdges must be used within a LayoutWindow");
38
+ const draggableIntersections = computed(
39
+ () => dragCtx.intersections.value.filter((_) => !_.isWindowEdge && (_.count === 4 || _.count === 1 && _.sharesEdge))
40
+ );
41
+ const cssDragIntersections = computed(() => {
42
+ const intersections = [];
43
+ const thick = getIntersectionsCss(draggableIntersections.value, {
44
+ intersectionWidth: `var(--layoutIntersectionWidth, 15px)`
45
+ });
46
+ const thin = getIntersectionsCss(draggableIntersections.value, {});
47
+ for (let i = 0; i < thick.length; i++) {
48
+ intersections.push({ handle: thick[i], visible: thin[i] });
49
+ }
50
+ return intersections;
51
+ });
52
+ </script>
@@ -0,0 +1,21 @@
1
+ declare var __VLS_1: {
2
+ css: any;
3
+ onPointerDown: any;
4
+ intersection: any;
5
+ }, __VLS_6: {
6
+ css: any;
7
+ intersection: any;
8
+ };
9
+ type __VLS_Slots = {} & {
10
+ handler?: (props: typeof __VLS_1) => any;
11
+ } & {
12
+ indicator?: (props: typeof __VLS_6) => any;
13
+ };
14
+ declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
16
+ export default _default;
17
+ type __VLS_WithSlots<T, S> = T & {
18
+ new (): {
19
+ $slots: S;
20
+ };
21
+ };
@@ -1,6 +1,6 @@
1
1
  import type { HTMLAttributes } from "vue";
2
- import type { LayoutShapeSquareProps } from "../types/index.js";
3
- type __VLS_Props = LayoutShapeSquareProps & /** @vue-ignore */ HTMLAttributes;
2
+ import type { LayoutShapeRectProps } from "../types/index.js";
3
+ type __VLS_Props = LayoutShapeRectProps & /** @vue-ignore */ HTMLAttributes;
4
4
  declare var __VLS_1: {};
5
5
  type __VLS_Slots = {} & {
6
6
  default?: (props: typeof __VLS_1) => any;
@@ -1,6 +1,6 @@
1
1
  import type { HTMLAttributes } from "vue";
2
- import type { LayoutShapeSquareProps } from "../types/index.js";
3
- type __VLS_Props = LayoutShapeSquareProps & /** @vue-ignore */ HTMLAttributes;
2
+ import type { LayoutShapeRectProps } from "../types/index.js";
3
+ type __VLS_Props = LayoutShapeRectProps & /** @vue-ignore */ HTMLAttributes;
4
4
  declare var __VLS_1: {};
5
5
  type __VLS_Slots = {} & {
6
6
  default?: (props: typeof __VLS_1) => any;