chore: cleanup components
This commit is contained in:
@@ -5,7 +5,7 @@ import { zoom, zoomIdentity } from 'd3-zoom'
|
||||
import type { D3ZoomEvent } from 'd3-zoom'
|
||||
import { pointer, select } from 'd3-selection'
|
||||
import { computed, provide, ref, useAttrs, useSlots, watchEffect } from 'vue'
|
||||
import type { MiniMapNodeFunc, MiniMapProps, ShapeRendering } from './types'
|
||||
import type { MiniMapEmits, MiniMapNodeFunc, MiniMapProps, ShapeRendering } from './types'
|
||||
import MiniMapNode from './MiniMapNode'
|
||||
import { MiniMapSlots } from './types'
|
||||
|
||||
@@ -29,7 +29,7 @@ const {
|
||||
offsetScale = 5,
|
||||
} = defineProps<MiniMapProps>()
|
||||
|
||||
const emit = defineEmits(['click', 'nodeClick', 'nodeDblclick', 'nodeMouseenter', 'nodeMousemove', 'nodeMouseleave'])
|
||||
const emit = defineEmits<MiniMapEmits>()
|
||||
|
||||
const attrs: Record<string, any> = useAttrs()
|
||||
|
||||
@@ -202,6 +202,7 @@ function onNodeMouseLeave(event: MouseEvent, node: GraphNode) {
|
||||
export default {
|
||||
name: 'MiniMap',
|
||||
compatConfig: { MODE: 3 },
|
||||
inheritAttrs: false,
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -209,6 +210,7 @@ export default {
|
||||
<Panel :position="position" class="vue-flow__minimap" :class="{ pannable, zoomable }">
|
||||
<svg
|
||||
ref="el"
|
||||
v-bind="attrs"
|
||||
:width="elementWidth"
|
||||
:height="elementHeight"
|
||||
:viewBox="[viewBox.x, viewBox.y, viewBox.width, viewBox.height].join(' ')"
|
||||
|
||||
@@ -3,6 +3,7 @@ import { defineComponent, h, inject } from 'vue'
|
||||
import type { MiniMapNodeProps } from './types'
|
||||
import { MiniMapSlots } from './types'
|
||||
|
||||
// todo: typings
|
||||
export default defineComponent({
|
||||
name: 'MiniMapNode',
|
||||
compatConfig: { MODE: 3 },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Dimensions, GraphNode, PanelPosition, XYPosition } from '@vue-flow/core'
|
||||
import type { Dimensions, GraphNode, NodeMouseEvent, PanelPosition, XYPosition } from '@vue-flow/core'
|
||||
import type { CSSProperties, InjectionKey, Slots } from 'vue'
|
||||
|
||||
/** expects a node and returns a color value */
|
||||
@@ -61,4 +61,19 @@ export interface MiniMapNodeProps {
|
||||
strokeWidth?: number
|
||||
}
|
||||
|
||||
export interface MiniMapEmits {
|
||||
(
|
||||
event: 'click',
|
||||
params: {
|
||||
event: MouseEvent
|
||||
position: { x: number; y: number }
|
||||
},
|
||||
): void
|
||||
(event: 'nodeClick', params: NodeMouseEvent): void
|
||||
(event: 'nodeDblclick', params: NodeMouseEvent): void
|
||||
(event: 'nodeMouseenter', params: NodeMouseEvent): void
|
||||
(event: 'nodeMousemove', params: NodeMouseEvent): void
|
||||
(event: 'nodeMouseleave', params: NodeMouseEvent): void
|
||||
}
|
||||
|
||||
export const MiniMapSlots: InjectionKey<Slots> = Symbol('MiniMapSlots')
|
||||
|
||||
Reference in New Issue
Block a user