UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

31 lines (30 loc) 1.08 kB
import { batch } from "@preact/signals-core"; import cloneDeep from "lodash/cloneDeep"; 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.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(); }); } }