refactor(core): move MaybeElement type

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-02-01 23:00:08 +01:00
committed by Braks
parent 6ea60349fd
commit 51270caa73
2 changed files with 3 additions and 5 deletions
+2 -1
View File
@@ -2,7 +2,7 @@ import type { CSSProperties } from 'vue'
import type { KeyFilter } from '@vueuse/core' import type { KeyFilter } from '@vueuse/core'
import type { DefaultEdgeOptions, Edge, EdgeUpdatable, GraphEdge } from './edge' import type { DefaultEdgeOptions, Edge, EdgeUpdatable, GraphEdge } from './edge'
import type { CoordinateExtent, GraphNode, Node } from './node' import type { CoordinateExtent, GraphNode, Node } from './node'
import type { ConnectionLineOptions, ConnectionLineType, ConnectionMode, Connector } from './connection' import type { Connection, ConnectionLineOptions, ConnectionLineType, ConnectionMode, Connector } from './connection'
import type { PanOnScrollMode, ViewportTransform } from './zoom' import type { PanOnScrollMode, ViewportTransform } from './zoom'
import type { EdgeTypesObject, NodeTypesObject } from './components' import type { EdgeTypesObject, NodeTypesObject } from './components'
import type { CustomEvent } from './hooks' import type { CustomEvent } from './hooks'
@@ -39,6 +39,7 @@ export type Elements<
EdgeEvents extends Record<string, CustomEvent> = any, EdgeEvents extends Record<string, CustomEvent> = any,
> = Element<NodeData, EdgeData, NodeEvents, EdgeEvents>[] > = Element<NodeData, EdgeData, NodeEvents, EdgeEvents>[]
export type MaybeElement = Node | Edge | Connection | FlowElement | Element
export interface CustomThemeVars { export interface CustomThemeVars {
[key: string]: string | number | undefined [key: string]: string | number | undefined
} }
+1 -4
View File
@@ -8,12 +8,11 @@ import type {
Dimensions, Dimensions,
Edge, Edge,
EdgeMarkerType, EdgeMarkerType,
Element,
ElementData, ElementData,
Elements, Elements,
FlowElement,
GraphEdge, GraphEdge,
GraphNode, GraphNode,
MaybeElement,
Node, Node,
Rect, Rect,
ViewportTransform, ViewportTransform,
@@ -54,8 +53,6 @@ export const getHostForElement = (element: HTMLElement): Document => {
else return window.document else return window.document
} }
type MaybeElement = Node | Edge | Connection | FlowElement | Element
export const isEdge = <Data = ElementData>(element: MaybeElement): element is Edge<Data> => export const isEdge = <Data = ElementData>(element: MaybeElement): element is Edge<Data> =>
element && 'id' in element && 'source' in element && 'target' in element element && 'id' in element && 'source' in element && 'target' in element