update(types): Use node/edge component type to define defaults
* import handleprops from types * Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { GraphNode, ShapeRendering } from '../../types'
|
import { ShapeRendering, StringFunc } from '../../types'
|
||||||
import { useVueFlow, useWindow } from '../../composables'
|
import { useVueFlow, useWindow } from '../../composables'
|
||||||
import { getBoundsofRects, getRectOfNodes } from '../../utils'
|
import { getBoundsofRects, getRectOfNodes } from '../../utils'
|
||||||
import type { MiniMapProps } from '../../types/components'
|
import type { MiniMapProps } from '../../types/components'
|
||||||
import MiniMapNode from './MiniMapNode.vue'
|
import MiniMapNode from './MiniMapNode.vue'
|
||||||
|
|
||||||
type StringFunc = (node: GraphNode) => string
|
|
||||||
|
|
||||||
const props = withDefaults(defineProps<MiniMapProps>(), {
|
const props = withDefaults(defineProps<MiniMapProps>(), {
|
||||||
nodeStrokeColor: '#555',
|
nodeStrokeColor: '#555',
|
||||||
nodeColor: '#fff',
|
nodeColor: '#fff',
|
||||||
|
|||||||
@@ -1,21 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useHandle, useVueFlow } from '../../composables'
|
import { useHandle, useVueFlow } from '../../composables'
|
||||||
import { Position, ValidConnectionFunc } from '../../types'
|
import { Position } from '../../types'
|
||||||
import { NodeId } from '../../context'
|
import { NodeId } from '../../context'
|
||||||
|
import type { HandleProps } from '../../types/components'
|
||||||
interface HandleProps {
|
|
||||||
id?: string
|
|
||||||
type?: string
|
|
||||||
position?: Position
|
|
||||||
isValidConnection?: ValidConnectionFunc
|
|
||||||
connectable?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
const { id } = useVueFlow()
|
const { id } = useVueFlow()
|
||||||
const props = withDefaults(defineProps<HandleProps>(), {
|
const props = withDefaults(defineProps<HandleProps>(), {
|
||||||
id: '',
|
id: '',
|
||||||
type: 'source',
|
type: 'source',
|
||||||
position: Position.Top,
|
position: 'top' as Position,
|
||||||
connectable: true,
|
connectable: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+14
-7
@@ -6,10 +6,17 @@ import { EdgeProps } from './edge'
|
|||||||
import { FitViewParams } from './zoom'
|
import { FitViewParams } from './zoom'
|
||||||
|
|
||||||
type GlobalComponentName = string
|
type GlobalComponentName = string
|
||||||
export type DefaultEdgeTypes = { [key in 'default' | 'straight' | 'smoothstep' | 'step']: Component<EdgeProps> }
|
export type NodeComponent<N = any> =
|
||||||
export type NodeComponent = Component<NodeProps> | DefineComponent<NodeProps, any, any, any, any> | GlobalComponentName
|
| Component<NodeProps<N>>
|
||||||
export type DefaultNodeTypes = { [key in 'input' | 'output' | 'default']: Component<NodeProps> }
|
| DefineComponent<NodeProps<N>, any, any, any, any>
|
||||||
export type EdgeComponent = Component<EdgeProps> | DefineComponent<EdgeProps, any, any, any, any, any> | GlobalComponentName
|
| GlobalComponentName
|
||||||
|
export type EdgeComponent<E = any> =
|
||||||
|
| Component<EdgeProps<E>>
|
||||||
|
| DefineComponent<EdgeProps<E>, any, any, any, any, any>
|
||||||
|
| GlobalComponentName
|
||||||
|
|
||||||
|
export type DefaultEdgeTypes = { [key in 'default' | 'straight' | 'smoothstep' | 'step']: EdgeComponent }
|
||||||
|
export type DefaultNodeTypes = { [key in 'input' | 'output' | 'default']: NodeComponent }
|
||||||
|
|
||||||
export type HandleType = 'source' | 'target'
|
export type HandleType = 'source' | 'target'
|
||||||
|
|
||||||
@@ -53,9 +60,9 @@ export type StringFunc<N = any> = (node: Node<N> | GraphNode<N>) => string
|
|||||||
export type ShapeRendering = 'inherit' | 'auto' | 'geometricPrecision' | 'optimizeSpeed' | 'crispEdges' | undefined
|
export type ShapeRendering = 'inherit' | 'auto' | 'geometricPrecision' | 'optimizeSpeed' | 'crispEdges' | undefined
|
||||||
|
|
||||||
export interface MiniMapProps<N = any> {
|
export interface MiniMapProps<N = any> {
|
||||||
nodeColor?: string | ((node: Node<N> | GraphNode<N>) => string)
|
nodeColor?: string | (<NC = N>(node: Node<NC> | GraphNode<NC>) => string)
|
||||||
nodeStrokeColor?: string | ((node: Node<N> | GraphNode<N>) => string)
|
nodeStrokeColor?: string | (<NSC = N>(node: Node<NSC> | GraphNode<NSC>) => string)
|
||||||
nodeClassName?: string | ((node: Node<N> | GraphNode<N>) => string)
|
nodeClassName?: string | (<NCM = N>(node: Node<NCM> | GraphNode<NCM>) => string)
|
||||||
nodeBorderRadius?: number
|
nodeBorderRadius?: number
|
||||||
nodeStrokeWidth?: number
|
nodeStrokeWidth?: number
|
||||||
maskColor?: string
|
maskColor?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user