refactor(types): Split types into separate files
* for better organization split typings into separate files * use index as barrel file
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
import { Edge } from './edge'
|
||||
import { Node } from './node'
|
||||
|
||||
export type ElementId = string
|
||||
|
||||
export type FlowElement<T = any> = Node<T> | Edge<T>
|
||||
|
||||
export type Elements<T = any> = Array<FlowElement<T>>
|
||||
|
||||
export type Transform = [number, number, number]
|
||||
|
||||
export enum Position {
|
||||
Left = 'left',
|
||||
Top = 'top',
|
||||
Right = 'right',
|
||||
Bottom = 'bottom',
|
||||
}
|
||||
|
||||
export interface XYPosition {
|
||||
x: number
|
||||
y: number
|
||||
}
|
||||
|
||||
export interface Dimensions {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
export interface Rect extends Dimensions, XYPosition {}
|
||||
|
||||
export type SnapGrid = [number, number]
|
||||
|
||||
export enum ArrowHeadType {
|
||||
Arrow = 'arrow',
|
||||
ArrowClosed = 'arrowclosed',
|
||||
}
|
||||
|
||||
export enum BackgroundVariant {
|
||||
Lines = 'lines',
|
||||
Dots = 'dots',
|
||||
}
|
||||
|
||||
export interface SelectionRect extends Rect {
|
||||
startX: number
|
||||
startY: number
|
||||
draw: boolean
|
||||
}
|
||||
|
||||
export type FitViewParams = {
|
||||
padding?: number
|
||||
includeHiddenNodes?: boolean
|
||||
minZoom?: number
|
||||
maxZoom?: number
|
||||
}
|
||||
|
||||
export type FlowExportObject<T = any> = {
|
||||
elements: Elements<T>
|
||||
position: [number, number]
|
||||
zoom: number
|
||||
}
|
||||
|
||||
export type FlowTransform = {
|
||||
x: number
|
||||
y: number
|
||||
zoom: number
|
||||
}
|
||||
|
||||
export type FitViewFunc = (fitViewOptions?: FitViewParams) => void
|
||||
export type ProjectFunc = (position: XYPosition) => XYPosition
|
||||
export type ToObjectFunc<T = any> = () => FlowExportObject<T>
|
||||
|
||||
export type OnLoadParams<T = any> = {
|
||||
zoomIn: () => void
|
||||
zoomOut: () => void
|
||||
zoomTo: (zoomLevel: number) => void
|
||||
fitView: FitViewFunc
|
||||
project: ProjectFunc
|
||||
getElements: () => Elements<T>
|
||||
setTransform: (transform: FlowTransform) => void
|
||||
toObject: ToObjectFunc<T>
|
||||
}
|
||||
|
||||
export type OnLoadFunc<T = any> = (params: OnLoadParams<T>) => void
|
||||
Reference in New Issue
Block a user