@selenite/graph-editor
Version:
A graph editor for visual programming, based on rete and svelte.
87 lines (86 loc) • 4.42 kB
TypeScript
import { BaseComponent } from '../components';
import type { NodeFactory } from './NodeFactory.svelte';
import { Connection, Node } from '../nodes';
import { SvelteSet } from 'svelte/reactivity';
import { Comment } from 'rete-comment-plugin';
import { boxSelection } from '@selenite/commons';
declare const entityTypesMap: {
readonly node: typeof Node;
readonly connection: typeof Connection;
readonly comment: typeof Comment;
};
type EntityType = keyof typeof entityTypesMap;
export type SelectorEntity = InstanceType<(typeof entityTypesMap)[EntityType]>;
type EntityWithType<K extends EntityType = EntityType> = {
type: K;
entity: InstanceType<(typeof entityTypesMap)[K]>;
};
export declare class NodeSelection extends BaseComponent<NodeFactory> {
#private;
entities: SvelteSet<SelectorEntity>;
accumulating: boolean;
ranging: boolean;
modifierActive: boolean;
typedEntities: EntityWithType[];
constructor(params: {
owner: NodeFactory;
});
nodes: Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>>[];
connections: Connection<Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>>, Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>>>[];
picked: SelectorEntity | undefined;
pickedNode: Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>> | undefined;
pickedConnection: Connection<Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>>, Node<Record<string, import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">>, {
[x: string]: import("../socket").Socket<import("../plugins/typed-sockets").SocketType, "scalar" | "array">;
}, {
[x: string]: import("../control").Control;
}, Record<string, unknown>, Record<string, unknown>>> | undefined;
entityElement(entity: SelectorEntity): HTMLElement | undefined;
isSelected(entity: SelectorEntity): boolean;
invertSelection(): void;
/**
* Selects all entities between two entities.
*
* Selects only entities with 50% of their bounding box inside
* the bouding box formed by the two entities.
*/
selectRange(a: SelectorEntity, b: SelectorEntity): void;
selectMultiple(entities: Iterable<SelectorEntity>): void;
select(entity: SelectorEntity, options?: {
accumulate?: boolean;
pick?: boolean;
range?: boolean;
}): void;
remove(entity: SelectorEntity): void;
unselect(entity: SelectorEntity): void;
unselectAll(): void;
translate(dx: number, dy: number): void;
pick(entity: SelectorEntity): void;
releasePicked(): void;
isPicked(entity: SelectorEntity | EntityWithType): boolean;
selectAll(): void;
get boxSelectionEnabled(): boolean;
boxSelectionAction: ReturnType<typeof boxSelection> | undefined;
set boxSelectionEnabled(value: boolean);
}
export type SelectOptions = Parameters<NodeSelection['select']>[1];
export {};