feat(minimap): add MiniMapNodeEmits interface & export it
This commit is contained in:
@@ -1,31 +1,17 @@
|
|||||||
import type { CSSProperties } from 'vue'
|
import type { CSSProperties } from 'vue'
|
||||||
import { defineComponent, h, inject } from 'vue'
|
import { defineComponent, h, inject } from 'vue'
|
||||||
import type { MiniMapNodeProps } from './types'
|
import type { MiniMapNodeEmits, MiniMapNodeProps } from './types'
|
||||||
import { Slots } from './types'
|
import { Slots } from './types'
|
||||||
|
|
||||||
// todo: typings
|
export default defineComponent<MiniMapNodeProps, MiniMapNodeEmits>({
|
||||||
export default defineComponent({
|
|
||||||
name: 'MiniMapNode',
|
name: 'MiniMapNode',
|
||||||
compatConfig: { MODE: 3 },
|
compatConfig: { MODE: 3 },
|
||||||
props: [
|
setup(props, { attrs, emit }) {
|
||||||
'id',
|
|
||||||
'type',
|
|
||||||
'selected',
|
|
||||||
'dragging',
|
|
||||||
'position',
|
|
||||||
'dimensions',
|
|
||||||
'borderRadius',
|
|
||||||
'color',
|
|
||||||
'shapeRendering',
|
|
||||||
'strokeColor',
|
|
||||||
'strokeWidth',
|
|
||||||
],
|
|
||||||
emits: ['click', 'dblclick', 'mouseenter', 'mousemove', 'mouseleave'],
|
|
||||||
setup(props: MiniMapNodeProps, { attrs, emit }) {
|
|
||||||
const miniMapSlots = inject(Slots)!
|
const miniMapSlots = inject(Slots)!
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const style = (attrs.style ?? {}) as CSSProperties
|
const style = (attrs.style ?? {}) as CSSProperties
|
||||||
|
|
||||||
const slot = miniMapSlots[`node-${props.type}`]
|
const slot = miniMapSlots[`node-${props.type}`]
|
||||||
|
|
||||||
if (slot) {
|
if (slot) {
|
||||||
|
|||||||
@@ -73,6 +73,14 @@ export interface MiniMapEmits {
|
|||||||
(event: 'nodeMouseleave', params: NodeMouseEvent): void
|
(event: 'nodeMouseleave', params: NodeMouseEvent): void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MiniMapNodeEmits {
|
||||||
|
(event: 'click', params: NodeMouseEvent): void
|
||||||
|
(event: 'dblclick', params: NodeMouseEvent): void
|
||||||
|
(event: 'mouseenter', params: NodeMouseEvent): void
|
||||||
|
(event: 'mousemove', params: NodeMouseEvent): void
|
||||||
|
(event: 'mouseleave', params: NodeMouseEvent): void
|
||||||
|
}
|
||||||
|
|
||||||
export interface MiniMapSlots extends Record<`node-${string}`, (nodeProps: MiniMapNodeProps) => any> {}
|
export interface MiniMapSlots extends Record<`node-${string}`, (nodeProps: MiniMapNodeProps) => any> {}
|
||||||
|
|
||||||
export const Slots: InjectionKey<MiniMapSlots> = Symbol('MiniMapSlots')
|
export const Slots: InjectionKey<MiniMapSlots> = Symbol('MiniMapSlots')
|
||||||
|
|||||||
Reference in New Issue
Block a user