feat(docs): Add comments to types
This commit is contained in:
+1
-2
@@ -23,8 +23,7 @@
|
|||||||
"unpkg": "./dist/vue-flow.iife.js",
|
"unpkg": "./dist/vue-flow.iife.js",
|
||||||
"jsdelivr": "./dist/vue-flow.iife.js",
|
"jsdelivr": "./dist/vue-flow.iife.js",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist"
|
||||||
"docs"
|
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "ts-patch install -s",
|
"prepare": "ts-patch install -s",
|
||||||
|
|||||||
@@ -83,5 +83,4 @@ export default {
|
|||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
@import '../../style.css';
|
@import '../../style.css';
|
||||||
@import '../../theme-default.css';
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+41
-2
@@ -5,11 +5,16 @@ import { GraphNode, Node, NodeProps } from './node'
|
|||||||
import { EdgeProps } from './edge'
|
import { EdgeProps } from './edge'
|
||||||
import { FitViewParams } from './zoom'
|
import { FitViewParams } from './zoom'
|
||||||
|
|
||||||
|
/** Global component names are components registered to the vue instance and are "autoloaded" by their string name */
|
||||||
type GlobalComponentName = string
|
type GlobalComponentName = string
|
||||||
|
|
||||||
|
/** Node Components can either be a component definition or a string name */
|
||||||
export type NodeComponent<N = any> =
|
export type NodeComponent<N = any> =
|
||||||
| Component<NodeProps<N>>
|
| Component<NodeProps<N>>
|
||||||
| DefineComponent<NodeProps<N>, any, any, any, any>
|
| DefineComponent<NodeProps<N>, any, any, any, any>
|
||||||
| GlobalComponentName
|
| GlobalComponentName
|
||||||
|
|
||||||
|
/** Edge Components can either be a component definition or a string name */
|
||||||
export type EdgeComponent<E = any> =
|
export type EdgeComponent<E = any> =
|
||||||
| Component<EdgeProps<E>>
|
| Component<EdgeProps<E>>
|
||||||
| DefineComponent<EdgeProps<E>, any, any, any, any, any>
|
| DefineComponent<EdgeProps<E>, any, any, any, any, any>
|
||||||
@@ -25,32 +30,51 @@ export interface HandleElement extends XYPosition, Dimensions {
|
|||||||
position: Position
|
position: Position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A valid connection function can determine if an attempted connection is valid or not, i.e. abort creating a new edge */
|
||||||
export type ValidConnectionFunc = (connection: Connection) => boolean
|
export type ValidConnectionFunc = (connection: Connection) => boolean
|
||||||
|
|
||||||
export interface HandleProps {
|
export interface HandleProps {
|
||||||
|
/** Unique id of handle element */
|
||||||
id?: string
|
id?: string
|
||||||
|
/** Handle type (source / target) {@link HandleType} */
|
||||||
type?: string
|
type?: string
|
||||||
|
/** Handle position (top, bottom, left, right) {@link Position} */
|
||||||
position?: Position
|
position?: Position
|
||||||
|
/** A valid connection func {@link ValidConnectionFunc} */
|
||||||
isValidConnection?: ValidConnectionFunc
|
isValidConnection?: ValidConnectionFunc
|
||||||
|
/** Enable/disable connecting to handle */
|
||||||
connectable?: boolean
|
connectable?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BackgroundProps {
|
export interface BackgroundProps {
|
||||||
|
/** The background pattern */
|
||||||
variant?: BackgroundVariant
|
variant?: BackgroundVariant
|
||||||
|
/** Background pattern gap */
|
||||||
gap?: number
|
gap?: number
|
||||||
patternColor?: string
|
/** Background pattern size */
|
||||||
bgColor?: string
|
|
||||||
size?: number
|
size?: number
|
||||||
|
/** Background pattern color */
|
||||||
|
patternColor?: string
|
||||||
|
/** Background color */
|
||||||
|
bgColor?: string
|
||||||
|
/** Background height */
|
||||||
height?: number
|
height?: number
|
||||||
|
/** Background width */
|
||||||
width?: number
|
width?: number
|
||||||
|
/** Background x-coordinate (offset x) */
|
||||||
x?: number
|
x?: number
|
||||||
|
/** Background y-coordinate (offset y) */
|
||||||
y?: number
|
y?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ControlProps {
|
export interface ControlProps {
|
||||||
|
/** Show the zoom icon */
|
||||||
showZoom?: boolean
|
showZoom?: boolean
|
||||||
|
/** Show the fit-view icon */
|
||||||
showFitView?: boolean
|
showFitView?: boolean
|
||||||
|
/** Show the interactive icon */
|
||||||
showInteractive?: boolean
|
showInteractive?: boolean
|
||||||
|
/** Params to use on fitView */
|
||||||
fitViewParams?: FitViewParams
|
fitViewParams?: FitViewParams
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,11 +89,17 @@ 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> {
|
||||||
|
/** Node color, can be either a string or a string func that receives the current node */
|
||||||
nodeColor?: string | (<NC = N>(node: Node<NC> | GraphNode<NC>) => string)
|
nodeColor?: string | (<NC = N>(node: Node<NC> | GraphNode<NC>) => string)
|
||||||
|
/** Node stroke color, can be either a string or a string func that receives the current node */
|
||||||
nodeStrokeColor?: string | (<NSC = N>(node: Node<NSC> | GraphNode<NSC>) => string)
|
nodeStrokeColor?: string | (<NSC = N>(node: Node<NSC> | GraphNode<NSC>) => string)
|
||||||
|
/** Additional node class name, can be either a string or a string func that receives the current node */
|
||||||
nodeClassName?: string | (<NCM = N>(node: Node<NCM> | GraphNode<NCM>) => string)
|
nodeClassName?: string | (<NCM = N>(node: Node<NCM> | GraphNode<NCM>) => string)
|
||||||
|
/** Node border radius */
|
||||||
nodeBorderRadius?: number
|
nodeBorderRadius?: number
|
||||||
|
/** Node stroke width */
|
||||||
nodeStrokeWidth?: number
|
nodeStrokeWidth?: number
|
||||||
|
/** Background color of minimap */
|
||||||
maskColor?: string
|
maskColor?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,15 +130,24 @@ export interface EdgeTextProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ConnectionLineProps<N = any> {
|
export interface ConnectionLineProps<N = any> {
|
||||||
|
/** Source X position of the connection line */
|
||||||
sourceX: number
|
sourceX: number
|
||||||
|
/** Source Y position of the connection line */
|
||||||
sourceY: number
|
sourceY: number
|
||||||
|
/** Source position of the connection line */
|
||||||
sourcePosition: Position
|
sourcePosition: Position
|
||||||
|
/** Target X position of the connection line */
|
||||||
targetX: number
|
targetX: number
|
||||||
|
/** Target Y position of the connection line */
|
||||||
targetY: number
|
targetY: number
|
||||||
|
/** Target position of the connection line */
|
||||||
targetPosition: Position
|
targetPosition: Position
|
||||||
connectionLineType: ConnectionLineType
|
connectionLineType: ConnectionLineType
|
||||||
connectionLineStyle: CSSProperties
|
connectionLineStyle: CSSProperties
|
||||||
|
/** All currently stored nodes */
|
||||||
nodes: GraphNode<N>[]
|
nodes: GraphNode<N>[]
|
||||||
|
/** The source node of the connection line */
|
||||||
sourceNode: GraphNode<N>
|
sourceNode: GraphNode<N>
|
||||||
|
/** The source handle element of the connection line */
|
||||||
sourceHandle: HandleElement
|
sourceHandle: HandleElement
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { HandleType } from './components'
|
import { HandleType } from './components'
|
||||||
|
|
||||||
|
/** Connection line types (same as default edge types */
|
||||||
export enum ConnectionLineType {
|
export enum ConnectionLineType {
|
||||||
Bezier = 'default',
|
Bezier = 'default',
|
||||||
Straight = 'straight',
|
Straight = 'straight',
|
||||||
@@ -7,19 +8,29 @@ export enum ConnectionLineType {
|
|||||||
SmoothStep = 'smoothstep',
|
SmoothStep = 'smoothstep',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Connection params that are passed when onConnect is called */
|
||||||
export interface Connection {
|
export interface Connection {
|
||||||
|
/** Source node id */
|
||||||
source: string
|
source: string
|
||||||
|
/** Target node id */
|
||||||
target: string
|
target: string
|
||||||
|
/** Source handle id */
|
||||||
sourceHandle?: string
|
sourceHandle?: string
|
||||||
|
/** Target handle id */
|
||||||
targetHandle?: string
|
targetHandle?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The source nodes params when connection is initiated */
|
||||||
export type OnConnectStartParams = {
|
export type OnConnectStartParams = {
|
||||||
|
/** Source node id */
|
||||||
nodeId?: string
|
nodeId?: string
|
||||||
|
/** Source handle id */
|
||||||
handleId?: string
|
handleId?: string
|
||||||
|
/** Source handle type */
|
||||||
handleType?: HandleType
|
handleType?: HandleType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Connection modes, when set to loose all handles are treated as source */
|
||||||
export enum ConnectionMode {
|
export enum ConnectionMode {
|
||||||
Strict = 'strict',
|
Strict = 'strict',
|
||||||
Loose = 'loose',
|
Loose = 'loose',
|
||||||
|
|||||||
+29
-3
@@ -2,19 +2,29 @@ import { CSSProperties } from 'vue'
|
|||||||
import { Position, Element } from './flow'
|
import { Position, Element } from './flow'
|
||||||
import { GraphNode } from './node'
|
import { GraphNode } from './node'
|
||||||
|
|
||||||
|
/** Edge markers */
|
||||||
export enum MarkerType {
|
export enum MarkerType {
|
||||||
Arrow = 'arrow',
|
Arrow = 'arrow',
|
||||||
ArrowClosed = 'arrowclosed',
|
ArrowClosed = 'arrowclosed',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Edge marker definition */
|
||||||
export interface EdgeMarker {
|
export interface EdgeMarker {
|
||||||
|
/** Unique marker id */
|
||||||
id?: string
|
id?: string
|
||||||
|
/** Marker type */
|
||||||
type: MarkerType
|
type: MarkerType
|
||||||
|
/** Marker color */
|
||||||
color?: string
|
color?: string
|
||||||
|
/** Marker width */
|
||||||
width?: number
|
width?: number
|
||||||
|
/** Marker height */
|
||||||
height?: number
|
height?: number
|
||||||
|
/** Marker units */
|
||||||
markerUnits?: string
|
markerUnits?: string
|
||||||
|
/** Marker orientation */
|
||||||
orient?: string
|
orient?: string
|
||||||
|
/** Marker stroke width */
|
||||||
strokeWidth?: number
|
strokeWidth?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,24 +39,40 @@ export interface MarkerProps {
|
|||||||
strokeWidth?: number
|
strokeWidth?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type EdgeMarkerType = string | EdgeMarker
|
export type EdgeMarkerType = string | MarkerType | EdgeMarker
|
||||||
|
|
||||||
export interface Edge<T = any> extends Element<T> {
|
export interface Edge<T = any> extends Element<T> {
|
||||||
|
/** Source node id */
|
||||||
source: string
|
source: string
|
||||||
|
/** Target node id */
|
||||||
target: string
|
target: string
|
||||||
|
/** Source handle id */
|
||||||
sourceHandle?: string
|
sourceHandle?: string
|
||||||
|
/** Target handle id */
|
||||||
targetHandle?: string
|
targetHandle?: string
|
||||||
|
/** Source position */
|
||||||
sourcePosition?: Position
|
sourcePosition?: Position
|
||||||
|
/** Target position */
|
||||||
targetPosition?: Position
|
targetPosition?: Position
|
||||||
labelStyle?: any
|
/** Label styles (CSSProperties) */
|
||||||
|
labelStyle?: CSSProperties
|
||||||
|
/** Show label bg */
|
||||||
labelShowBg?: boolean
|
labelShowBg?: boolean
|
||||||
labelBgStyle?: any
|
/** Label Bg styles (CSSProperties) */
|
||||||
|
labelBgStyle?: CSSProperties
|
||||||
|
/** Label Bg padding */
|
||||||
labelBgPadding?: [number, number]
|
labelBgPadding?: [number, number]
|
||||||
|
/** Label Bg border radius */
|
||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
|
/** Animated edge */
|
||||||
animated?: boolean
|
animated?: boolean
|
||||||
|
/** EdgeMarker */
|
||||||
markerStart?: EdgeMarkerType
|
markerStart?: EdgeMarkerType
|
||||||
|
/** EdgeMarker */
|
||||||
markerEnd?: EdgeMarkerType
|
markerEnd?: EdgeMarkerType
|
||||||
|
/** Disable/enable updating edge */
|
||||||
updatable?: boolean
|
updatable?: boolean
|
||||||
|
/** Disable/enable selecting edge */
|
||||||
selectable?: boolean
|
selectable?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user