@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/dist/canvas.jsx CHANGED
@@ -1,12 +1,12 @@
1
- import { measureNode } from "@g9tm/lynxcontrols/anchor";
2
- import { g9SafeId, startTimer, stopTimer } from "@g9tm/lynxcontrols/base";
1
+ import { measureNode, useG9Anchor } from "@g9tm/lynxcontrols/anchor";
2
+ import { g9OnWebHost, g9SafeId, startTimer, stopTimer } from "@g9tm/lynxcontrols/base";
3
3
  import { g9HeldModifiers, useG9Keys } from "@g9tm/lynxcontrols/commands";
4
4
  import { registerG9DropTarget, useG9DragState } from "@g9tm/lynxcontrols/pointer";
5
5
  import { useG9Direction, useG9Theme } from "@g9tm/lynxcontrols/provider";
6
6
  import { g9MotionScale, isContextMenuKey } from "@g9tm/lynxcontrols-foundation";
7
7
  import { memo, runOnBackground, runOnMainThread, useEffect, useMainThreadRef, useMemo, useRef, useState } from "@lynx-js/react";
8
- import { contentBounds, cullGraph, edgeGeometry, fitView, nextSelection, nodeAt, nodeInDirection, portPoint, snapTo, toScreen, toWorld, visibleWorld, zoomAt } from "./core.jsx";
9
- import { edgeOfTargetMT, liveEdgesSvgMT, nodeIndexAtMT, snapMT, zoomAtMT } from "./mt.jsx";
8
+ import { G9_GRAPH_FLOW_SPEED, contentBounds, cullGraph, edgeGeometry, edgeSvg, fitView, flowPeriod, nextSelection, nodeAt, nodeInDirection, portPoint, snapTo, toScreen, toWorld, visibleWorld, zoomAt } from "./core.jsx";
9
+ import { edgeNearMT, edgeOfTargetMT, edgeSvgMT, liveEdgesSvgMT, nodeIndexAtMT, snapMT, zoomAtMT } from "./mt.jsx";
10
10
  import "./graph.css";
11
11
  const IDLE_DRAG = {
12
12
  mode: 0,
@@ -31,7 +31,7 @@ const sameView = (a, b)=>Math.abs(a.zoom - b.zoom) < 1e-6 && Math.abs(a.x - b.x)
31
31
  const sameState = (a, b)=>a.selected === b.selected && a.focused === b.focused && a.dragging === b.dragging && a.dropCandidate === b.dropCandidate && a.dropOver === b.dropOver && a.zoom === b.zoom;
32
32
  const Card = memo(function(props) {
33
33
  const { node, state } = props;
34
- const cls = `g9-graph__node${state.selected ? ' g9-graph__node--selected' : ''}${state.focused ? ' g9-graph__node--focused' : ''}${state.selected && state.focused ? ' g9-graph__node--selfocus' : ''}${state.dragging ? ' g9-graph__node--dragging' : ''}${state.dropCandidate ? ' g9-graph__node--candidate' : ''}${state.dropOver ? ' g9-graph__node--over' : ''}`;
34
+ const cls = `g9-graph__node${state.selected ? ' g9-graph__node--selected' : ''}${state.focused ? ' g9-graph__node--focused' : ''}${state.selected && state.focused ? ' g9-graph__node--selfocus' : ''}${state.dragging ? ' g9-graph__node--dragging' : ''}${state.dropCandidate ? ' g9-graph__node--candidate' : ''}${state.dropOver ? ' g9-graph__node--over' : ''}${props.enter ? ' g9-graph__node--enter' : ''}${state.dragging && props.dragClass ? ` ${props.dragClass}` : ''}`;
35
35
  return <view id={props.elementId} className={cls} style={{
36
36
  left: `${node.x}px`,
37
37
  top: `${node.y}px`,
@@ -40,18 +40,20 @@ const Card = memo(function(props) {
40
40
  }} accessibility-element={false}>
41
41
  {props.render(node, state)}
42
42
  </view>;
43
- }, (a, b)=>a.node === b.node && a.render === b.render && a.elementId === b.elementId && sameState(a.state, b.state));
43
+ }, (a, b)=>a.node === b.node && a.render === b.render && a.elementId === b.elementId && a.enter === b.enter && a.dragClass === b.dragClass && sameState(a.state, b.state));
44
44
  function svgOf(paths, box) {
45
45
  const r = (v)=>Math.round(10 * v) / 10;
46
46
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${r(box.x)} ${r(box.y)} ${r(box.width)} ${r(box.height)}" width="${r(box.width)}" height="${r(box.height)}">${paths}</svg>`;
47
47
  }
48
- function pathsOf(list, color, offset) {
48
+ const dashOf = (e)=>'active' === e.style ? 2 : 'dashed' === e.style ? 1 : 0;
49
+ const speedOf = (e)=>void 0 !== e.flowSpeed && e.flowSpeed > 0 ? e.flowSpeed : G9_GRAPH_FLOW_SPEED;
50
+ function pathsOf(list, color, animate) {
49
51
  let out = '';
50
- for (const { g, edge } of list){
51
- var _edge_width;
52
- const dashed = 'dashed' === edge.style || 'active' === edge.style;
53
- out += `<path d="${g.d}" fill="none" stroke="${color(edge)}" stroke-width="${null != (_edge_width = edge.width) ? _edge_width : 1.5}"${dashed ? ` stroke-dasharray="6 4"${offset ? ` stroke-dashoffset="${offset}"` : ''}` : ''}/>`;
54
- }
52
+ list.forEach(({ g, edge }, i)=>{
53
+ var _edge_colorTo, _edge_width, _edge_glow;
54
+ const beads = 'beads' === edge.flow;
55
+ out += edgeSvg(g.d, g.from.x, g.from.y, g.to.x, g.to.y, color(edge), null != (_edge_colorTo = edge.colorTo) ? _edge_colorTo : '', null != (_edge_width = edge.width) ? _edge_width : 1.5, null != (_edge_glow = edge.glow) ? _edge_glow : 0, dashOf(edge), beads, true === edge.ends, `g9g${i}`, 0, animate && 'active' === edge.style ? flowPeriod(beads) / speedOf(edge) : 0);
56
+ });
55
57
  return out;
56
58
  }
57
59
  function boxOf(list) {
@@ -59,11 +61,13 @@ function boxOf(list) {
59
61
  let y0 = 1 / 0;
60
62
  let x1 = -1 / 0;
61
63
  let y1 = -1 / 0;
62
- for (const { g } of list){
63
- x0 = Math.min(x0, g.box.x - 4);
64
- y0 = Math.min(y0, g.box.y - 4);
65
- x1 = Math.max(x1, g.box.x + g.box.width + 4);
66
- y1 = Math.max(y1, g.box.y + g.box.height + 4);
64
+ for (const { g, edge } of list){
65
+ var _edge_glow, _edge_width;
66
+ const pad = 4 + Math.max(null != (_edge_glow = edge.glow) ? _edge_glow : 0, (null != (_edge_width = edge.width) ? _edge_width : 1.5) * 1.5, edge.ends ? 3 : 0);
67
+ x0 = Math.min(x0, g.box.x - pad);
68
+ y0 = Math.min(y0, g.box.y - pad);
69
+ x1 = Math.max(x1, g.box.x + g.box.width + pad);
70
+ y1 = Math.max(y1, g.box.y + g.box.height + pad);
67
71
  }
68
72
  return {
69
73
  x: x0,
@@ -73,36 +77,100 @@ function boxOf(list) {
73
77
  };
74
78
  }
75
79
  function ActiveEdges(props) {
76
- const [phase, setPhase] = useState(0);
80
+ const web = g9OnWebHost();
81
+ const el = useMainThreadRef(null);
82
+ const args = useMainThreadRef([]);
83
+ const box = props.list.length ? boxOf(props.list) : null;
84
+ const content = box ? svgOf(pathsOf(props.list, props.color, web && props.animate), box) : '';
85
+ const timed = !web && props.animate && props.list.length > 0;
86
+ function setArgsMT(next) {
87
+ 'main thread';
88
+ args.current = next;
89
+ }
90
+ function tickMT(ms, bx, by, bw, bh) {
91
+ 'main thread';
92
+ var _el_current;
93
+ let paths = '';
94
+ const list = args.current;
95
+ for(let i = 0; i < list.length; i++){
96
+ const a = list[i];
97
+ const period = 1 === a[9] ? 14 : 10;
98
+ const offset = -(ms / 1000 * a[11] % period);
99
+ paths += edgeSvgMT(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], 2, 1 === a[9], 1 === a[10], `g9a${i}`, offset, 0);
100
+ }
101
+ const r = (v)=>Math.round(10 * v) / 10;
102
+ null == (_el_current = el.current) || _el_current.setAttribute('content', `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${r(bx)} ${r(by)} ${r(bw)} ${r(bh)}" width="${r(bw)}" height="${r(bh)}">${paths}</svg>`);
103
+ }
77
104
  useEffect(()=>{
78
- if (!props.animate || 0 === props.list.length) return;
105
+ if (!timed || !box) return;
106
+ const next = props.list.map(({ g, edge })=>{
107
+ var _edge_colorTo, _edge_width, _edge_glow;
108
+ return [
109
+ g.d,
110
+ g.from.x,
111
+ g.from.y,
112
+ g.to.x,
113
+ g.to.y,
114
+ props.color(edge),
115
+ null != (_edge_colorTo = edge.colorTo) ? _edge_colorTo : '',
116
+ null != (_edge_width = edge.width) ? _edge_width : 1.5,
117
+ null != (_edge_glow = edge.glow) ? _edge_glow : 0,
118
+ 'beads' === edge.flow ? 1 : 0,
119
+ true === edge.ends ? 1 : 0,
120
+ speedOf(edge)
121
+ ];
122
+ });
123
+ runOnMainThread(setArgsMT)(next);
124
+ const t0 = Date.now();
79
125
  let handle = null;
80
126
  const tick = ()=>{
81
- setPhase((p)=>(p + 1) % 5);
82
- handle = startTimer(tick, 90);
127
+ runOnMainThread(tickMT)(Date.now() - t0, box.x, box.y, box.width, box.height);
128
+ handle = startTimer(tick, 33);
83
129
  };
84
- handle = startTimer(tick, 90);
130
+ handle = startTimer(tick, 33);
85
131
  return ()=>stopTimer(handle);
86
132
  }, [
87
- props.animate,
88
- props.list.length
133
+ content,
134
+ timed
89
135
  ]);
90
- if (0 === props.list.length) return null;
91
- const box = boxOf(props.list);
92
- return <svg className="g9-graph__edges g9-graph__edges--active" content={svgOf(pathsOf(props.list, props.color, 2 * -phase), box)} style={{
136
+ if (!box) return null;
137
+ return <svg className="g9-graph__edges g9-graph__edges--active" main-thread:ref={el} content={content} style={{
93
138
  left: `${box.x}px`,
94
139
  top: `${box.y}px`,
95
140
  width: `${box.width}px`,
96
141
  height: `${box.height}px`
97
142
  }}/>;
98
143
  }
144
+ function graphBackgroundStyle(b, view1) {
145
+ var _b_size;
146
+ let tile = b.gap * view1.zoom;
147
+ if (!(tile > 0)) return {};
148
+ while(tile < 8)tile *= 2;
149
+ const s = null != (_b_size = b.size) ? _b_size : 1;
150
+ const image = 'dots' === b.kind ? `radial-gradient(circle, ${b.color} ${s}px, transparent ${s + 0.5}px)` : `linear-gradient(to right, ${b.color} ${s}px, transparent ${s}px), linear-gradient(to bottom, ${b.color} ${s}px, transparent ${s}px)`;
151
+ return {
152
+ backgroundImage: image,
153
+ backgroundSize: `${tile}px ${tile}px`,
154
+ backgroundPosition: `${view1.x % tile}px ${view1.y % tile}px`
155
+ };
156
+ }
157
+ const backgroundStyle = graphBackgroundStyle;
99
158
  const ICONS = {
100
159
  plus: 'M12 5v14M5 12h14',
101
160
  minus: 'M5 12h14',
102
161
  fit: 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5'
103
162
  };
104
163
  function ChromeButton(props) {
105
- return <view id={props.id} className="g9-graph__button" bindtap={props.onPress} accessibility-element={true} accessibility-traits="button" accessibility-label={props.label}>
164
+ const anchor = useG9Anchor(props.anchorId, {
165
+ kind: 'button',
166
+ label: ()=>props.label,
167
+ capabilities: {
168
+ activate: ()=>props.onPress()
169
+ }
170
+ }, {
171
+ domId: props.id
172
+ });
173
+ return <view {...anchor.props} className="g9-graph__button" bindtap={props.onPress} accessibility-element={true} accessibility-traits="button" accessibility-label={props.label}>
106
174
  <svg className="g9-graph__icon" content={`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18"><path d="${ICONS[props.icon]}" fill="none" stroke="${props.color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`}/>
107
175
  </view>;
108
176
  }
@@ -122,7 +190,7 @@ const pagePoint = (e)=>{
122
190
  return null;
123
191
  };
124
192
  function G9GraphCanvas(props) {
125
- var _props_minZoom, _props_maxZoom, _props_curvature, _props_edges, _props_groups, _props_defaultView, _ref, _props_view, _props_defaultSelection, _props_selection, _props_keyboard, _props_cullMargin, _props_labels, _labels_zoomIn, _labels_zoomOut, _labels_fit;
193
+ var _props_minZoom, _props_maxZoom, _props_curvature, _props_edges, _props_groups, _props_defaultView, _ref, _props_view, _props_defaultSelection, _props_selection, _props_keyboard, _props_cullMargin, _props_labels, _props_nodeEnter, _props_id, _labels_zoomIn, _props_id1, _labels_zoomOut, _props_id2, _labels_fit;
126
194
  var _props_view1, _props_view2, _props_view3;
127
195
  const theme = useG9Theme();
128
196
  const rtl = 'rtl' === useG9Direction();
@@ -166,6 +234,8 @@ function G9GraphCanvas(props) {
166
234
  0,
167
235
  0
168
236
  ]);
237
+ const bg = useMainThreadRef(null);
238
+ const bgGap = useMainThreadRef(0);
169
239
  function applyViewMT(z, x, y) {
170
240
  'main thread';
171
241
  var _world_current;
@@ -175,6 +245,15 @@ function G9GraphCanvas(props) {
175
245
  y
176
246
  ];
177
247
  null == (_world_current = world.current) || _world_current.setStyleProperty('transform', `translate(${x}px, ${y}px) scale(${z})`);
248
+ const gap = bgGap.current;
249
+ if (gap > 0 && z > 0 && bg.current) {
250
+ let tile = gap * z;
251
+ while(tile < 8)tile *= 2;
252
+ bg.current.setStyleProperties({
253
+ 'background-size': `${tile}px ${tile}px`,
254
+ 'background-position': `${x % tile}px ${y % tile}px`
255
+ });
256
+ }
178
257
  }
179
258
  const fromMain = (z, x, y)=>{
180
259
  var _latest_current_onViewChange, _latest_current;
@@ -209,6 +288,18 @@ function G9GraphCanvas(props) {
209
288
  null == (_props_view2 = props.view) ? void 0 : _props_view2.x,
210
289
  null == (_props_view3 = props.view) ? void 0 : _props_view3.y
211
290
  ]);
291
+ const bgStep = props.background && props.background.gap > 0 ? props.background.gap : 0;
292
+ function setBgGapMT(gap) {
293
+ 'main thread';
294
+ bgGap.current = gap;
295
+ const v = viewMT.current;
296
+ applyViewMT(v[0], v[1], v[2]);
297
+ }
298
+ useEffect(()=>{
299
+ runOnMainThread(setBgGapMT)(bgStep);
300
+ }, [
301
+ bgStep
302
+ ]);
212
303
  const bounds = useMemo(()=>contentBounds(props.nodes, groups), [
213
304
  props.nodes,
214
305
  groups
@@ -286,6 +377,7 @@ function G9GraphCanvas(props) {
286
377
  null == (_latest_current_onSelectionChange = (_latest_current = latest.current).onSelectionChange) || _latest_current_onSelectionChange.call(_latest_current, next);
287
378
  };
288
379
  const [focus, setFocus] = useState(null);
380
+ const [hoverEdge, setHoverEdge] = useState(null);
289
381
  const [active, setActive] = useState(false);
290
382
  const keyboard = null != (_props_keyboard = props.keyboard) ? _props_keyboard : 'auto';
291
383
  const byId = useMemo(()=>new Map(props.nodes.map((n)=>[
@@ -315,6 +407,10 @@ function G9GraphCanvas(props) {
315
407
  var _e_color;
316
408
  return null != (_e_color = e.color) ? _e_color : 'active' === e.style ? primary : outline;
317
409
  };
410
+ const labelModeOf = (e)=>{
411
+ var _ref, _e_labelMode;
412
+ return null != (_ref = null != (_e_labelMode = e.labelMode) ? _e_labelMode : props.edgeLabels) ? _ref : 'always';
413
+ };
318
414
  useEffect(()=>{
319
415
  var _props_snap;
320
416
  const nodes = props.nodes.map((n)=>[
@@ -327,7 +423,7 @@ function G9GraphCanvas(props) {
327
423
  ]);
328
424
  const mtEdges = [];
329
425
  for (const e of edges){
330
- var _ref, _ref1, _e_width;
426
+ var _ref, _ref1, _e_width, _e_glow, _e_colorTo;
331
427
  var _a_ports_find, _a_ports, _b_ports_find, _b_ports;
332
428
  const a = byId.get(e.from.node);
333
429
  const b = byId.get(e.to.node);
@@ -348,7 +444,11 @@ function G9GraphCanvas(props) {
348
444
  'right' === sb ? 1 : -1,
349
445
  strokeOf(e),
350
446
  null != (_e_width = e.width) ? _e_width : 1.5,
351
- 'dashed' === e.style ? 1 : 'active' === e.style ? 2 : 0
447
+ dashOf(e),
448
+ null != (_e_glow = e.glow) ? _e_glow : 0,
449
+ null != (_e_colorTo = e.colorTo) ? _e_colorTo : '',
450
+ (e.ends ? 1 : 0) | ('beads' === e.flow ? 2 : 0) | (e.label && 'hover' === labelModeOf(e) ? 4 : 0),
451
+ speedOf(e)
352
452
  ]);
353
453
  }
354
454
  const next = {
@@ -378,7 +478,8 @@ function G9GraphCanvas(props) {
378
478
  uid,
379
479
  Boolean(props.onMove),
380
480
  outline,
381
- primary
481
+ primary,
482
+ props.edgeLabels
382
483
  ]);
383
484
  function setGeoMT(next) {
384
485
  'main thread';
@@ -545,14 +646,28 @@ function G9GraphCanvas(props) {
545
646
  d.mode = 3;
546
647
  runOnBackground(onDragStart)(d.ids.slice());
547
648
  }
649
+ const hoverMT = useMainThreadRef('');
650
+ function hoverAtMT(raw, g) {
651
+ 'main thread';
652
+ var _ref, _raw_pageX, _ref1, _raw_pageY;
653
+ if (raw.touches && raw.touches.length > 0) return;
654
+ const v = viewNowMT();
655
+ const wx = ((null != (_ref = null != (_raw_pageX = raw.pageX) ? _raw_pageX : raw.x) ? _ref : 0) - g.ox - v[1]) / v[0];
656
+ const wy = ((null != (_ref1 = null != (_raw_pageY = raw.pageY) ? _raw_pageY : raw.y) ? _ref1 : 0) - g.oy - v[2]) / v[0];
657
+ const id = edgeNearMT(g.edges, g.nodes, wx, wy, 8 / v[0], g.curvature);
658
+ if (id === hoverMT.current) return;
659
+ hoverMT.current = id;
660
+ runOnBackground(setHoverEdge)(id || null);
661
+ }
548
662
  function moveMT(e) {
549
663
  'main thread';
550
664
  var _ref, _raw_pageX, _ref1, _raw_pageY;
551
665
  var _live_current, _live_current1;
552
666
  const d = drag.current;
553
667
  const g = geo.current;
554
- if (0 === d.mode || !g) return;
668
+ if (!g) return;
555
669
  const raw = e;
670
+ if (0 === d.mode) return void hoverAtMT(raw, g);
556
671
  const touches = raw.touches;
557
672
  if (4 === d.mode) {
558
673
  if (!touches || touches.length < 2) return;
@@ -639,6 +754,14 @@ function G9GraphCanvas(props) {
639
754
  const v = viewNowMT();
640
755
  runOnBackground(fromMain)(v[0], v[1], v[2]);
641
756
  }
757
+ function leaveMT() {
758
+ 'main thread';
759
+ upMT();
760
+ if (hoverMT.current) {
761
+ hoverMT.current = '';
762
+ runOnBackground(setHoverEdge)(null);
763
+ }
764
+ }
642
765
  function touchEndMT(e) {
643
766
  'main thread';
644
767
  var _ref;
@@ -820,14 +943,32 @@ function G9GraphCanvas(props) {
820
943
  const zoomStep = Math.round(20 * view1.zoom) / 20;
821
944
  const motion = false !== props.animateActive && g9MotionScale() > 0;
822
945
  const labels = null != (_props_labels = props.labels) ? _props_labels : {};
946
+ const enterMode = null != (_props_nodeEnter = props.nodeEnter) ? _props_nodeEnter : 'none';
947
+ const seen = useRef(null);
948
+ if (null === seen.current) seen.current = new Set('all' === enterMode ? [] : props.nodes.map((n)=>n.id));
949
+ const entering = 'none' !== enterMode && g9MotionScale() > 0;
950
+ useEffect(()=>{
951
+ var _seen_current;
952
+ for (const n of props.nodes)null == (_seen_current = seen.current) || _seen_current.add(n.id);
953
+ });
954
+ const background = props.background;
955
+ const bgStyle = background && background.gap > 0 ? backgroundStyle(background, view1) : null;
956
+ const labelled = shownEdges.filter((s)=>{
957
+ if (!s.edge.label) return false;
958
+ const mode = labelModeOf(s.edge);
959
+ if ('always' === mode) return true;
960
+ if ('none' === mode) return false;
961
+ return hoverEdge === s.edge.id || selectedSet.has(s.edge.from.node) || selectedSet.has(s.edge.to.node);
962
+ });
823
963
  return <view className={`g9-graph${props.className ? ` ${props.className}` : ''}`} id={uid} ref={(r)=>{
824
964
  root.current = r;
825
965
  }} style={{
826
966
  direction: 'ltr'
827
- }} bindlayoutchange={onLayout} main-thread:bindmousedown={downMT} main-thread:bindmousemove={moveMT} main-thread:bindmouseup={upMT} main-thread:bindmouseleave={upMT} main-thread:bindtouchstart={downMT} main-thread:bindtouchmove={moveMT} main-thread:bindtouchend={touchEndMT} main-thread:bindtouchcancel={touchEndMT} main-thread:bindwheel={wheelMT} bindlongpress={(e)=>{
967
+ }} bindlayoutchange={onLayout} main-thread:bindmousedown={downMT} main-thread:bindmousemove={moveMT} main-thread:bindmouseup={upMT} main-thread:bindmouseleave={leaveMT} main-thread:bindtouchstart={downMT} main-thread:bindtouchmove={moveMT} main-thread:bindtouchend={touchEndMT} main-thread:bindtouchcancel={touchEndMT} main-thread:bindwheel={wheelMT} bindlongpress={(e)=>{
828
968
  const p = pagePoint(e);
829
969
  if (p) menuAt(p.x, p.y, 'touch', edgeOf(e));
830
970
  }}>
971
+ {bgStyle ? <view className="g9-graph__bg" main-thread:ref={bg} style={bgStyle}/> : null}
831
972
  <view className="g9-graph__world" main-thread:ref={world}>
832
973
  {groups.map((g)=><view key={g.id} className="g9-graph__group" style={{
833
974
  left: `${g.x}px`,
@@ -836,13 +977,23 @@ function G9GraphCanvas(props) {
836
977
  height: `${g.height}px`,
837
978
  ...g.color ? {
838
979
  backgroundColor: g.color
980
+ } : {},
981
+ ...g.borderColor ? {
982
+ borderColor: g.borderColor
839
983
  } : {}
840
984
  }}>
841
- {g.title ? <text className="g9-graph__group-title" text-maxline="1">
985
+ {g.accent ? <view className="g9-graph__group-accent" style={{
986
+ backgroundColor: g.accent
987
+ }}/> : null}
988
+ {g.title ? <text className="g9-graph__group-title" text-maxline="1" {...g.titleColor ? {
989
+ style: {
990
+ color: g.titleColor
991
+ }
992
+ } : {}}>
842
993
  {g.title}
843
994
  </text> : null}
844
995
  </view>)}
845
- {staticBox ? <svg className="g9-graph__edges" content={svgOf(pathsOf(staticEdges, strokeOf, 0), staticBox)} style={{
996
+ {staticBox ? <svg className="g9-graph__edges" content={svgOf(pathsOf(staticEdges, strokeOf, false), staticBox)} style={{
846
997
  left: `${staticBox.x}px`,
847
998
  top: `${staticBox.y}px`,
848
999
  width: `${staticBox.width}px`,
@@ -850,21 +1001,8 @@ function G9GraphCanvas(props) {
850
1001
  }}/> : null}
851
1002
  <ActiveEdges list={activeEdges} color={strokeOf} animate={motion}/>
852
1003
  <svg className="g9-graph__edges g9-graph__edges--live" main-thread:ref={live} content=""/>
853
- {shownEdges.filter((s)=>s.edge.label).map((s)=><view key={`l:${s.edge.id}`} className="g9-graph__edge-label" data-g9edge={s.edge.id} style={{
854
- left: `${s.g.mid.x}px`,
855
- top: `${s.g.mid.y}px`
856
- }} {...props.onEdgePress ? {
857
- bindtap: ()=>{
858
- var _latest_current_onEdgePress, _latest_current;
859
- return null == (_latest_current_onEdgePress = (_latest_current = latest.current).onEdgePress) ? void 0 : _latest_current_onEdgePress.call(_latest_current, s.edge.id);
860
- }
861
- } : {}}>
862
- <text className="g9-graph__edge-text" data-g9edge={s.edge.id} text-maxline="1">
863
- {s.edge.label}
864
- </text>
865
- </view>)}
866
1004
  {props.nodes.map((n)=>{
867
- var _n_acceptsDrop, _dropping_over;
1005
+ var _n_acceptsDrop, _dropping_over, _seen_current;
868
1006
  const isDragging = draggingSet.has(n.id);
869
1007
  if (culled && !culled.nodes.has(n.id) && !isDragging && !selectedSet.has(n.id)) return null;
870
1008
  const candidate = null !== dropping && (null == (_n_acceptsDrop = n.acceptsDrop) ? void 0 : _n_acceptsDrop.call(n, dropping.payload)) === true;
@@ -876,14 +1014,27 @@ function G9GraphCanvas(props) {
876
1014
  dropOver: candidate && (null == dropping ? void 0 : null == (_dropping_over = dropping.over) ? void 0 : _dropping_over.part) === n.id,
877
1015
  zoom: zoomStep
878
1016
  };
879
- return <Card key={n.id} node={n} state={state} render={props.renderNode} elementId={nodeElementId(n.id)}/>;
1017
+ return <Card key={n.id} node={n} state={state} render={props.renderNode} elementId={nodeElementId(n.id)} enter={entering && !(null == (_seen_current = seen.current) ? void 0 : _seen_current.has(n.id))} dragClass={props.draggingClassName}/>;
880
1018
  })}
1019
+ {labelled.map((s)=><view key={`l:${s.edge.id}`} className="g9-graph__edge-label" data-g9edge={s.edge.id} style={{
1020
+ left: `${s.g.mid.x}px`,
1021
+ top: `${s.g.mid.y}px`
1022
+ }} {...props.onEdgePress ? {
1023
+ bindtap: ()=>{
1024
+ var _latest_current_onEdgePress, _latest_current;
1025
+ return null == (_latest_current_onEdgePress = (_latest_current = latest.current).onEdgePress) ? void 0 : _latest_current_onEdgePress.call(_latest_current, s.edge.id);
1026
+ }
1027
+ } : {}}>
1028
+ <text className="g9-graph__edge-text" data-g9edge={s.edge.id} text-maxline="1">
1029
+ {s.edge.label}
1030
+ </text>
1031
+ </view>)}
881
1032
  </view>
882
1033
  {false === props.controls ? null : <view className={`g9-graph__controls g9-graph__controls--${rtl ? 'rtl' : 'ltr'}`}>
883
- <ChromeButton id={`${uid}_ZoomIn`} icon="plus" label={null != (_labels_zoomIn = labels.zoomIn) ? _labels_zoomIn : 'Zoom in'} color={theme.palette.OnSurface} onPress={()=>zoomBy(1.25)}/>
884
- <ChromeButton id={`${uid}_ZoomOut`} icon="minus" label={null != (_labels_zoomOut = labels.zoomOut) ? _labels_zoomOut : 'Zoom out'} color={theme.palette.OnSurface} onPress={()=>zoomBy(0.8)}/>
885
- <ChromeButton id={`${uid}_Fit`} icon="fit" label={null != (_labels_fit = labels.fit) ? _labels_fit : 'Fit'} color={theme.palette.OnSurface} onPress={fit}/>
1034
+ <ChromeButton id={`${uid}_ZoomIn`} anchorId={`${null != (_props_id = props.id) ? _props_id : uid}_ZoomIn`} icon="plus" label={null != (_labels_zoomIn = labels.zoomIn) ? _labels_zoomIn : 'Zoom in'} color={theme.palette.OnSurface} onPress={()=>zoomBy(1.25)}/>
1035
+ <ChromeButton id={`${uid}_ZoomOut`} anchorId={`${null != (_props_id1 = props.id) ? _props_id1 : uid}_ZoomOut`} icon="minus" label={null != (_labels_zoomOut = labels.zoomOut) ? _labels_zoomOut : 'Zoom out'} color={theme.palette.OnSurface} onPress={()=>zoomBy(0.8)}/>
1036
+ <ChromeButton id={`${uid}_Fit`} anchorId={`${null != (_props_id2 = props.id) ? _props_id2 : uid}_Fit`} icon="fit" label={null != (_labels_fit = labels.fit) ? _labels_fit : 'Fit'} color={theme.palette.OnSurface} onPress={fit}/>
886
1037
  </view>}
887
1038
  </view>;
888
1039
  }
889
- export { G9GraphCanvas };
1040
+ export { G9GraphCanvas, graphBackgroundStyle };
package/dist/core.d.ts CHANGED
@@ -45,6 +45,10 @@ export interface G9GraphEnd {
45
45
  }
46
46
  /** How an edge is drawn. */
47
47
  export type G9GraphEdgeStyle = 'solid' | 'dashed' | 'active';
48
+ /** What moves along an active edge (2.11.12): dashes, or small round beads. */
49
+ export type G9GraphEdgeFlow = 'dashes' | 'beads';
50
+ /** When an edge's label shows (2.11.12): never, while the pointer is near the edge, or always. */
51
+ export type G9GraphLabelMode = 'none' | 'hover' | 'always';
48
52
  /** An edge between two node ports. */
49
53
  export interface G9GraphEdge {
50
54
  readonly id: string;
@@ -56,6 +60,20 @@ export interface G9GraphEdge {
56
60
  /** A colour of the app's own (default the theme's outline; active: primary). */
57
61
  readonly color?: string;
58
62
  readonly width?: number;
63
+ /**
64
+ * A soft halo (2.11.12): a translucent under-stroke in the edge's colour (alpha 0.25), `glow` px wider on each side.
65
+ */
66
+ readonly glow?: number;
67
+ /** A gradient (2.11.12): from `color` at the source end to `colorTo` at the target end. */
68
+ readonly colorTo?: string;
69
+ /** What moves along an active edge (2.11.12). Default `'dashes'`. */
70
+ readonly flow?: G9GraphEdgeFlow;
71
+ /** How fast it moves, in world px a second (2.11.12; tie it to the traffic). Default 24. */
72
+ readonly flowSpeed?: number;
73
+ /** Small port dots at both ends (2.11.12). */
74
+ readonly ends?: boolean;
75
+ /** When its label shows (2.11.12). Default: the canvas's `edgeLabels` (`'always'`). */
76
+ readonly labelMode?: G9GraphLabelMode;
59
77
  }
60
78
  /** A titled background area (a lane, a pillar) at an app-given rect. */
61
79
  export interface G9GraphGroup {
@@ -67,6 +85,21 @@ export interface G9GraphGroup {
67
85
  readonly height: number;
68
86
  /** A colour of the app's own for its fill (default the theme's container colour). */
69
87
  readonly color?: string;
88
+ /** The title's colour (2.11.12). */
89
+ readonly titleColor?: string;
90
+ /** The border's colour (2.11.12). */
91
+ readonly borderColor?: string;
92
+ /** A 2 px line along the top in this colour (2.11.12): a lane's tone. */
93
+ readonly accent?: string;
94
+ }
95
+ /** A pattern behind the graph in world space (2.11.12): it pans and zooms with the view. */
96
+ export interface G9GraphBackground {
97
+ readonly kind: 'dots' | 'grid';
98
+ /** The pattern's step in world units. */
99
+ readonly gap: number;
100
+ readonly color: string;
101
+ /** A dot's radius or a line's width in screen px. Default 1. */
102
+ readonly size?: number;
70
103
  }
71
104
  /** The identity view. */
72
105
  export declare const G9_GRAPH_IDENTITY: G9GraphView;
@@ -109,6 +142,10 @@ export interface G9EdgeGeometry {
109
142
  readonly d: string;
110
143
  readonly mid: G9GraphPoint;
111
144
  readonly box: G9GraphRect;
145
+ /** The source port's point (2.11.12). */
146
+ readonly from: G9GraphPoint;
147
+ /** The target port's point (2.11.12). */
148
+ readonly to: G9GraphPoint;
112
149
  }
113
150
  /** Lays out an edge between its nodes. */
114
151
  export declare function edgeGeometry(edge: G9GraphEdge, byId: ReadonlyMap<string, G9GraphNode>, curvature?: number): G9EdgeGeometry | null;
@@ -148,4 +185,14 @@ export interface G9LayeredLayoutOptions {
148
185
  * deepest predecessor; cycles are broken at the edge that closes them. Answers each node's top-left; the app applies it.
149
186
  */
150
187
  export declare function layeredLayout(nodes: readonly Pick<G9GraphNode, 'id' | 'width' | 'height'>[], edges: readonly Pick<G9GraphEdge, 'from' | 'to'>[], options?: G9LayeredLayoutOptions): Map<string, G9GraphPoint>;
188
+ /** The default speed of an active edge's flow, in world px a second (2.11.12). */
189
+ export declare const G9_GRAPH_FLOW_SPEED = 24;
190
+ /** The repeat of an active edge's pattern: dashes (6 + 4) or beads (one each 14 px). */
191
+ export declare function flowPeriod(beads: boolean): number;
192
+ /**
193
+ * One edge's SVG (2.11.12): the glow under it, the stroke (a gradient with `colorTo`), the dashes or beads of an
194
+ * active edge at `offset`, moving by SMIL when `animSeconds` > 0 (the web host animates them in the browser), and
195
+ * the end dots. `dash`: 0 solid, 1 dashed, 2 active. Its twin `edgeSvgMT` (mt.ts) draws a dragged node's edges.
196
+ */
197
+ export declare function edgeSvg(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;
151
198
  //# sourceMappingURL=core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAKA,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,6BAA6B;AAC7B,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAA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SAAS,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC,EAAE,EAC9D,KAAK,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,EAClD,OAAO,GAAE,sBAA2B,GACnC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CA0F3B;AAED,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAyBR"}
package/dist/core.js CHANGED
@@ -156,7 +156,9 @@ function edgeGeometry(edge, byId, curvature = 0.5) {
156
156
  y: y0,
157
157
  width: Math.max(...xs) - x0,
158
158
  height: Math.max(...ys) - y0
159
- }
159
+ },
160
+ from: a,
161
+ to: b
160
162
  };
161
163
  }
162
164
  function cullGraph(nodes, edges, visible) {
@@ -320,6 +322,29 @@ function layeredLayout(nodes, edges, options = {}) {
320
322
  }
321
323
  return result;
322
324
  }
323
- export { G9_GRAPH_IDENTITY, bezierPoint, clampZoom, contentBounds, cullGraph, edgeCurve, edgeGeometry, edgePathData, fitView, intersects, layeredLayout, nextSelection, nodeAt, nodeInDirection, panBy, portPoint, snapTo, toScreen, toWorld, visibleWorld, zoomAt };
325
+ const G9_GRAPH_FLOW_SPEED = 24;
326
+ function flowPeriod(beads) {
327
+ return beads ? 14 : 10;
328
+ }
329
+ function edgeSvg(d, ax, ay, bx, by, color, colorTo, width, glow, dash, beads, ends, gid, offset, animSeconds) {
330
+ let out = '';
331
+ const stroke = colorTo ? `url(#${gid})` : color;
332
+ if (colorTo) out += `<defs><linearGradient id="${gid}" gradientUnits="userSpaceOnUse" x1="${r1(ax)}" y1="${r1(ay)}" x2="${r1(bx)}" y2="${r1(by)}"><stop offset="0" stop-color="${color}"/><stop offset="1" stop-color="${colorTo}"/></linearGradient></defs>`;
333
+ if (glow > 0) out += `<path d="${d}" fill="none" stroke="${stroke}" stroke-opacity="0.25" stroke-width="${r1(width + 2 * glow)}" stroke-linecap="round"/>`;
334
+ const period = flowPeriod(beads);
335
+ const anim = 2 === dash && animSeconds > 0 ? `<animate attributeName="stroke-dashoffset" from="0" to="-${period}" dur="${Math.round(100 * animSeconds) / 100}s" repeatCount="indefinite"/>` : '';
336
+ const off = 2 === dash && offset ? ` stroke-dashoffset="${r1(offset)}"` : '';
337
+ if (2 === dash && beads) {
338
+ out += `<path d="${d}" fill="none" stroke="${stroke}" stroke-opacity="0.45" stroke-width="${width}"/>`;
339
+ out += `<path d="${d}" fill="none" stroke="${stroke}" stroke-width="${r1(Math.max(4, 2.6 * width))}" stroke-linecap="round" stroke-dasharray="0 ${period}"${off}>${anim}</path>`;
340
+ } else if (0 === dash) out += `<path d="${d}" fill="none" stroke="${stroke}" stroke-width="${width}"/>`;
341
+ else out += `<path d="${d}" fill="none" stroke="${stroke}" stroke-width="${width}" stroke-dasharray="6 4"${off}>${anim}</path>`;
342
+ if (ends) {
343
+ const r = r1(Math.max(2.5, width + 1.5));
344
+ out += `<circle cx="${r1(ax)}" cy="${r1(ay)}" r="${r}" fill="${color}"/><circle cx="${r1(bx)}" cy="${r1(by)}" r="${r}" fill="${colorTo || color}"/>`;
345
+ }
346
+ return out;
347
+ }
348
+ export { G9_GRAPH_FLOW_SPEED, G9_GRAPH_IDENTITY, bezierPoint, clampZoom, contentBounds, cullGraph, edgeCurve, edgeGeometry, edgePathData, edgeSvg, fitView, flowPeriod, intersects, layeredLayout, nextSelection, nodeAt, nodeInDirection, panBy, portPoint, snapTo, toScreen, toWorld, visibleWorld, zoomAt };
324
349
 
325
350
  //# sourceMappingURL=core.js.map