@gravity-ui/graph
Version:
Modern graph editor component
49 lines (48 loc) • 1.93 kB
TypeScript
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<T extends TGroup = TGroup> {
protected store: GroupsListStore;
private readonly groupSelectionBucket;
$state: import("@preact/signals-core").Signal<T>;
readonly $viewComponent: import("@preact/signals-core").Signal<Group<TGroup>>;
/**
* When true, the group's rect should not be auto-updated based on contained blocks.
* Used during Shift+drag to keep the group visually stable.
* Note: This is NOT a signal to avoid cycle detection issues in computed signals.
*/
private sizeLocked;
constructor(store: GroupsListStore, state: T, groupSelectionBucket: ISelectionBucket<string | number>);
setViewComponent(component: Group | undefined): void;
getViewComponent(): Group<TGroup>;
/**
* Check if the group's size is locked
*/
isSizeLocked(): boolean;
/**
* Lock the group's size to prevent auto-resize during block transfer
*/
lockSize(): void;
/**
* Unlock the group's size to allow auto-resize
*/
unlockSize(): void;
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<T>): void;
setSelection(selected: boolean, strategy?: ESelectionStrategy): void;
asTGroup(): T;
static fromTGroup<T extends TGroup>(store: GroupsListStore, group: T): GroupState<T>;
}