@bruno00o/graph 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,8 @@ Framework-agnostic, typed graph visualization rendered with WebGL2.
24
24
  - Declarative marks: map your fields to color, size, labels, arrows and dashes through shared scales, with types inferred from your data
25
25
  - Live sources: pass a TanStack DB collection as is, or anything with `subscribeChanges`, and only what changed is redrawn
26
26
  - Named states (selection, hover, focus and your own) resolved on the GPU
27
- - Parallel edges, self loops, drag, pan and zoom out of the box
27
+ - Images and icons clipped to the node shape, corner badges, outlines, label backgrounds, parallel edges and self loops
28
+ - Drag, pan, zoom, multiple selection and lasso out of the box, plus keyboard navigation announced to screen readers
28
29
  - Themed with CSS variables, light and dark
29
30
  - A framework-agnostic core with a thin React adapter, plus TanStack DB and TanStack Query integrations
30
31
 
@@ -108,7 +109,7 @@ nodes(itemsCollection, { color: 'group', label: 'label' })
108
109
 
109
110
  ## Examples
110
111
 
111
- The [`examples`](./examples) folder holds runnable examples: vanilla and React graphs, parallel edges and loops, collaboration across tabs with TanStack DB, and neighborhood exploration with TanStack Query. Run them with `pnpm install && pnpm dev`.
112
+ The [`examples`](./examples) folder holds runnable examples: vanilla and React graphs, images, badges and outlines, parallel edges and loops, collaboration across tabs with TanStack DB, and neighborhood exploration with TanStack Query. Run them with `pnpm install && pnpm dev`.
112
113
 
113
114
  ## Get Involved
114
115
 
package/dist/db.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { r as GraphInstance } from "./mount-graph-B88WGOQu.js";
2
- import { O as Point, _ as Key, d as FieldOf } from "./types-D6b86Rt1.js";
1
+ import { i as GraphInstance } from "./mount-graph-Br5IAZbP.js";
2
+ import { _ as Key, d as FieldOf, k as Point } from "./types-DJEdpHUo.js";
3
3
  import { Collection, MutationFn, Strategy } from "@tanstack/db";
4
4
  export interface PersistPositionsOptions<T extends object, TKey extends string | number> {
5
5
  readonly collection: Collection<T, TKey>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ResolvedTransitions, C as NodeMark, D as NumberScaleType, E as NumberScale, F as StateStyle, I as StateStyles, L as Style, M as SelectMode, N as SourceChange, O as Point, P as SourceSubscription, R as TransitionOptions, S as Mark, T as NodeShape, _ as Key, a as Channel, b as LabelOptions, c as EdgeDash, d as FieldOf, f as FreeState, g as InteractionOptions, h as GraphDefinitionOptions, i as BuiltInState, j as ScalesOptions, k as ResolvedInteraction, l as EdgeMark, m as GraphDefinition, n as Badge, o as ColorScale, p as GraphData, r as BadgeCorner, s as EdgeArrow, t as Accessor, u as EdgeOptions, v as KeyChannel, w as NodeOptions, x as LiveSource, y as KeyFieldOf, z as View } from "./types-D6b86Rt1.js";
2
- import { C as PositionOrigin, S as GraphTargetEvent, _ as GraphEventName, a as GraphSelection, b as GraphPositionEvent, c as GraphStore, d as ViewOptions, f as mountGraph, g as GraphEventHandler, h as GraphDragEvent, i as GraphPositions, l as GraphView, m as ElementKeysInput, n as GraphElement, o as GraphState, p as ElementKeys, r as GraphInstance, s as GraphStates, t as FitOptions, u as MountGraphOptions, v as GraphEvents, x as GraphTarget, y as GraphPointerEvent } from "./mount-graph-B88WGOQu.js";
1
+ import { A as ResolvedInteraction, B as View, C as NodeImage, D as NumberScale, E as NodeShape, F as SourceSubscription, I as StateStyle, L as StateStyles, M as ScalesOptions, N as SelectMode, O as NumberScaleType, P as SourceChange, R as Style, S as Mark, T as NodeOptions, _ as Key, a as Channel, b as LabelOptions, c as EdgeDash, d as FieldOf, f as FreeState, g as InteractionOptions, h as GraphDefinitionOptions, i as BuiltInState, j as ResolvedTransitions, k as Point, l as EdgeMark, m as GraphDefinition, n as Badge, o as ColorScale, p as GraphData, r as BadgeCorner, s as EdgeArrow, t as Accessor, u as EdgeOptions, v as KeyChannel, w as NodeMark, x as LiveSource, y as KeyFieldOf, z as TransitionOptions } from "./types-DJEdpHUo.js";
2
+ import { C as GraphTarget, S as GraphPositionEvent, T as PositionOrigin, _ as GraphEventHandler, a as GraphPositions, b as GraphFocusEvent, c as GraphStates, d as MountGraphOptions, f as ViewOptions, g as GraphDragEvent, h as ElementKeysInput, i as GraphInstance, l as GraphStore, m as ElementKeys, n as GraphElement, o as GraphSelection, p as mountGraph, r as GraphFocus, s as GraphState, t as FitOptions, u as GraphView, v as GraphEventName, w as GraphTargetEvent, x as GraphPointerEvent, y as GraphEvents } from "./mount-graph-Br5IAZbP.js";
3
3
  export declare function defineGraph<S extends string = never>(options: GraphDefinitionOptions<S>): GraphDefinition<S>;
4
4
  export declare function nodes<T>(data: LiveSource<T>, options?: NodeOptions<NoInfer<T>>): NodeMark<T>;
5
5
  export declare function nodes<T extends {
@@ -15,5 +15,5 @@ export declare function edges<T extends {
15
15
  export declare function edges<T>(data: Iterable<T>, options: EdgeOptions<NoInfer<T>> & {
16
16
  readonly key: KeyChannel<NoInfer<T>>;
17
17
  }): EdgeMark<T>;
18
- export { type Accessor, type Badge, type BadgeCorner, type BuiltInState, type Channel, type ColorScale, type EdgeArrow, type EdgeDash, type EdgeMark, type EdgeOptions, type ElementKeys, type ElementKeysInput, type FieldOf, type FitOptions, type FreeState, type GraphData, type GraphDefinition, type GraphDefinitionOptions, type GraphDragEvent, type GraphElement, type GraphEventHandler, type GraphEventName, type GraphEvents, type GraphInstance, type GraphPointerEvent, type GraphPositionEvent, type GraphPositions, type GraphSelection, type GraphState, type GraphStates, type GraphStore, type GraphTarget, type GraphTargetEvent, type GraphView, type InteractionOptions, type Key, type KeyChannel, type KeyFieldOf, type LabelOptions, type LiveSource, type Mark, type MountGraphOptions, type NodeMark, type NodeOptions, type NodeShape, type NumberScale, type NumberScaleType, type Point, type PositionOrigin, type ResolvedInteraction, type ResolvedTransitions, type ScalesOptions, type SelectMode, type SourceChange, type SourceSubscription, type StateStyle, type StateStyles, type Style, type TransitionOptions, type View, type ViewOptions, mountGraph };
18
+ export { type Accessor, type Badge, type BadgeCorner, type BuiltInState, type Channel, type ColorScale, type EdgeArrow, type EdgeDash, type EdgeMark, type EdgeOptions, type ElementKeys, type ElementKeysInput, type FieldOf, type FitOptions, type FreeState, type GraphData, type GraphDefinition, type GraphDefinitionOptions, type GraphDragEvent, type GraphElement, type GraphEventHandler, type GraphEventName, type GraphEvents, type GraphFocus, type GraphFocusEvent, type GraphInstance, type GraphPointerEvent, type GraphPositionEvent, type GraphPositions, type GraphSelection, type GraphState, type GraphStates, type GraphStore, type GraphTarget, type GraphTargetEvent, type GraphView, type InteractionOptions, type Key, type KeyChannel, type KeyFieldOf, type LabelOptions, type LiveSource, type Mark, type MountGraphOptions, type NodeImage, type NodeMark, type NodeOptions, type NodeShape, type NumberScale, type NumberScaleType, type Point, type PositionOrigin, type ResolvedInteraction, type ResolvedTransitions, type ScalesOptions, type SelectMode, type SourceChange, type SourceSubscription, type StateStyle, type StateStyles, type Style, type TransitionOptions, type View, type ViewOptions, mountGraph };
19
19
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as freeStateNames, r as maxFreeStates, t as mountGraph } from "./mount-graph-DYOgD_ql.js";
1
+ import { n as freeStateNames, r as maxFreeStates, t as mountGraph } from "./mount-graph-mObhwJ3e.js";
2
2
  // src/define-graph.ts
3
3
  const defaultZoomSpeed = 1;
4
4
  const defaultPositionTransition = 120;
@@ -1,4 +1,4 @@
1
- import { O as Point, _ as Key, f as FreeState, m as GraphDefinition, z as View } from "./types-D6b86Rt1.js";
1
+ import { B as View, _ as Key, f as FreeState, k as Point, m as GraphDefinition } from "./types-DJEdpHUo.js";
2
2
  import { ReadonlyStore } from "@tanstack/store";
3
3
  interface Endpoints {
4
4
  readonly source: Key;
@@ -40,6 +40,9 @@ interface GraphDragEvent {
40
40
  readonly world: Point;
41
41
  readonly originalEvent: PointerEvent;
42
42
  }
43
+ interface GraphFocusEvent {
44
+ readonly target: GraphTarget | null;
45
+ }
43
46
  type PositionOrigin = "drag" | "api";
44
47
  interface GraphPositionEvent {
45
48
  readonly origin: PositionOrigin;
@@ -56,6 +59,7 @@ interface GraphEvents {
56
59
  readonly dragend: GraphDragEvent;
57
60
  readonly positionchange: GraphPositionEvent;
58
61
  readonly selectionchange: ElementKeys;
62
+ readonly focuschange: GraphFocusEvent;
59
63
  readonly viewchange: {
60
64
  readonly view: View;
61
65
  };
@@ -67,6 +71,7 @@ interface GraphState<S extends string = string> {
67
71
  readonly width: number;
68
72
  readonly height: number;
69
73
  readonly hovered: GraphTarget | null;
74
+ readonly focused: GraphTarget | null;
70
75
  readonly selection: ElementKeys;
71
76
  readonly states: { readonly [K in FreeState<S>]: ElementKeys; };
72
77
  readonly positionsVersion: number;
@@ -95,6 +100,10 @@ interface GraphSelection {
95
100
  set(keys: ElementKeysInput): void;
96
101
  clear(): void;
97
102
  }
103
+ interface GraphFocus {
104
+ get(): GraphTarget | null;
105
+ set(element: GraphElement | null): void;
106
+ }
98
107
  interface GraphStates<N extends string = string> {
99
108
  set(name: N, keys: ElementKeysInput): void;
100
109
  add(name: N, keys: ElementKeysInput): void;
@@ -117,6 +126,7 @@ interface GraphInstance<S extends string = string> {
117
126
  readonly store: GraphStore<S>;
118
127
  readonly view: GraphView;
119
128
  readonly selection: GraphSelection;
129
+ readonly focus: GraphFocus;
120
130
  readonly states: GraphStates<FreeState<S>>;
121
131
  readonly positions: GraphPositions;
122
132
  readonly element: HTMLElement;
@@ -129,5 +139,5 @@ interface GraphInstance<S extends string = string> {
129
139
  destroy(): void;
130
140
  }
131
141
  declare function mountGraph<S extends string = string>(container: HTMLElement, options: MountGraphOptions<S>): GraphInstance<S>;
132
- export { PositionOrigin as C, GraphTargetEvent as S, GraphEventName as _, GraphSelection as a, GraphPositionEvent as b, GraphStore as c, ViewOptions as d, mountGraph as f, GraphEventHandler as g, GraphDragEvent as h, GraphPositions as i, GraphView as l, ElementKeysInput as m, GraphElement as n, GraphState as o, ElementKeys as p, GraphInstance as r, GraphStates as s, FitOptions as t, MountGraphOptions as u, GraphEvents as v, GraphTarget as x, GraphPointerEvent as y };
133
- //# sourceMappingURL=mount-graph-B88WGOQu.d.ts.map
142
+ export { GraphTarget as C, GraphPositionEvent as S, PositionOrigin as T, GraphEventHandler as _, GraphPositions as a, GraphFocusEvent as b, GraphStates as c, MountGraphOptions as d, ViewOptions as f, GraphDragEvent as g, ElementKeysInput as h, GraphInstance as i, GraphStore as l, ElementKeys as m, GraphElement as n, GraphSelection as o, mountGraph as p, GraphFocus as r, GraphState as s, FitOptions as t, GraphView as u, GraphEventName as v, GraphTargetEvent as w, GraphPointerEvent as x, GraphEvents as y };
143
+ //# sourceMappingURL=mount-graph-Br5IAZbP.d.ts.map