Skip to content

Commit 54f4bfa

Browse files
committed
Fix an incorrect type declaration for layer slots
1 parent 75a5cfe commit 54f4bfa

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/components/VNetworkGraph.vue

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { readonly, ref, toRef, useSlots, computed, nextTick, watch, CSSProperties } from "vue"
2+
import { readonly, ref, toRef, computed, nextTick, watch, CSSProperties } from "vue"
33
import { EventHandlers, Nodes, Edges, InputPaths, Layouts, UserLayouts } from "@/common/types"
44
import { Layers, LayerPosition, LayerPositions, Point, Sizes } from "@/common/types"
55
import { Reactive, nonNull } from "@/common/common"
@@ -20,7 +20,7 @@ import { SvgPanZoomInstance, Box } from "@/modules/svg-pan-zoom-ex"
2020
import { exportSvgElement, exportSvgElementWithOptions, ExportOptions } from "@/utils/svg"
2121
import { provideSelections } from "@/composables/selection"
2222
import { provideLayouts } from "@/composables/layout"
23-
import { LayerSlots, useBuiltInLayerOrder } from "@/composables/layer"
23+
import { LayerSlotProps, useBuiltInLayerOrder } from "@/composables/layer"
2424
import { asyncNextTick } from "@/modules/vue/nextTick"
2525
import { isPromise } from "@/utils/object"
2626
import { calculateFit, parseFitContentMargin } from "@/modules/view/fit"
@@ -63,10 +63,6 @@ interface Props {
6363
eventHandlers?: EventHandlers
6464
}
6565
66-
interface LayerSlot {
67-
scale: number
68-
}
69-
7066
const props = withDefaults(defineProps<Props>(), {
7167
nodes: () => ({}),
7268
edges: () => ({}),
@@ -89,7 +85,10 @@ const emit = defineEmits<{
8985
(e: "update:layouts", v: Layouts): void
9086
}>()
9187
92-
const slots = defineSlots<LayerSlots>()
88+
const slots = defineSlots<{
89+
default: (props: LayerSlotProps) => any
90+
[key: string]: (props: LayerSlotProps) => any
91+
}>()
9392
9493
const nodesRef = toRef(props, "nodes")
9594
const edgesRef = toRef(props, "edges")
@@ -705,12 +704,9 @@ function stopEventPropagation(event: Event) {
705704
height="100%"
706705
>
707706
<!-- outside of viewport -->
708-
<slot
709-
v-for="layerName in layerDefs['root']"
710-
:key="layerName"
711-
:name="layerName"
712-
:scale="scale"
713-
/>
707+
<template v-for="layerName in layerDefs['root']" :key="layerName">
708+
<slot :name="layerName" :scale="scale" />
709+
</template>
714710

715711
<defs v-if="Object.keys(markerState.markers).length > 0">
716712
<v-marker-head

src/composables/layer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { computed, ComputedRef, Slot, Slots } from "vue"
1+
import { computed, ComputedRef, Slot } from "vue"
22
import { uniq } from "lodash-es"
33
import { Configs } from "@/common/configs"
44
import { LayerName } from "@/common/types"
55
import { pairwise } from "@/modules/collection/iterate"
66
import { insertAfter, removeItem } from "@/modules/collection/array"
77

8-
export interface LayerSlotParameter {
9-
key?: string
8+
export interface LayerSlotProps {
109
scale: number
1110
}
12-
export type LayerSlots = Record<string, Slot<LayerSlotParameter>>
11+
export type LayerSlots = Record<string, Slot<LayerSlotProps>>
1312

1413
export function useBuiltInLayerOrder<T extends Configs>(
1514
configs: T,

0 commit comments

Comments
 (0)