UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

33 lines (32 loc) 1.21 kB
import { batch } from "@preact/signals-core"; import cloneDeep from "lodash/cloneDeep"; import { SelectionService } from "../services/selection/SelectionService"; import { BlockListStore } from "./block/BlocksList"; import { ConnectionsStore } from "./connection/ConnectionList"; import { GroupsListStore } from "./group/GroupsList"; import { GraphEditorSettings } from "./settings"; export class RootStore { constructor(graph) { this.selectionService = new SelectionService(); this.blocksList = new BlockListStore(this, graph); this.connectionsList = new ConnectionsStore(this, graph); this.settings = new GraphEditorSettings(this); this.groupsList = new GroupsListStore(this, graph); } getAsConfig() { return cloneDeep({ configurationName: this.configurationName, blocks: this.blocksList.toJSON(), connections: this.connectionsList.toJSON(), settings: this.settings.toJSON(), }); } reset() { batch(() => { this.blocksList.reset(); this.connectionsList.reset(); this.settings.reset(); this.groupsList.reset(); }); } }