UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

28 lines (27 loc) 1.15 kB
import { Group } from "../../components/canvas/groups"; import { ESelectionStrategy, ISelectionBucket } from "../../services/selection/types"; import { TRect } from "../../utils/types/shapes"; import { GroupsListStore } from "./GroupsList"; export type TGroupId = string; export interface TGroup { id: TGroupId; rect: TRect; selected?: boolean; component?: typeof Group; } export declare class GroupState { protected store: GroupsListStore; private readonly groupSelectionBucket; $state: import("@preact/signals-core").Signal<TGroup>; constructor(store: GroupsListStore, state: TGroup, groupSelectionBucket: ISelectionBucket<string | number>); get id(): string; /** * Computed signal that reactively determines if this group is selected * by checking if its ID exists in the selection bucket */ readonly $selected: import("@preact/signals-core").ReadonlySignal<boolean>; updateGroup(group: Partial<TGroup>): void; setSelection(selected: boolean, strategy?: ESelectionStrategy): void; asTGroup(): TGroup; static fromTGroup(store: GroupsListStore, group: TGroup): GroupState; }