@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
131 lines (130 loc) • 4.24 kB
TypeScript
import { Ref } from 'vue';
export interface CurvePoint {
x: number;
y: number;
}
export type CurveOrientation = 'default' | 'portrait' | 'landscape';
export interface CurvePointOffset {
aroundDirection: string;
left: number;
right: number;
top: number;
bottom: number;
x: number;
y: number;
}
export interface PendingConnection {
startNodeId: string;
startPortId: string;
startPosition: {
x: number;
y: number;
};
mousePosition: {
x: number;
y: number;
};
}
export interface UseDrawing {
drawFrom: (ancherElementId: string, payload: MouseEvent) => void;
}
export interface UseCurve {
createCurveBetween: (starPointId: string, endPointId: string) => void;
drawingCurveBetween: (startX: number, startY: number, endX: number, endY: number) => void;
}
export interface UseBezierCurve {
connect: (startPointId: string, endPointId: string, startPointPosition: string, endPoinPosition: string) => void;
drawing: (curveId: string, startPoint: CurvePoint, endPoint: CurvePoint, startPointPosition: string, endPoinPosition: string) => void;
redrawConnection: (startPointId: string, endPointId: string) => void;
setConnectionClickHandler: (handler: (connectionId: string) => void) => void;
updateConnectionSelection: (connectionId: string, selected: boolean) => void;
setConnectionContextMenuHandler: (handler: (connectionId: string, event: MouseEvent) => void) => void;
setConnectionInsertNodeHandler: (handler: (connectionId: string, position: {
x: number;
y: number;
}) => void) => void;
status: Ref<string>;
}
export interface DeleteResult {
success: boolean;
message: string;
deletedItems?: {
nodes?: string[];
connections?: string[];
};
}
export interface SelectionState {
selectedNodeId: string | null;
selectedConnectionId: string | null;
}
export interface ContextMenuState {
visible: boolean;
position: {
x: number;
y: number;
};
type: 'node' | 'connection' | null;
targetId: string | null;
}
export interface UseDrawingBezier {
drawFrom: (ancherElementId: string, payload: MouseEvent) => void;
eraseDrawingLine: (curveId: string) => void;
finishToDraw: (event: MouseEvent) => void;
getAncherPointPosition: (ancher: HTMLElement | null) => string;
isAncherPoint: (element: HTMLElement) => boolean;
startAncherElement: Ref<HTMLElement | undefined>;
pendingConnection: Ref<PendingConnection | null>;
showNodeSelector: Ref<boolean>;
nodeSelectorPosition: Ref<{
x: number;
y: number;
}>;
cancelNodeSelection: () => void;
completeNodeSelection: (targetNodeType: string) => void;
}
export type ConnectionType = 'Curve' | 'Line';
export interface Connection {
from: string;
to: string;
type: ConnectionType;
}
export interface UseConnections {
addConnection: (fromNodeId: string, startAncherId: string, toNodeId: string, endAncherId: string) => void;
getConnectionsOfNode: (nodeId: string) => Connection[];
removeConnection: (startAncherId: string, endAcherId: string) => void;
getConnectionsByNodeId: (nodeId: string) => Array<{
startPortId: string;
endPortId: string;
startNodeId: string;
endNodeId: string;
connectionId: string;
}>;
getAllConnections: () => Array<{
startPortId: string;
endPortId: string;
startNodeId: string;
endNodeId: string;
connectionId: string;
}>;
}
export interface ConfigOptions {
/** 节点组件集合 */
nodeUrl: string;
/** 节点元模型集合 */
nodeSchemasUrl: string;
/** 节点属性配置集合 */
propertyConfigUrl: string;
/** 流程节点工具箱 */
toolboxUrl: string;
}
export interface UseConfig {
options: ConfigOptions;
initialize: () => Promise<any>;
}
export interface UseSelection {
selectedNodeId: Ref<string | null>;
selectedConnectionId: Ref<string | null>;
selectNode: (nodeId: string, schemaType: string, schemaValue: any) => void;
selectConnection: (connectionId: string) => void;
clearSelection: () => void;
}