@yuneta/gobj-ui 7.27.25 → 7.27.26
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 +10 -2
- package/dist/gobj-ui.cjs.js +34656 -34512
- package/dist/gobj-ui.es.js +34496 -34352
- package/package.json +4 -4
- package/src/c_g6_nodes_tree.js +36 -96
- package/src/c_yui_gobj_tree_js.js +87 -1
- package/src/gobj_tree_camera.wiring.test.js +44 -4
- package/src/gobj_tree_model.js +42 -7
- package/src/gobj_tree_model.test.js +34 -0
- package/src/yui_graph_minimap.js +128 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* yui_graph_minimap.js
|
|
3
|
+
*
|
|
4
|
+
* The minimap of a G6 graph, drawn the same way in every graph of the
|
|
5
|
+
* library: where it sits, the frame it wears in each theme, and how
|
|
6
|
+
* it shows the part of the graph that is on screen.
|
|
7
|
+
*
|
|
8
|
+
* It came from the treedb graph (`c_g6_nodes_tree.js`), where each of
|
|
9
|
+
* these decisions was paid for, and moved here when the gobj tree
|
|
10
|
+
* needed one too: two graphs side by side in the same console with
|
|
11
|
+
* two different minimaps is the drift `yui_graph_camera.js` exists to
|
|
12
|
+
* stop.
|
|
13
|
+
*
|
|
14
|
+
* What stays with each graph is WHEN it shows one (both decide by the
|
|
15
|
+
* number of nodes) and the colour of each block -- a topic's colour
|
|
16
|
+
* in one, a role's in the other.
|
|
17
|
+
*
|
|
18
|
+
* Copyright (c) 2026, ArtGins.
|
|
19
|
+
* All Rights Reserved.
|
|
20
|
+
***********************************************************************/
|
|
21
|
+
import {Rect as RectGeometry} from '@antv/g';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/************************************************************
|
|
25
|
+
* The options of G6's `minimap` plugin, with `shape` drawing
|
|
26
|
+
* each element: `(id, element_type, element) => shape`.
|
|
27
|
+
*
|
|
28
|
+
* The shapes are the caller's because G6's minimap clones each
|
|
29
|
+
* element's KEY shape into its own canvas, and in an `html` node
|
|
30
|
+
* the key shape is a DOM element, which clones into nothing. A
|
|
31
|
+
* block of the node's size (yui_graph_minimap_block()) is also
|
|
32
|
+
* what a minimap of cards should show: at that scale a card is a
|
|
33
|
+
* rectangle anyway.
|
|
34
|
+
************************************************************/
|
|
35
|
+
export function yui_graph_minimap_options(shape)
|
|
36
|
+
{
|
|
37
|
+
return {
|
|
38
|
+
size: [200, 140],
|
|
39
|
+
position: "bottom-left",
|
|
40
|
+
/*
|
|
41
|
+
* The anchor has to be CSS, not the pixels G6 computes.
|
|
42
|
+
*
|
|
43
|
+
* `createPluginCanvas` turns `position` into `left`/`top`
|
|
44
|
+
* in PIXELS, once, from the canvas size at creation
|
|
45
|
+
* (`xRatio * (W - width)`). The container then grows --
|
|
46
|
+
* full screen, a window resize, a panel closing -- and the
|
|
47
|
+
* minimap stays at the `top` it was given: measured going
|
|
48
|
+
* full screen, `top` was still `511px` over a container
|
|
49
|
+
* that had become 768 tall, which put it floating halfway
|
|
50
|
+
* up the left edge, on top of the graph it is there to
|
|
51
|
+
* explain.
|
|
52
|
+
*
|
|
53
|
+
* `containerStyle` is merged AFTER those pixels, so
|
|
54
|
+
* `top: auto` + `bottom` is a real anchor the browser
|
|
55
|
+
* keeps for every size the container ever takes.
|
|
56
|
+
*
|
|
57
|
+
* And it follows the theme: G6's default is a `#fff` box
|
|
58
|
+
* with a `#ddd` border in BOTH themes, which over a
|
|
59
|
+
* near-black canvas is the brightest thing on screen.
|
|
60
|
+
*/
|
|
61
|
+
containerStyle: {
|
|
62
|
+
top: "auto",
|
|
63
|
+
bottom: "12px",
|
|
64
|
+
left: "12px",
|
|
65
|
+
background: "var(--bulma-scheme-main, #fff)",
|
|
66
|
+
/* A mid grey and not a `--bulma-border-*` token: those
|
|
67
|
+
* are made for a line INSIDE a surface, and this one has
|
|
68
|
+
* to separate a floating panel from the CANVAS behind
|
|
69
|
+
* it -- which is near-black in one scheme and white in
|
|
70
|
+
* the other. `border-weak` was 1.43:1 over the dark
|
|
71
|
+
* canvas and 1.18 over the light one; every border token
|
|
72
|
+
* fails at least one of them. This one is 4.6 on both.
|
|
73
|
+
* (The box-shadow below separates it only where there
|
|
74
|
+
* is light to cast a shadow on.) */
|
|
75
|
+
border: "1px solid var(--bulma-text-weak, #94a3b8)",
|
|
76
|
+
borderRadius: "6px",
|
|
77
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.15)",
|
|
78
|
+
},
|
|
79
|
+
/* The viewport rectangle: G6 washes it in black, which is
|
|
80
|
+
* invisible over a dark minimap. A link-coloured outline
|
|
81
|
+
* reads on both. */
|
|
82
|
+
maskStyle: {
|
|
83
|
+
border: "2px solid var(--bulma-link-on-scheme, var(--bulma-link, #3b82f6))",
|
|
84
|
+
background: "rgba(59, 130, 246, 0.12)",
|
|
85
|
+
},
|
|
86
|
+
shape: shape,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/************************************************************
|
|
91
|
+
* One node of the minimap: a block of the node's size,
|
|
92
|
+
* centred where the node is, filled with `fill`.
|
|
93
|
+
*
|
|
94
|
+
* `node_data` is G6's (graph.getNodeData(id)); a node with no
|
|
95
|
+
* size of its own gets a card's.
|
|
96
|
+
************************************************************/
|
|
97
|
+
export function yui_graph_minimap_block(node_data, fill)
|
|
98
|
+
{
|
|
99
|
+
let size = (node_data && node_data.style && node_data.style.size) || [120, 60];
|
|
100
|
+
return new RectGeometry({
|
|
101
|
+
style: {
|
|
102
|
+
x: -size[0] / 2,
|
|
103
|
+
y: -size[1] / 2,
|
|
104
|
+
width: size[0],
|
|
105
|
+
height: size[1],
|
|
106
|
+
fill: fill,
|
|
107
|
+
radius: 4
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/************************************************************
|
|
113
|
+
* Paint a minimap again from where the nodes are NOW.
|
|
114
|
+
*
|
|
115
|
+
* It repaints off the graph's draw events, and a layout emits
|
|
116
|
+
* none: G6 moves the nodes with a SILENT draw. So after a layout
|
|
117
|
+
* the minimap goes on showing the arrangement before it until it
|
|
118
|
+
* is told. It throws what G6 throws: the caller catches it, and
|
|
119
|
+
* its log says whose minimap it was.
|
|
120
|
+
************************************************************/
|
|
121
|
+
export function yui_graph_minimap_repaint(plugin)
|
|
122
|
+
{
|
|
123
|
+
if(!plugin || plugin.destroyed) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
plugin.renderMinimap();
|
|
127
|
+
plugin.renderMask();
|
|
128
|
+
}
|