@g9tm/lynxcontrols-graph 2.11.10 → 2.11.12
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 +18 -1
- package/catalog/cards/G9GraphCanvas.md +1 -1
- package/catalog/catalog.json +235 -3
- package/catalog/index.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/canvas.d.ts +20 -1
- package/dist/canvas.d.ts.map +1 -1
- package/dist/canvas.jsx +206 -55
- package/dist/core.d.ts +47 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +27 -2
- package/dist/core.js.map +1 -1
- package/dist/core.jsx +27 -2
- package/dist/graph.css +35 -0
- package/dist/graph.css.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.jsx +1 -1
- package/dist/mt.d.ts +28 -3
- package/dist/mt.d.ts.map +1 -1
- package/dist/mt.jsx +73 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ const nodes: G9GraphNode[] = proxies.map((p) => ({
|
|
|
50
50
|
| --- | --- |
|
|
51
51
|
| Cards | `renderNode(node, state)` draws anything inside the node's box. `state` has `selected`, `focused`, `dragging`, `dropCandidate`, `dropOver` and `zoom`. A card re-renders only when its node or state changes. |
|
|
52
52
|
| Edges | SVG bezier curves from a source port (right side by default) to a target port (left side by default). Each edge can have a `label` (tap: `onEdgePress`), a `color`, a `width` and a `style`: `'solid'`, `'dashed'`, or `'active'` (dashed and moving; it stays still with reduced motion or `animateActive={false}`). |
|
|
53
|
-
| Lanes | `groups` are rects with an optional title, drawn behind the edges. |
|
|
53
|
+
| Lanes | `groups` are rects with an optional title, drawn behind the edges. Each can have its own tone: `titleColor`, `borderColor` and `accent` (a 2 px line along the top). |
|
|
54
54
|
| View | Drag empty space to pan. Two-finger and trackpad scrolls pan. The wheel and pinch zoom around the pointer. There are zoom-in, zoom-out and fit buttons (`controls`, `labels`). `view` + `onViewChange` make the view controlled, `defaultView` sets where it starts (default: fit). `minZoom` / `maxZoom` bound the zoom. `wheel: 'zoom' \| 'pan'` forces one wheel behaviour. |
|
|
55
55
|
| Drag | Nodes move on the main thread: no background render per frame, and the edges that touch moving nodes are redrawn there too. `snap` rounds to a grid. `onMove` reports live moves, `onMoveEnd` the final positions. A node with `draggable: false` stays put. |
|
|
56
56
|
| Selection | A tap selects. Shift or Ctrl/⌘ adds or removes. `selection` / `defaultSelection` / `onSelectionChange`. |
|
|
@@ -64,6 +64,22 @@ The chrome follows the reading direction: in RTL, the zoom buttons move to the b
|
|
|
64
64
|
mirror, since an app's positions are absolute. Ids are safe: `#Routes`, a node's element `#Routes__n_<id>`, the
|
|
65
65
|
buttons `#Routes_ZoomIn`, `#Routes_ZoomOut`, `#Routes_Fit`.
|
|
66
66
|
|
|
67
|
+
### The look (2.11.12)
|
|
68
|
+
|
|
69
|
+
| Prop | What it draws |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| `G9GraphEdge.glow` | A translucent under-stroke in the edge's colour (alpha 0.25), `glow` px wider on each side. |
|
|
72
|
+
| `G9GraphEdge.colorTo` | A gradient from `color` at the source end to `colorTo` at the target end. |
|
|
73
|
+
| `G9GraphEdge.flow`, `flowSpeed` | What moves along an `'active'` edge: `'dashes'` (default) or `'beads'` (round dots riding a quieter line), at `flowSpeed` world px a second (default 24; tie it to the traffic). |
|
|
74
|
+
| `G9GraphEdge.ends` | Small port dots at both ends (the target's in `colorTo`). |
|
|
75
|
+
| `edgeLabels`, `G9GraphEdge.labelMode` | `'always'` (default), `'hover'` (while the mouse is within 8 px of the curve, or one of the edge's nodes is selected) or `'none'`. Labels are drawn above the cards. |
|
|
76
|
+
| `background` | `{ kind: 'dots' | 'grid', gap, color, size? }`: one pattern behind the world that pans and zooms with the view (a tile under 8 px doubles, so a far zoom stays calm). |
|
|
77
|
+
| `nodeEnter` | `'added'` fades a card in from 94 % the first time it appears after the first render; `'all'` the first cards too. Off with reduced motion. |
|
|
78
|
+
| `draggingClassName` | The app's class on a dragged card, beside `g9-graph__node--dragging` (a lift shadow by default). |
|
|
79
|
+
|
|
80
|
+
Animation costs no render: on the web host the active edges move by SMIL inside their one SVG (the browser runs it);
|
|
81
|
+
on Android, iOS and Lynxtron a 33 ms timer redraws that SVG on the main thread. Everything else is drawn once.
|
|
82
|
+
|
|
67
83
|
### Positions
|
|
68
84
|
|
|
69
85
|
The app owns positions. `onMoveEnd` reports them, and the app writes them back to `nodes`. To place a new graph,
|
|
@@ -76,6 +92,7 @@ the edge that closes them.
|
|
|
76
92
|
The canvas uses the same core functions an app or a host can call:
|
|
77
93
|
- `toWorld` / `toScreen`, `zoomAt`, `panBy`, `fitView`, `visibleWorld`;
|
|
78
94
|
- `portPoint`, `edgeCurve`, `edgePathData`, `bezierPoint`, `edgeGeometry`, `cullGraph`, `contentBounds`;
|
|
95
|
+
- `edgeSvg` (one edge's markup with its look), `flowPeriod`, `graphBackgroundStyle`;
|
|
79
96
|
- `snapTo`, `nodeAt`, `nextSelection`, `nodeInDirection`, `clampZoom`, `intersects`, `layeredLayout`.
|
|
80
97
|
|
|
81
98
|
## Hosts
|
|
@@ -7,11 +7,11 @@ A node graph editor: app-drawn cards at app-given positions, edges between their
|
|
|
7
7
|
Props:
|
|
8
8
|
- `nodes`: G9GraphNode[]
|
|
9
9
|
- `renderNode`: (node, state) => ReactNode
|
|
10
|
+
- `nodeEnter?`: 'none' | 'all' | 'added' = "none"
|
|
10
11
|
- `onActivate?`: (id: string) => void
|
|
11
12
|
- `onContextMenu?`: (event: G9GraphContextMenuEvent) => void
|
|
12
13
|
- `onDelete?`: (ids: string[]) => void
|
|
13
14
|
- `onDrop?`: (event: G9GraphDropEvent) => void
|
|
14
15
|
- `onEdgePress?`: (id: string) => void
|
|
15
|
-
- `onMove?`: (id: string, x: number, y: number) => void
|
|
16
16
|
|
|
17
17
|
Example: `<G9GraphCanvas nodes={nodes} renderNode={renderNode} />`
|
package/catalog/catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"catalogVersion": 1,
|
|
3
3
|
"package": "@g9tm/lynxcontrols-graph",
|
|
4
|
-
"version": "2.11.
|
|
4
|
+
"version": "2.11.12",
|
|
5
5
|
"generatedBy": "node scripts/check-docs.mjs --write",
|
|
6
6
|
"components": [
|
|
7
7
|
{
|
|
@@ -24,6 +24,54 @@
|
|
|
24
24
|
"role": "behaviour",
|
|
25
25
|
"doc": "Active edges' dashes move (off with reduced motion). Default true."
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
"name": "background",
|
|
29
|
+
"type": {
|
|
30
|
+
"kind": "object",
|
|
31
|
+
"fields": [
|
|
32
|
+
{
|
|
33
|
+
"name": "kind",
|
|
34
|
+
"required": true,
|
|
35
|
+
"type": {
|
|
36
|
+
"kind": "enum",
|
|
37
|
+
"values": [
|
|
38
|
+
"grid",
|
|
39
|
+
"dots"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"serializable": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "gap",
|
|
46
|
+
"required": true,
|
|
47
|
+
"type": {
|
|
48
|
+
"kind": "number"
|
|
49
|
+
},
|
|
50
|
+
"serializable": true
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "color",
|
|
54
|
+
"required": true,
|
|
55
|
+
"type": {
|
|
56
|
+
"kind": "color"
|
|
57
|
+
},
|
|
58
|
+
"serializable": true
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "size",
|
|
62
|
+
"required": false,
|
|
63
|
+
"type": {
|
|
64
|
+
"kind": "number"
|
|
65
|
+
},
|
|
66
|
+
"serializable": true
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"required": false,
|
|
71
|
+
"serializable": true,
|
|
72
|
+
"role": "behaviour",
|
|
73
|
+
"doc": "A dot or grid pattern behind the graph in world space (2.11.12): it pans and zooms with the view."
|
|
74
|
+
},
|
|
27
75
|
{
|
|
28
76
|
"name": "className",
|
|
29
77
|
"type": {
|
|
@@ -113,6 +161,31 @@
|
|
|
113
161
|
"serializable": true,
|
|
114
162
|
"role": "behaviour"
|
|
115
163
|
},
|
|
164
|
+
{
|
|
165
|
+
"name": "draggingClassName",
|
|
166
|
+
"type": {
|
|
167
|
+
"kind": "string"
|
|
168
|
+
},
|
|
169
|
+
"required": false,
|
|
170
|
+
"serializable": true,
|
|
171
|
+
"role": "behaviour",
|
|
172
|
+
"doc": "A class of the app's own on a card while it is dragged (2.11.12), beside `g9-graph__node--dragging` (a lift shadow)."
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"name": "edgeLabels",
|
|
176
|
+
"type": {
|
|
177
|
+
"kind": "enum",
|
|
178
|
+
"values": [
|
|
179
|
+
"none",
|
|
180
|
+
"hover",
|
|
181
|
+
"always"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"serializable": true,
|
|
186
|
+
"role": "behaviour",
|
|
187
|
+
"doc": "When edge labels show (2.11.12): `'always'` (default), `'hover'` (while the pointer is near the edge, or one of its nodes is selected) or `'none'`; an edge's own `labelMode` wins. Labels are drawn above the cards."
|
|
188
|
+
},
|
|
116
189
|
{
|
|
117
190
|
"name": "edges",
|
|
118
191
|
"type": {
|
|
@@ -182,6 +255,63 @@
|
|
|
182
255
|
"kind": "number"
|
|
183
256
|
},
|
|
184
257
|
"serializable": true
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"name": "glow",
|
|
261
|
+
"required": false,
|
|
262
|
+
"type": {
|
|
263
|
+
"kind": "number"
|
|
264
|
+
},
|
|
265
|
+
"serializable": true
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"name": "colorTo",
|
|
269
|
+
"required": false,
|
|
270
|
+
"type": {
|
|
271
|
+
"kind": "string"
|
|
272
|
+
},
|
|
273
|
+
"serializable": true
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "flow",
|
|
277
|
+
"required": false,
|
|
278
|
+
"type": {
|
|
279
|
+
"kind": "enum",
|
|
280
|
+
"values": [
|
|
281
|
+
"dashes",
|
|
282
|
+
"beads"
|
|
283
|
+
]
|
|
284
|
+
},
|
|
285
|
+
"serializable": true
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "flowSpeed",
|
|
289
|
+
"required": false,
|
|
290
|
+
"type": {
|
|
291
|
+
"kind": "number"
|
|
292
|
+
},
|
|
293
|
+
"serializable": true
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"name": "ends",
|
|
297
|
+
"required": false,
|
|
298
|
+
"type": {
|
|
299
|
+
"kind": "boolean"
|
|
300
|
+
},
|
|
301
|
+
"serializable": true
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"name": "labelMode",
|
|
305
|
+
"required": false,
|
|
306
|
+
"type": {
|
|
307
|
+
"kind": "enum",
|
|
308
|
+
"values": [
|
|
309
|
+
"none",
|
|
310
|
+
"hover",
|
|
311
|
+
"always"
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
"serializable": true
|
|
185
315
|
}
|
|
186
316
|
]
|
|
187
317
|
}
|
|
@@ -252,6 +382,30 @@
|
|
|
252
382
|
"kind": "color"
|
|
253
383
|
},
|
|
254
384
|
"serializable": true
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"name": "titleColor",
|
|
388
|
+
"required": false,
|
|
389
|
+
"type": {
|
|
390
|
+
"kind": "color"
|
|
391
|
+
},
|
|
392
|
+
"serializable": true
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "borderColor",
|
|
396
|
+
"required": false,
|
|
397
|
+
"type": {
|
|
398
|
+
"kind": "color"
|
|
399
|
+
},
|
|
400
|
+
"serializable": true
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"name": "accent",
|
|
404
|
+
"required": false,
|
|
405
|
+
"type": {
|
|
406
|
+
"kind": "string"
|
|
407
|
+
},
|
|
408
|
+
"serializable": true
|
|
255
409
|
}
|
|
256
410
|
]
|
|
257
411
|
}
|
|
@@ -415,6 +569,22 @@
|
|
|
415
569
|
"role": "behaviour",
|
|
416
570
|
"doc": "Default 0.1 and 2.5."
|
|
417
571
|
},
|
|
572
|
+
{
|
|
573
|
+
"name": "nodeEnter",
|
|
574
|
+
"type": {
|
|
575
|
+
"kind": "enum",
|
|
576
|
+
"values": [
|
|
577
|
+
"none",
|
|
578
|
+
"all",
|
|
579
|
+
"added"
|
|
580
|
+
]
|
|
581
|
+
},
|
|
582
|
+
"required": false,
|
|
583
|
+
"default": "none",
|
|
584
|
+
"serializable": true,
|
|
585
|
+
"role": "behaviour",
|
|
586
|
+
"doc": "A card fades in from 94 % when it first appears (2.11.12): `'added'` the nodes added after the first render, `'all'` the first ones too. Off with reduced motion. Default `'none'`."
|
|
587
|
+
},
|
|
418
588
|
{
|
|
419
589
|
"name": "nodes",
|
|
420
590
|
"type": {
|
|
@@ -621,10 +791,16 @@
|
|
|
621
791
|
"doc": "What the mouse wheel does: `'auto'` (default) zooms with a wheel and pans with a two-finger trackpad scroll (a horizontal delta or small steps), `'zoom'` always zooms, `'pan'` always pans."
|
|
622
792
|
}
|
|
623
793
|
],
|
|
624
|
-
"anchor":
|
|
794
|
+
"anchor": {
|
|
795
|
+
"kind": "button",
|
|
796
|
+
"capabilities": [
|
|
797
|
+
"activate"
|
|
798
|
+
]
|
|
799
|
+
},
|
|
625
800
|
"accessibility": {
|
|
626
801
|
"labelFrom": [],
|
|
627
|
-
"labelRequired":
|
|
802
|
+
"labelRequired": true,
|
|
803
|
+
"minTarget": 44
|
|
628
804
|
},
|
|
629
805
|
"targets": {
|
|
630
806
|
"android": "pending",
|
|
@@ -713,6 +889,14 @@
|
|
|
713
889
|
"signature": "(a: G9GraphPoint, b: G9GraphPoint, c1: G9GraphPoint, c2: G9GraphPoint): string",
|
|
714
890
|
"summary": "The SVG path data of an edge's bezier."
|
|
715
891
|
},
|
|
892
|
+
{
|
|
893
|
+
"id": "graph.core.edgeSvg",
|
|
894
|
+
"export": "edgeSvg",
|
|
895
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
896
|
+
"kind": "function",
|
|
897
|
+
"signature": "(d: string, ax: number, ay: number, bx: number, by: number, color: string, colorTo: string, width: number, glow: number, dash: number, beads: boolean, ends: boolean, gid: string, offset: number, animSeconds: number): string",
|
|
898
|
+
"summary": "One edge's SVG (2.11.12): the glow under it, the stroke (a gradient with `colorTo`), the dashes or beads of an active edge at `offset`, moving by SMIL when `animSeconds` > 0 (the web host animates them in the browser), and the end dots. `dash`: 0 solid, 1 dashed, 2 active. Its twin `edgeSvgMT` (mt.ts) draws a dragged node's edges."
|
|
899
|
+
},
|
|
716
900
|
{
|
|
717
901
|
"id": "graph.core.fitView",
|
|
718
902
|
"export": "fitView",
|
|
@@ -721,6 +905,22 @@
|
|
|
721
905
|
"signature": "(bounds: G9GraphRect | null, width: number, height: number, options?: { readonly padding?: number; readonly minZoom?: number; readonly maxZoom?: number; }): G9GraphView",
|
|
722
906
|
"summary": "The view that shows `bounds` whole inside a viewport of `width` × `height`, centred, with `padding` (screen px)."
|
|
723
907
|
},
|
|
908
|
+
{
|
|
909
|
+
"id": "graph.core.flowPeriod",
|
|
910
|
+
"export": "flowPeriod",
|
|
911
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
912
|
+
"kind": "function",
|
|
913
|
+
"signature": "(beads: boolean): number",
|
|
914
|
+
"summary": "The repeat of an active edge's pattern: dashes (6 + 4) or beads (one each 14 px)."
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
"id": "graph.core.G9_GRAPH_FLOW_SPEED",
|
|
918
|
+
"export": "G9_GRAPH_FLOW_SPEED",
|
|
919
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
920
|
+
"kind": "constant",
|
|
921
|
+
"signature": "24",
|
|
922
|
+
"summary": "The default speed of an active edge's flow, in world px a second (2.11.12)."
|
|
923
|
+
},
|
|
724
924
|
{
|
|
725
925
|
"id": "graph.core.G9_GRAPH_IDENTITY",
|
|
726
926
|
"export": "G9_GRAPH_IDENTITY",
|
|
@@ -737,6 +937,14 @@
|
|
|
737
937
|
"signature": "G9EdgeGeometry",
|
|
738
938
|
"summary": "An edge laid out: its path, label point and bounding rect, or null when an end's node is missing."
|
|
739
939
|
},
|
|
940
|
+
{
|
|
941
|
+
"id": "graph.core.G9GraphBackground",
|
|
942
|
+
"export": "G9GraphBackground",
|
|
943
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
944
|
+
"kind": "interface",
|
|
945
|
+
"signature": "G9GraphBackground",
|
|
946
|
+
"summary": "A pattern behind the graph in world space (2.11.12): it pans and zooms with the view."
|
|
947
|
+
},
|
|
740
948
|
{
|
|
741
949
|
"id": "graph.graph.G9GraphCanvasHandle",
|
|
742
950
|
"export": "G9GraphCanvasHandle",
|
|
@@ -785,6 +993,14 @@
|
|
|
785
993
|
"signature": "G9GraphEdge",
|
|
786
994
|
"summary": "An edge between two node ports."
|
|
787
995
|
},
|
|
996
|
+
{
|
|
997
|
+
"id": "graph.core.G9GraphEdgeFlow",
|
|
998
|
+
"export": "G9GraphEdgeFlow",
|
|
999
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
1000
|
+
"kind": "type",
|
|
1001
|
+
"signature": "G9GraphEdgeFlow",
|
|
1002
|
+
"summary": "What moves along an active edge (2.11.12): dashes, or small round beads."
|
|
1003
|
+
},
|
|
788
1004
|
{
|
|
789
1005
|
"id": "graph.core.G9GraphEdgeStyle",
|
|
790
1006
|
"export": "G9GraphEdgeStyle",
|
|
@@ -809,6 +1025,14 @@
|
|
|
809
1025
|
"signature": "G9GraphGroup",
|
|
810
1026
|
"summary": "A titled background area (a lane, a pillar) at an app-given rect."
|
|
811
1027
|
},
|
|
1028
|
+
{
|
|
1029
|
+
"id": "graph.core.G9GraphLabelMode",
|
|
1030
|
+
"export": "G9GraphLabelMode",
|
|
1031
|
+
"from": "@g9tm/lynxcontrols-graph/core",
|
|
1032
|
+
"kind": "type",
|
|
1033
|
+
"signature": "G9GraphLabelMode",
|
|
1034
|
+
"summary": "When an edge's label shows (2.11.12): never, while the pointer is near the edge, or always."
|
|
1035
|
+
},
|
|
812
1036
|
{
|
|
813
1037
|
"id": "graph.graph.G9GraphLabels",
|
|
814
1038
|
"export": "G9GraphLabels",
|
|
@@ -881,6 +1105,14 @@
|
|
|
881
1105
|
"signature": "G9LayeredLayoutOptions",
|
|
882
1106
|
"summary": "Options of `layeredLayout`."
|
|
883
1107
|
},
|
|
1108
|
+
{
|
|
1109
|
+
"id": "graph.graph.graphBackgroundStyle",
|
|
1110
|
+
"export": "graphBackgroundStyle",
|
|
1111
|
+
"from": "@g9tm/lynxcontrols-graph",
|
|
1112
|
+
"kind": "function",
|
|
1113
|
+
"signature": "(b: G9GraphBackground, view: G9GraphView): Record<string, string>",
|
|
1114
|
+
"summary": "The background pattern's style at a view (2.11.12): one tile of `gap × zoom` screen px (doubled while under 8, so a far zoom stays calm), placed with the pan. The main thread keeps size and position in step (applyViewMT)."
|
|
1115
|
+
},
|
|
884
1116
|
{
|
|
885
1117
|
"id": "graph.core.intersects",
|
|
886
1118
|
"export": "intersects",
|
package/catalog/index.md
CHANGED