@witchcraft/layout 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "configKey": "witchcraftLayout",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -1,8 +1,4 @@
1
1
  <template>
2
- <!-- <div -->
3
- <!-- v-bind="$attrs" -->
4
- <!-- class="decos" -->
5
- <!-- > -->
6
2
  <template
7
3
  v-for="(deco) of splitDecos"
8
4
  :key="deco.id"
@@ -34,18 +30,13 @@
34
30
  :css="getShapeSquareCss(frames[deco.id], `var(--layoutEdgeWidth,2px)`)"
35
31
  />
36
32
  </template>
37
- <!-- </div> -->
38
33
  </template>
39
34
 
40
35
  <script setup>
41
- import { twMerge } from "@witchcraft/ui/utils/twMerge";
42
- import { computed, inject, ref, useAttrs } from "vue";
43
36
  import LayoutShapeSquare from "./LayoutShapeSquare.vue";
44
- import { dirToOrientation } from "../helpers/dirToOrientation.js";
45
37
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss";
46
38
  import { getVisualEdgeCss } from "../helpers/getVisualEdgeCss";
47
39
  import {} from "../types/index.js";
48
- const $attrs = useAttrs();
49
40
  const props = defineProps({
50
41
  frames: { type: Object, required: true },
51
42
  splitDecos: { type: Array, required: true },
@@ -1,26 +1,16 @@
1
- import { type Edge, type IntersectionEntry, type LayoutFrame, type LayoutWindow } from "../types/index.js";
2
- type __VLS_Props = {
3
- edges: Edge[];
4
- intersections: IntersectionEntry[];
5
- /** The owning window, needed so we can correctly scale coordinates. */
6
- win: LayoutWindow;
7
- /** 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. */
8
- activeFrame?: LayoutFrame;
9
- draggingEdge?: Edge;
10
- draggingIntersection?: IntersectionEntry;
11
- };
12
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
1
+ import { type Edge, type IntersectionEntry, type LayoutEdgesProps } from "../types/index.js";
2
+ declare const _default: import("vue").DefineComponent<LayoutEdgesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
3
  dragStart: (e: PointerEvent, args_1: {
14
4
  edge?: Edge;
15
5
  intersection?: IntersectionEntry;
16
6
  }) => any;
17
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
7
+ }, string, import("vue").PublicProps, Readonly<LayoutEdgesProps> & Readonly<{
18
8
  onDragStart?: ((e: PointerEvent, args_1: {
19
9
  edge?: Edge;
20
10
  intersection?: IntersectionEntry;
21
11
  }) => any) | undefined;
22
12
  }>, {
23
- activeFrame: LayoutFrame;
13
+ activeFrame: import("../types/index.js").LayoutFrame;
24
14
  draggingEdge: Edge;
25
15
  draggingIntersection: IntersectionEntry;
26
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -9,8 +9,11 @@
9
9
  z-0
10
10
  border-blue-500
11
11
  border
12
- `
12
+ rounded-md
13
+ `,
14
+ $attrs.class
13
15
  )"
16
+ v-bind="{ ...$attrs, class: void 0 }"
14
17
  />
15
18
 
16
19
  <template
@@ -77,17 +80,18 @@
77
80
 
78
81
  <script setup>
79
82
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
80
- import { computed, ref, useAttrs } from "vue";
83
+ import { computed, useAttrs } from "vue";
81
84
  import LayoutShapeSquare from "./LayoutShapeSquare.vue";
82
- import { frameToEdges } from "../helpers/frameToEdges.js";
83
85
  import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js";
84
86
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss.js";
85
87
  import { getVisualEdgesCss } from "../helpers/getVisualEdgesCss.js";
86
88
  import { isEdgeEqual } from "../helpers/isEdgeEqual.js";
87
- import { toWindowCoord } from "../helpers/toWindowCoord.js";
88
89
  import {
89
90
  } from "../types/index.js";
90
91
  const $attrs = useAttrs();
92
+ defineOptions({
93
+ inheritAttrs: false
94
+ });
91
95
  const emit = defineEmits(["dragStart"]);
92
96
  const props = defineProps({
93
97
  edges: { type: Array, required: true },
@@ -95,13 +99,8 @@ const props = defineProps({
95
99
  win: { type: Object, required: true },
96
100
  activeFrame: { type: Object, required: false, default: void 0 },
97
101
  draggingEdge: { type: null, required: false, default: void 0 },
98
- draggingIntersection: { type: Object, required: false, default: void 0 }
99
- });
100
- const activeFrameCssEdges = computed(() => {
101
- if (!props.activeFrame) return [];
102
- return getVisualEdgesCss(Object.values(frameToEdges(props.activeFrame)), {
103
- edgeWidth: `var(--layoutEdgeWidth, 2px)`
104
- });
102
+ draggingIntersection: { type: Object, required: false, default: void 0 },
103
+ css: { type: Object, required: false }
105
104
  });
106
105
  const cssDragEdges = computed(() => {
107
106
  const thickEdges = getVisualEdgesCss(
@@ -1,26 +1,16 @@
1
- import { type Edge, type IntersectionEntry, type LayoutFrame, type LayoutWindow } from "../types/index.js";
2
- type __VLS_Props = {
3
- edges: Edge[];
4
- intersections: IntersectionEntry[];
5
- /** The owning window, needed so we can correctly scale coordinates. */
6
- win: LayoutWindow;
7
- /** 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. */
8
- activeFrame?: LayoutFrame;
9
- draggingEdge?: Edge;
10
- draggingIntersection?: IntersectionEntry;
11
- };
12
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
1
+ import { type Edge, type IntersectionEntry, type LayoutEdgesProps } from "../types/index.js";
2
+ declare const _default: import("vue").DefineComponent<LayoutEdgesProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
3
  dragStart: (e: PointerEvent, args_1: {
14
4
  edge?: Edge;
15
5
  intersection?: IntersectionEntry;
16
6
  }) => any;
17
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
7
+ }, string, import("vue").PublicProps, Readonly<LayoutEdgesProps> & Readonly<{
18
8
  onDragStart?: ((e: PointerEvent, args_1: {
19
9
  edge?: Edge;
20
10
  intersection?: IntersectionEntry;
21
11
  }) => any) | undefined;
22
12
  }>, {
23
- activeFrame: LayoutFrame;
13
+ activeFrame: import("../types/index.js").LayoutFrame;
24
14
  draggingEdge: Edge;
25
15
  draggingIntersection: IntersectionEntry;
26
16
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,32 +1,13 @@
1
- import { type PropType } from "vue";
2
- import { type LayoutFrame } from "../types/index.js";
1
+ import { type LayoutFrameProps } from "../types/index.js";
3
2
  declare var __VLS_8: {};
4
3
  type __VLS_Slots = {} & {
5
4
  default?: (props: typeof __VLS_8) => any;
6
5
  };
7
- declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
- frame: {
9
- type: PropType<LayoutFrame>;
10
- required: true;
11
- };
12
- isActiveFrame: {
13
- type: BooleanConstructor;
14
- required: true;
15
- };
16
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ declare const __VLS_component: import("vue").DefineComponent<LayoutFrameProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
7
  focus: () => any;
18
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
- frame: {
20
- type: PropType<LayoutFrame>;
21
- required: true;
22
- };
23
- isActiveFrame: {
24
- type: BooleanConstructor;
25
- required: true;
26
- };
27
- }>> & Readonly<{
8
+ }, string, import("vue").PublicProps, Readonly<LayoutFrameProps> & Readonly<{
28
9
  onFocus?: (() => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
11
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
31
12
  export default _default;
32
13
  type __VLS_WithSlots<T, S> = T & {
@@ -1,5 +1,4 @@
1
1
  <template>
2
- <!-- @vue-expect-error just let it inherit extra attrs -->
3
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 -->
4
3
  <LayoutShapeSquare
5
4
  tabindex="0"
@@ -26,9 +25,11 @@
26
25
 
27
26
  <script setup>
28
27
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
29
- import {} from "vue";
30
28
  import { useAttrs } from "vue";
31
29
  const $attrs = useAttrs();
30
+ defineOptions({
31
+ inheritAttrs: false
32
+ });
32
33
  import LayoutShapeSquare from "./LayoutShapeSquare.vue";
33
34
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss";
34
35
  import { debugFrame } from "../layout/debugFrame.js";
@@ -36,6 +37,7 @@ import {} from "../types/index.js";
36
37
  const emit = defineEmits(["focus"]);
37
38
  defineProps({
38
39
  frame: { type: Object, required: true },
39
- isActiveFrame: { type: Boolean, required: true }
40
+ isActiveFrame: { type: Boolean, required: true },
41
+ css: { type: Object, required: false }
40
42
  });
41
43
  </script>
@@ -1,32 +1,13 @@
1
- import { type PropType } from "vue";
2
- import { type LayoutFrame } from "../types/index.js";
1
+ import { type LayoutFrameProps } from "../types/index.js";
3
2
  declare var __VLS_8: {};
4
3
  type __VLS_Slots = {} & {
5
4
  default?: (props: typeof __VLS_8) => any;
6
5
  };
7
- declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
- frame: {
9
- type: PropType<LayoutFrame>;
10
- required: true;
11
- };
12
- isActiveFrame: {
13
- type: BooleanConstructor;
14
- required: true;
15
- };
16
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ declare const __VLS_component: import("vue").DefineComponent<LayoutFrameProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
7
  focus: () => any;
18
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
- frame: {
20
- type: PropType<LayoutFrame>;
21
- required: true;
22
- };
23
- isActiveFrame: {
24
- type: BooleanConstructor;
25
- required: true;
26
- };
27
- }>> & Readonly<{
8
+ }, string, import("vue").PublicProps, Readonly<LayoutFrameProps> & Readonly<{
28
9
  onFocus?: (() => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
11
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
31
12
  export default _default;
32
13
  type __VLS_WithSlots<T, S> = T & {
@@ -1,32 +1,9 @@
1
- import { type PropType } from "vue";
2
- import type { BaseSquareCss } from "../types/index.js";
1
+ import type { LayoutShapeSquareProps } from "../types/index.js";
3
2
  declare var __VLS_1: {};
4
3
  type __VLS_Slots = {} & {
5
4
  default?: (props: typeof __VLS_1) => any;
6
5
  };
7
- declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
- style: {
9
- type: StringConstructor;
10
- required: false;
11
- default: string;
12
- };
13
- css: {
14
- type: PropType<BaseSquareCss>;
15
- required: true;
16
- };
17
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
18
- style: {
19
- type: StringConstructor;
20
- required: false;
21
- default: string;
22
- };
23
- css: {
24
- type: PropType<BaseSquareCss>;
25
- required: true;
26
- };
27
- }>> & Readonly<{}>, {
28
- style: string;
29
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
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>;
30
7
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
31
8
  export default _default;
32
9
  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
@@ -26,11 +26,12 @@
26
26
 
27
27
  <script setup>
28
28
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
29
- import {} from "vue";
30
29
  import { useAttrs } from "vue";
31
30
  const $attrs = useAttrs();
31
+ defineOptions({
32
+ inheritAttrs: false
33
+ });
32
34
  const props = defineProps({
33
- style: { type: String, required: false, default: "" },
34
35
  css: { type: Object, required: true }
35
36
  });
36
37
  </script>
@@ -1,32 +1,9 @@
1
- import { type PropType } from "vue";
2
- import type { BaseSquareCss } from "../types/index.js";
1
+ import type { LayoutShapeSquareProps } from "../types/index.js";
3
2
  declare var __VLS_1: {};
4
3
  type __VLS_Slots = {} & {
5
4
  default?: (props: typeof __VLS_1) => any;
6
5
  };
7
- declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
- style: {
9
- type: StringConstructor;
10
- required: false;
11
- default: string;
12
- };
13
- css: {
14
- type: PropType<BaseSquareCss>;
15
- required: true;
16
- };
17
- }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
18
- style: {
19
- type: StringConstructor;
20
- required: false;
21
- default: string;
22
- };
23
- css: {
24
- type: PropType<BaseSquareCss>;
25
- required: true;
26
- };
27
- }>> & Readonly<{}>, {
28
- style: string;
29
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
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>;
30
7
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
31
8
  export default _default;
32
9
  type __VLS_WithSlots<T, S> = T & {
@@ -1,5 +1,5 @@
1
1
  import { type DragState, type IDragAction } from "../drag/types.js";
2
- import { type LayoutWindow } from "../types/index.js";
2
+ import { type LayoutEdgesProps, type LayoutFrameProps, type LayoutWindow } from "../types/index.js";
3
3
  type __VLS_Props = {
4
4
  additionalDragActions?: IDragAction[];
5
5
  splitKeyHandler?: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
@@ -14,6 +14,8 @@ type __VLS_Props = {
14
14
  * When this is turned back on again, it will trigger an update. You can also trigger updates manually with the exposed updateWindowSize function.
15
15
  */
16
16
  allowWindowSizeUpdate?: boolean;
17
+ frameProps?: Partial<Omit<LayoutFrameProps, "frame" | "isActiveFrame" | "onFocus">>;
18
+ edgesProps?: Partial<Omit<LayoutEdgesProps, "edges" | "intersections" | "win">>;
17
19
  };
18
20
  declare function updateWindowSize(): void;
19
21
  type __VLS_PublicProps = __VLS_Props & {
@@ -7,17 +7,17 @@
7
7
  `,
8
8
  isDragging && `dragging cursor-pointer`,
9
9
  requestType && `request-${requestType}`,
10
- $attrs.attrs.class
10
+ $attrs.class
11
11
  )"
12
12
  ref="windowEl"
13
- v-bind="{ ...$attrs.attrs, class: void 0 }"
13
+ v-bind="{ ...$attrs, class: void 0 }"
14
14
  >
15
15
  <template v-if="windowEl && win">
16
16
  <LayoutFrameComponent :frame="frame"
17
17
  :is-active-frame="frame.id === win.activeFrame"
18
18
  v-for="frame of frames"
19
19
  :key="frame.id"
20
- v-bind="$attrs.frameAttrs"
20
+ v-bind="frameProps"
21
21
  @focus="windowSetActiveFrame(win, frame.id)"
22
22
  >
23
23
  <slot :name="`frame-${frame.id}`" v-bind="{ frame }"/>
@@ -29,14 +29,13 @@
29
29
  :intersections="intersections"
30
30
  :dragging-edge="draggingEdges.length === 1 ? draggingEdges[0] : void 0"
31
31
  :dragging-intersection="draggingIntersection"
32
- v-bind="$attrs.edgesAttrs"
32
+ v-bind="edgesProps"
33
33
  @drag-start="dragStart"
34
34
  />
35
35
  <LayoutDecosComponent
36
36
  :frames="frames"
37
37
  :split-decos="splitDecos"
38
38
  :close-decos="closeDecos"
39
- v-bind="$attrs.decosAttrs"
40
39
  />
41
40
  <slot name="extra-decos"/>
42
41
  </template>
@@ -45,7 +44,6 @@
45
44
  <span
46
45
  class="
47
46
  after:content-['┃']
48
- after:text-accent-500
49
47
  last:after:content-none
50
48
  after:mx-1
51
49
  after:text-gray-500
@@ -61,10 +59,10 @@
61
59
  </template>
62
60
 
63
61
  <script setup>
64
- import { useDivideAttrs } from "@witchcraft/ui/composables/useDivideAttrs";
65
62
  import { useGlobalResizeObserver } from "@witchcraft/ui/composables/useGlobalResizeObserver";
66
63
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
67
- import { computed, ref, watch } from "vue";
64
+ import { computed, ref, useAttrs, watch } from "vue";
65
+ import {} from "vue";
68
66
  import LayoutDecosComponent from "./LayoutDecos.vue";
69
67
  import LayoutEdgesComponent from "./LayoutEdges.vue";
70
68
  import LayoutFrameComponent from "./LayoutFrame.vue";
@@ -76,7 +74,7 @@ import {} from "../drag/types.js";
76
74
  import { updateWindowWithEvent } from "../helpers/updateWindowSizeWithEvent.js";
77
75
  import { windowSetActiveFrame } from "../layout/windowSetActiveFrame.js";
78
76
  import {} from "../types/index.js";
79
- const $attrs = useDivideAttrs(["frame", "edges", "decos"]);
77
+ const $attrs = useAttrs();
80
78
  const win = defineModel("win", { type: Object, ...{ required: true } });
81
79
  const props = defineProps({
82
80
  additionalDragActions: { type: Array, required: false, default: () => [] },
@@ -84,7 +82,9 @@ const props = defineProps({
84
82
  closeKeyHandler: { type: Function, required: false, default: void 0 },
85
83
  usageInstructions: { type: Object, required: false, default: () => ({}) },
86
84
  instructionsTeleportTo: { type: null, required: true },
87
- allowWindowSizeUpdate: { type: Boolean, required: false, default: true }
85
+ allowWindowSizeUpdate: { type: Boolean, required: false, default: true },
86
+ frameProps: { type: Object, required: false },
87
+ edgesProps: { type: Object, required: false }
88
88
  });
89
89
  const emit = defineEmits(["isShowingDrag", "dragState"]);
90
90
  const filteredUsageInstructions = computed(() => Object.values(props.usageInstructions).filter((_) => _ !== void 0).map((_) => _));
@@ -1,5 +1,5 @@
1
1
  import { type DragState, type IDragAction } from "../drag/types.js";
2
- import { type LayoutWindow } from "../types/index.js";
2
+ import { type LayoutEdgesProps, type LayoutFrameProps, type LayoutWindow } from "../types/index.js";
3
3
  type __VLS_Props = {
4
4
  additionalDragActions?: IDragAction[];
5
5
  splitKeyHandler?: (e: PointerEvent | KeyboardEvent, state: DragState) => boolean;
@@ -14,6 +14,8 @@ type __VLS_Props = {
14
14
  * When this is turned back on again, it will trigger an update. You can also trigger updates manually with the exposed updateWindowSize function.
15
15
  */
16
16
  allowWindowSizeUpdate?: boolean;
17
+ frameProps?: Partial<Omit<LayoutFrameProps, "frame" | "isActiveFrame" | "onFocus">>;
18
+ edgesProps?: Partial<Omit<LayoutEdgesProps, "edges" | "intersections" | "win">>;
17
19
  };
18
20
  declare function updateWindowSize(): void;
19
21
  type __VLS_PublicProps = __VLS_Props & {
@@ -60,7 +60,7 @@
60
60
 
61
61
  <script setup>
62
62
  import { keys } from "@alanscodelog/utils/keys";
63
- import WRoot from "@witchcraft/ui/components/LibRoot";
63
+ import WRoot from "@witchcraft/ui/components/WRoot";
64
64
  import { twMerge } from "@witchcraft/ui/utils/twMerge";
65
65
  import { computed, onBeforeMount, ref } from "vue";
66
66
  import DemoControls from "./DemoControls.vue";
@@ -7,7 +7,7 @@
7
7
  </template>
8
8
 
9
9
  <script setup>
10
- import WDarkModeSwitcher from "@witchcraft/ui/components/LibDarkModeSwitcher";
10
+ import WDarkModeSwitcher from "@witchcraft/ui/components/WDarkModeSwitcher";
11
11
  defineProps({
12
12
  frames: { type: Array, required: true }
13
13
  });
@@ -1,6 +1,7 @@
1
1
  import type { EnumLike } from "@alanscodelog/utils";
2
2
  import { z } from "zod";
3
3
  export * from "../drag/types.js";
4
+ import type { HTMLAttributes } from "vue";
4
5
  export declare const zUuid: z.ZodUUID;
5
6
  export type AnyUuid = z.infer<typeof zUuid>;
6
7
  export declare const zWindowIdConstants: z.ZodEnum<{
@@ -456,3 +457,22 @@ export declare const zFrameCreate: z.ZodObject<{
456
457
  x: z.ZodOptional<z.ZodNumber>;
457
458
  y: z.ZodOptional<z.ZodNumber>;
458
459
  }, z.core.$loose>;
460
+ export type LayoutShapeSquareProps = {
461
+ css: BaseSquareCss;
462
+ } & /** @vue-ignore */ Omit<HTMLAttributes, "class" | "onFocus"> & /** @vue-ignore */ {
463
+ class?: string;
464
+ };
465
+ export type LayoutEdgesProps = {
466
+ edges: Edge[];
467
+ intersections: IntersectionEntry[];
468
+ /** The owning window, needed so we can correctly scale coordinates. */
469
+ win: LayoutWindow;
470
+ /** 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. */
471
+ activeFrame?: LayoutFrame;
472
+ draggingEdge?: Edge;
473
+ draggingIntersection?: IntersectionEntry;
474
+ } & Partial<LayoutShapeSquareProps>;
475
+ export type LayoutFrameProps = {
476
+ frame: LayoutFrame;
477
+ isActiveFrame: boolean;
478
+ } & Partial<LayoutShapeSquareProps>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@witchcraft/layout",
3
3
  "description": "Headless layout manager.",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "main": "./dist/runtime/index.js",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -28,13 +28,13 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@alanscodelog/utils": "^6.0.1",
31
+ "@alanscodelog/utils": "^6.2.0",
32
32
  "@iconify/json": "^2.2.383",
33
33
  "es-toolkit": "^1.39.10"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@witchcraft/nuxt-utils": "^0.3.6",
37
- "@witchcraft/ui": "^0.3.13"
37
+ "@witchcraft/ui": "^0.4.1"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@witchcraft/ui": {
@@ -47,8 +47,8 @@
47
47
  "devDependencies": {
48
48
  "@alanscodelog/commitlint-config": "^3.1.2",
49
49
  "@alanscodelog/eslint-config": "^6.3.0",
50
- "@alanscodelog/semantic-release-config": "^6.0.0",
51
- "@alanscodelog/tsconfigs": "^6.2.0",
50
+ "@alanscodelog/semantic-release-config": "^6.0.2",
51
+ "@alanscodelog/tsconfigs": "^6.3.0",
52
52
  "@alanscodelog/vite-config": "^0.0.6",
53
53
  "@commitlint/cli": "^19.8.1",
54
54
  "@nuxt/eslint-config": "^1.9.0",
@@ -61,7 +61,7 @@
61
61
  "@vitejs/plugin-vue": "^6.0.1",
62
62
  "@vitest/coverage-c8": "^0.33.0",
63
63
  "@witchcraft/nuxt-utils": "^0.3.6",
64
- "@witchcraft/ui": "^0.3.13",
64
+ "@witchcraft/ui": "^0.4.1",
65
65
  "concurrently": "^9.2.1",
66
66
  "cross-env": "^10.0.0",
67
67
  "fast-glob": "^3.3.3",
@@ -1,8 +1,4 @@
1
1
  <template>
2
- <!-- <div -->
3
- <!-- v-bind="$attrs" -->
4
- <!-- class="decos" -->
5
- <!-- > -->
6
2
  <template
7
3
  v-for="(deco) of splitDecos"
8
4
  :key="deco.id"
@@ -34,21 +30,15 @@
34
30
  :css="getShapeSquareCss( frames[deco.id], `var(--layoutEdgeWidth,2px)`)"
35
31
  />
36
32
  </template>
37
- <!-- </div> -->
38
33
  </template>
39
34
  <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
35
 
44
36
  import LayoutShapeSquare from "./LayoutShapeSquare.vue"
45
37
 
46
- import { dirToOrientation } from "../helpers/dirToOrientation.js"
47
38
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss"
48
39
  import { getVisualEdgeCss } from "../helpers/getVisualEdgeCss"
49
40
  import { type CloseDeco, type LayoutFrames, type Size, type SplitDeco } from "../types/index.js"
50
41
 
51
- const $attrs = useAttrs()
52
42
 
53
43
  const props = withDefaults(defineProps<{
54
44
  frames: LayoutFrames
@@ -8,8 +8,11 @@
8
8
  z-0
9
9
  border-blue-500
10
10
  border
11
+ rounded-md
11
12
  `,
13
+ ($attrs as any).class
12
14
  )"
15
+ v-bind="{...$attrs, class: undefined}"
13
16
  />
14
17
 
15
18
  <template
@@ -73,51 +76,42 @@
73
76
  </template>
74
77
  <script lang="ts" setup>
75
78
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
76
- import { computed,type PropType, ref,useAttrs } from "vue"
79
+ import { computed,useAttrs } from "vue"
77
80
 
78
81
  import LayoutShapeSquare from "./LayoutShapeSquare.vue"
79
82
 
80
- import { frameToEdges } from "../helpers/frameToEdges.js"
81
83
  import { getIntersectionsCss } from "../helpers/getIntersectionsCss.js"
82
84
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss.js"
83
85
  import { getVisualEdgesCss } from "../helpers/getVisualEdgesCss.js"
84
86
  import { isEdgeEqual } from "../helpers/isEdgeEqual.js"
85
- import { toWindowCoord } from "../helpers/toWindowCoord.js"
86
87
  import {
87
88
  type Edge,
88
89
  type EdgeCss,
89
90
  type IntersectionEntry,
90
- type LayoutFrame,
91
- type LayoutWindow,
92
- type Point,
91
+ type LayoutEdgesProps,
93
92
  } from "../types/index.js"
94
93
  const $attrs = useAttrs()
95
94
 
95
+ defineOptions({
96
+ inheritAttrs: false,
97
+ })
98
+
96
99
  const emit = defineEmits<{
97
100
  dragStart: [e: PointerEvent, { edge?: Edge, intersection?: IntersectionEntry }]
98
101
  }>()
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
- }>(), {
102
+ const props = withDefaults(defineProps<LayoutEdgesProps>(), {
109
103
  activeFrame: undefined,
110
104
  draggingEdge: undefined,
111
105
  draggingIntersection: undefined,
112
106
  })
113
107
 
114
108
 
115
- const activeFrameCssEdges = computed(() => {
116
- if (!props.activeFrame) return []
117
- return getVisualEdgesCss(Object.values(frameToEdges(props.activeFrame)), {
118
- edgeWidth: `var(--layoutEdgeWidth, 2px)`,
119
- })
120
- })
109
+ // const activeFrameCssEdges = computed(() => {
110
+ // if (!props.activeFrame) return []
111
+ // return getVisualEdgesCss(Object.values(frameToEdges(props.activeFrame)), {
112
+ // edgeWidth: `var(--layoutEdgeWidth, 2px)`,
113
+ // })
114
+ // })
121
115
 
122
116
  const cssDragEdges = computed(() => {
123
117
  const thickEdges = getVisualEdgesCss(
@@ -1,5 +1,4 @@
1
1
  <template>
2
- <!-- @vue-expect-error just let it inherit extra attrs -->
3
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 -->
4
3
  <LayoutShapeSquare
5
4
  tabindex="0"
@@ -9,7 +8,7 @@
9
8
  p-[var(--layoutEdgeWidth,_2px)]
10
9
  overflow-hidden
11
10
  `,
12
- $attrs.class
11
+ ($attrs as any).class
13
12
  )"
14
13
  v-bind="{...$attrs, class: undefined}"
15
14
  @focus="emit('focus')"
@@ -24,15 +23,18 @@
24
23
  </template>
25
24
  <script lang="ts" setup>
26
25
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
27
- import { type PropType } from "vue"
28
26
  import { useAttrs } from "vue"
29
27
  const $attrs = useAttrs()
30
28
 
29
+ defineOptions({
30
+ inheritAttrs: false,
31
+ })
32
+
31
33
  import LayoutShapeSquare from "./LayoutShapeSquare.vue"
32
34
 
33
35
  import { getShapeSquareCss } from "../helpers/getShapeSquareCss"
34
36
  import { debugFrame } from "../layout/debugFrame.js"
35
- import { type LayoutFrame } from "../types/index.js"
37
+ import { type LayoutFrameProps } from "../types/index.js"
36
38
 
37
39
 
38
40
  const emit = defineEmits<{
@@ -40,8 +42,6 @@ const emit = defineEmits<{
40
42
  (e: "focus"): void
41
43
  }>()
42
44
 
43
- /* const props = */defineProps({
44
- frame: { type: Object as PropType<LayoutFrame>, required: true },
45
- isActiveFrame: { type: Boolean, required: true },
46
- })
45
+ /* const props = */defineProps<LayoutFrameProps>(
46
+ )
47
47
  </script>
@@ -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
  absolute
12
12
  w-[var(--width)]
@@ -15,7 +15,7 @@
15
15
  left-[var(--posX)]
16
16
  `,
17
17
  css.translate && `[transform:var(--translate)]`,
18
- $attrs.class as any
18
+ ($attrs as any).class
19
19
  )"
20
20
  v-bind="{...$attrs, class: undefined}"
21
21
  >
@@ -24,15 +24,14 @@
24
24
  </template>
25
25
  <script setup lang="ts">
26
26
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
27
- import { type PropType } from "vue"
28
27
  import { useAttrs } from "vue"
29
28
 
30
- import type { BaseSquareCss } from "../types/index.js"
29
+ import type { LayoutShapeSquareProps } from "../types/index.js"
31
30
  const $attrs = useAttrs()
32
31
 
33
-
34
- const props = defineProps({
35
- style: { type: String, required: false, default: "" },
36
- css: { type: Object as PropType<BaseSquareCss>, required: true },
32
+ defineOptions({
33
+ inheritAttrs: false,
37
34
  })
35
+
36
+ const props = defineProps<LayoutShapeSquareProps>()
38
37
  </script>
@@ -7,17 +7,17 @@
7
7
  `,
8
8
  isDragging && `dragging cursor-pointer`,
9
9
  requestType && `request-${requestType}`,
10
- $attrs.attrs.class
10
+ ($attrs as any).class
11
11
  )"
12
12
  ref="windowEl"
13
- v-bind="{...$attrs.attrs, class: undefined}"
13
+ v-bind="{...$attrs, class: undefined}"
14
14
  >
15
15
  <template v-if="windowEl && win">
16
16
  <LayoutFrameComponent :frame="frame"
17
17
  :is-active-frame="frame.id === win.activeFrame"
18
18
  v-for="frame of frames"
19
19
  :key="frame.id"
20
- v-bind="$attrs.frameAttrs"
20
+ v-bind="frameProps"
21
21
  @focus="windowSetActiveFrame(win, frame.id)"
22
22
  >
23
23
  <slot :name="`frame-${frame.id}`" v-bind="{frame}"/>
@@ -29,14 +29,13 @@
29
29
  :intersections="intersections"
30
30
  :dragging-edge="draggingEdges.length === 1 ? draggingEdges[0] : undefined"
31
31
  :dragging-intersection="draggingIntersection"
32
- v-bind="$attrs.edgesAttrs"
32
+ v-bind="edgesProps"
33
33
  @drag-start="dragStart"
34
34
  />
35
35
  <LayoutDecosComponent
36
36
  :frames="frames"
37
37
  :split-decos="splitDecos"
38
38
  :close-decos="closeDecos"
39
- v-bind="$attrs.decosAttrs"
40
39
  />
41
40
  <slot name="extra-decos"/>
42
41
  </template>
@@ -45,7 +44,6 @@
45
44
  <span
46
45
  class="
47
46
  after:content-['┃']
48
- after:text-accent-500
49
47
  last:after:content-none
50
48
  after:mx-1
51
49
  after:text-gray-500
@@ -60,10 +58,10 @@
60
58
  </div>
61
59
  </template>
62
60
  <script lang="ts" setup>
63
- import { useDivideAttrs } from "@witchcraft/ui/composables/useDivideAttrs"
64
61
  import { useGlobalResizeObserver } from "@witchcraft/ui/composables/useGlobalResizeObserver"
65
62
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
66
- import { computed, ref,watch } from "vue"
63
+ import { computed, ref,useAttrs,watch } from "vue"
64
+ import { type HTMLAttributes } from "vue"
67
65
 
68
66
  import LayoutDecosComponent from "./LayoutDecos.vue"
69
67
  import LayoutEdgesComponent from "./LayoutEdges.vue"
@@ -76,10 +74,10 @@ import { SplitAction } from "../drag/SplitAction.js"
76
74
  import { type DragState, type IDragAction } from "../drag/types.js"
77
75
  import { updateWindowWithEvent } from "../helpers/updateWindowSizeWithEvent.js"
78
76
  import { windowSetActiveFrame } from "../layout/windowSetActiveFrame.js"
79
- import { type CloseDeco, type LayoutWindow, type SplitDeco } from "../types/index.js"
77
+ import { type CloseDeco, type LayoutEdgesProps, type LayoutFrameProps, type LayoutWindow, type SplitDeco } from "../types/index.js"
80
78
 
81
- const $attrs = useDivideAttrs(["frame", "edges", "decos"] as const)
82
79
 
80
+ const $attrs = useAttrs()
83
81
  const win = defineModel<LayoutWindow>("win", { required: true })
84
82
 
85
83
  const props = withDefaults(defineProps<{
@@ -96,13 +94,15 @@ const props = withDefaults(defineProps<{
96
94
  * When this is turned back on again, it will trigger an update. You can also trigger updates manually with the exposed updateWindowSize function.
97
95
  */
98
96
  allowWindowSizeUpdate?: boolean
97
+ frameProps?: Partial<Omit<LayoutFrameProps, "frame" | "isActiveFrame" | "onFocus">>,
98
+ edgesProps?: Partial<Omit<LayoutEdgesProps, "edges" | "intersections" | "win">>
99
99
  }>(), {
100
100
  additionalDragActions: () => ([]),
101
101
  splitKeyHandler: undefined,
102
102
  closeKeyHandler: undefined,
103
103
  usageInstructions: () => ({ }),
104
104
  instructionTeleportTo: undefined,
105
- allowWindowSizeUpdate: true
105
+ allowWindowSizeUpdate: true,
106
106
  })
107
107
  const emit = defineEmits<{
108
108
  (e: "isShowingDrag", value: boolean): void
@@ -60,7 +60,7 @@
60
60
  import { keys } from "@alanscodelog/utils/keys"
61
61
  // playground not resolving???
62
62
  // todo this breaks the non-playground build
63
- import WRoot from "@witchcraft/ui/components/LibRoot"
63
+ import WRoot from "@witchcraft/ui/components/WRoot"
64
64
  import { twMerge } from "@witchcraft/ui/utils/twMerge"
65
65
  import { computed, onBeforeMount, ref } from "vue"
66
66
 
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  </template>
8
8
  <script lang="ts" setup>
9
- import WDarkModeSwitcher from "@witchcraft/ui/components/LibDarkModeSwitcher"
9
+ import WDarkModeSwitcher from "@witchcraft/ui/components/WDarkModeSwitcher"
10
10
 
11
11
  import type { LayoutFrame } from "../types/index.js"
12
12
 
@@ -4,6 +4,8 @@ import { z } from "zod"
4
4
 
5
5
  export * from "../drag/types.js"
6
6
 
7
+ import type { HTMLAttributes } from "vue"
8
+
7
9
  import { getMaxInt } from "../settings.js"
8
10
 
9
11
  export const zUuid = z.uuid()
@@ -289,3 +291,33 @@ export const zFrameCreate = zLayoutFrame.partial({
289
291
  width: true,
290
292
  height: true
291
293
  })
294
+
295
+
296
+ export type LayoutShapeSquareProps
297
+ = & {
298
+ css: BaseSquareCss
299
+ }
300
+ & /** @vue-ignore */ Omit<HTMLAttributes, "class" | "onFocus">
301
+ & /** @vue-ignore */ { class?: string }
302
+
303
+
304
+ export type LayoutEdgesProps
305
+ = & {
306
+ edges: Edge[]
307
+ intersections: IntersectionEntry[]
308
+ /** The owning window, needed so we can correctly scale coordinates. */
309
+ win: LayoutWindow
310
+ /** 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. */
311
+ activeFrame?: LayoutFrame
312
+ draggingEdge?: Edge
313
+ draggingIntersection?: IntersectionEntry
314
+ }
315
+ & Partial<LayoutShapeSquareProps>
316
+
317
+
318
+ export type LayoutFrameProps
319
+ = & {
320
+ frame: LayoutFrame
321
+ isActiveFrame: boolean
322
+ }
323
+ & Partial<LayoutShapeSquareProps>