import { NodeId, ProjectId, BBox } from '@likec4/core'; import { LayoutedProjectsView } from '@likec4/core/compute-view'; import { EdgeChange, NodeChange } from '@xyflow/system'; import { MouseEvent } from 'react'; import { Simplify } from 'type-fest'; import { ActorRef, SnapshotFrom, StateMachine, ActionFunction } from 'xstate'; import { ViewPadding } from '../LikeC4Diagram.props'; import { ProjectsOverviewTypes, ProjectsOverviewXYFLowInstance, ProjectsOverviewXYStoreApi } from './_types'; export type Input = { view: LayoutedProjectsView; fitViewPadding: ViewPadding; }; export interface Context { initialized: { xydata: boolean; xyflow: boolean; }; xystore: ProjectsOverviewXYStoreApi | null; xyflow: ProjectsOverviewXYFLowInstance | null; view: LayoutedProjectsView; fitViewPadding: ViewPadding; xynodes: ProjectsOverviewTypes.Node[]; xyedges: ProjectsOverviewTypes.Edge[]; navigateTo?: ProjectsOverviewTypes.Node; } export type EmittedEvents = { type: 'navigate.to'; projectId: ProjectId; }; /** * Converts a union of events to a union of events with a prefix. */ type EmitEach = { [Key in T['type']]: Simplify<{ type: `emit.${Key}`; } & Omit, 'type'>>; }[T['type']]; export type Events = { type: 'navigate.to'; projectId: ProjectId; fromNode: NodeId; } | { type: 'xyflow.init'; xyflow: ProjectsOverviewXYFLowInstance; xystore: ProjectsOverviewXYStoreApi; } | { type: 'xyflow.click.node'; node: ProjectsOverviewTypes.Node; } | { type: 'xyflow.click.edge'; edge: ProjectsOverviewTypes.Edge; } | { type: 'xyflow.click.pane'; } | { type: 'xyflow.click.double'; } | { type: 'xyflow.mouse.enter.node'; node: ProjectsOverviewTypes.Node; } | { type: 'xyflow.mouse.leave.node'; node: ProjectsOverviewTypes.Node; } | { type: 'xyflow.mouse.enter.edge'; edge: ProjectsOverviewTypes.Edge; event: MouseEvent; } | { type: 'xyflow.mouse.leave.edge'; edge: ProjectsOverviewTypes.Edge; event: MouseEvent; } | { type: 'xyflow.applyNodeChanges'; changes: NodeChange[]; } | { type: 'xyflow.applyEdgeChanges'; changes: EdgeChange[]; } | { type: 'xyflow.fitDiagram'; bounds?: BBox; duration?: number; } | { type: 'update.view'; view: LayoutedProjectsView; } | EmitEach | { type: 'close'; }; type Tags = 'active'; export declare const onMouseEnterOrLeave: () => ActionFunction; export declare const fitDiagram: (params?: { duration?: number; bounds?: BBox; }) => ActionFunction; export declare const restoreViewport: () => ActionFunction; export interface ProjectsOverviewLogic extends StateMachine { } export declare const projectOverviewLogic: ProjectsOverviewLogic; export type ProjectsOverviewSnapshot = SnapshotFrom; export interface ProjectsOverviewActorRef extends ActorRef { } export type { Input as ProjectsOverviewInput, };