@yuneta/gobj-ui 7.23.80 → 7.23.82
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 +62 -27
- package/dist/gobj-ui.cjs.js +590 -110
- package/dist/gobj-ui.es.js +591 -111
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +632 -74
- package/src/c_yui_treedb_graph.js +58 -30
- package/src/lib_graph.css +2 -0
|
@@ -120,8 +120,8 @@ SDATA(data_type_t.DTP_STRING, "layout", sdata_flag_t.SDF_PERSIST, ""
|
|
|
120
120
|
SDATA(data_type_t.DTP_LIST, "hidden_topics", sdata_flag_t.SDF_PERSIST, "[]", "Topics hidden from the graph (legend). User preference, per treedb"),
|
|
121
121
|
SDATA(data_type_t.DTP_STRING, "main_topic", sdata_flag_t.SDF_PERSIST, "", "The topic the tree hangs from; empty = deduced by the graph. User preference, per treedb"),
|
|
122
122
|
SDATA(data_type_t.DTP_LIST, "loose_topics", sdata_flag_t.SDF_PERSIST, "[]", "Topics whose LOOSE records (no parent) are shown. User preference, per treedb"),
|
|
123
|
-
SDATA(data_type_t.DTP_STRING, "node_mode", sdata_flag_t.SDF_PERSIST, "expanded", "How the records are drawn: `expanded` = the cards with their ports, `compact` = coloured
|
|
124
|
-
SDATA(data_type_t.DTP_BOOLEAN, "node_labels", sdata_flag_t.SDF_PERSIST, true, "A
|
|
123
|
+
SDATA(data_type_t.DTP_STRING, "node_mode", sdata_flag_t.SDF_PERSIST, "expanded", "How the records are drawn: `expanded` = the cards with their pills and ports, `compact` = one-line pills with the name, `shape` = coloured figures, the topology alone. User preference"),
|
|
124
|
+
SDATA(data_type_t.DTP_BOOLEAN, "node_labels", sdata_flag_t.SDF_PERSIST, true, "A `shape` node says its name under its figure. User preference"),
|
|
125
125
|
|
|
126
126
|
/*---------------- Remote Connection ----------------*/
|
|
127
127
|
SDATA(data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "Remote Yuno to request data"),
|
|
@@ -547,28 +547,53 @@ function option_label(name)
|
|
|
547
547
|
************************************************************/
|
|
548
548
|
function node_shape_items(gobj, wide)
|
|
549
549
|
{
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
550
|
+
/* `value` explicit on every option, as on the two selects
|
|
551
|
+
* above: a translated <option> without one answers with its
|
|
552
|
+
* TEXT, and the mode the child is told is a word it does not
|
|
553
|
+
* know. */
|
|
554
|
+
let options = NODE_MODES.map((mode) =>
|
|
555
|
+
['option', {value: mode, 'data-i18n': NODE_MODE_LABELS[mode]}, t(NODE_MODE_LABELS[mode])]
|
|
556
|
+
);
|
|
557
|
+
return [
|
|
558
|
+
['span', {class: 'GRAPH_NODE_MODE_LABEL is-hidden-mobile',
|
|
559
|
+
style: 'padding-left:10px; padding-right:5px;', i18n: 'nodes'}, 'nodes'],
|
|
560
|
+
['div', {class: 'select'}, [
|
|
561
|
+
['select', {class: 'GRAPH_NODE_MODE_SELECT',
|
|
562
|
+
title: t('nodes'), 'data-i18n-title': 'nodes',
|
|
563
|
+
'aria-label': t('nodes'), 'data-i18n-aria-label': 'nodes'}, options]
|
|
564
|
+
], {
|
|
565
|
+
change: (evt) => {
|
|
566
|
+
evt.stopPropagation();
|
|
567
|
+
gobj_send_event(gobj, "EV_SET_NODE_MODE", {node_mode: evt.target.value}, gobj);
|
|
568
|
+
}
|
|
569
|
+
}],
|
|
570
|
+
['button', {class: 'GRAPH_NODE_LABELS button', type: 'button',
|
|
571
|
+
style: {height: wide, width: '2.5em'},
|
|
572
|
+
title: t('node labels'), 'data-i18n-title': 'node labels',
|
|
573
|
+
'aria-label': t('node labels'), 'data-i18n-aria-label': 'node labels',
|
|
574
|
+
'aria-pressed': 'false'},
|
|
575
|
+
['i', {style: 'font-size:1.5em; color:inherit;', class: 'yi-font'}],
|
|
557
576
|
{
|
|
558
577
|
click: (evt) => {
|
|
559
578
|
evt.stopPropagation();
|
|
560
|
-
gobj_send_event(gobj,
|
|
579
|
+
gobj_send_event(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
|
|
561
580
|
}
|
|
562
581
|
}
|
|
563
|
-
]
|
|
564
|
-
};
|
|
565
|
-
return [
|
|
566
|
-
toggle('GRAPH_NODE_MODE', 'yi-hexagon-nodes', 'EV_TOGGLE_NODE_MODE', 'closed nodes'),
|
|
567
|
-
toggle('GRAPH_NODE_LABELS', 'yi-font', 'EV_TOGGLE_NODE_LABELS', 'node labels'),
|
|
582
|
+
],
|
|
568
583
|
];
|
|
569
584
|
}
|
|
570
585
|
|
|
571
|
-
/* The
|
|
586
|
+
/* The three views of a record, and the label of each in the
|
|
587
|
+
* select. The values are the child's `node_mode`. */
|
|
588
|
+
const NODE_MODES = ['expanded', 'compact', 'shape'];
|
|
589
|
+
const NODE_MODE_LABELS = {
|
|
590
|
+
expanded: 'full',
|
|
591
|
+
compact: 'compact',
|
|
592
|
+
shape: 'shape',
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
/* The select and the labels toggle, from the attrs. The toggle
|
|
596
|
+
* only means something on figures, so it is disabled elsewhere.
|
|
572
597
|
* `$root` is whatever holds the toolbar: the toolbar itself before
|
|
573
598
|
* the view is mounted, the view's container after. */
|
|
574
599
|
function refresh_node_shape_buttons(gobj, $root)
|
|
@@ -576,17 +601,20 @@ function refresh_node_shape_buttons(gobj, $root)
|
|
|
576
601
|
if(!$root) {
|
|
577
602
|
return;
|
|
578
603
|
}
|
|
579
|
-
let
|
|
604
|
+
let mode = gobj_read_str_attr(gobj, "node_mode");
|
|
605
|
+
if(!NODE_MODES.includes(mode)) {
|
|
606
|
+
mode = 'expanded';
|
|
607
|
+
}
|
|
580
608
|
let labels = gobj_read_bool_attr(gobj, "node_labels");
|
|
581
|
-
|
|
582
|
-
set_pressed_state($root, '.GRAPH_NODE_LABELS', labels);
|
|
583
|
-
let $mode = $root.querySelector('.GRAPH_NODE_MODE');
|
|
609
|
+
let $mode = $root.querySelector('.GRAPH_NODE_MODE_SELECT');
|
|
584
610
|
if($mode) {
|
|
585
|
-
$mode.
|
|
611
|
+
$mode.value = mode;
|
|
586
612
|
}
|
|
613
|
+
set_pressed_state($root, '.GRAPH_NODE_LABELS', labels);
|
|
587
614
|
let $labels = $root.querySelector('.GRAPH_NODE_LABELS');
|
|
588
615
|
if($labels) {
|
|
589
616
|
$labels.setAttribute('aria-pressed', labels? 'true' : 'false');
|
|
617
|
+
$labels.disabled = (mode !== 'shape');
|
|
590
618
|
}
|
|
591
619
|
}
|
|
592
620
|
|
|
@@ -654,8 +682,8 @@ function make_toolbar(gobj)
|
|
|
654
682
|
* way back to the default depth. */
|
|
655
683
|
...yui_graph_fold_items(gobj, gobj_read_str_attr(gobj, "wide")),
|
|
656
684
|
|
|
657
|
-
/* The
|
|
658
|
-
*
|
|
685
|
+
/* The view of the nodes -- full cards, one-line pills or
|
|
686
|
+
* figures -- and the name under a figure. */
|
|
659
687
|
...node_shape_items(gobj, gobj_read_str_attr(gobj, "wide")),
|
|
660
688
|
|
|
661
689
|
/* Inspect the treedb's raw tranger json in the lazy tree viewer
|
|
@@ -2770,14 +2798,14 @@ function ac_collapse_all(gobj, event, kw, src)
|
|
|
2770
2798
|
}
|
|
2771
2799
|
|
|
2772
2800
|
/************************************************************
|
|
2773
|
-
* The
|
|
2774
|
-
*
|
|
2775
|
-
* the nodes.
|
|
2801
|
+
* The view of the nodes and the labels toggle of the toolbar:
|
|
2802
|
+
* the attr changes, persists, shows on the control, and reaches
|
|
2803
|
+
* the G6 child, which owns the nodes.
|
|
2776
2804
|
************************************************************/
|
|
2777
|
-
function
|
|
2805
|
+
function ac_set_node_mode(gobj, event, kw, src)
|
|
2778
2806
|
{
|
|
2779
2807
|
let priv = gobj.priv;
|
|
2780
|
-
let mode = (
|
|
2808
|
+
let mode = (kw && NODE_MODES.includes(kw.node_mode))? kw.node_mode : "expanded";
|
|
2781
2809
|
|
|
2782
2810
|
gobj_write_str_attr(gobj, "node_mode", mode);
|
|
2783
2811
|
gobj_save_persistent_attrs(gobj, "node_mode");
|
|
@@ -2955,7 +2983,7 @@ function create_gclass(gclass_name)
|
|
|
2955
2983
|
["EV_FIND_NODES", ac_find_nodes, null],
|
|
2956
2984
|
["EV_EXPAND_ALL", ac_expand_all, null],
|
|
2957
2985
|
["EV_COLLAPSE_ALL", ac_collapse_all, null],
|
|
2958
|
-
["
|
|
2986
|
+
["EV_SET_NODE_MODE", ac_set_node_mode, null],
|
|
2959
2987
|
["EV_TOGGLE_NODE_LABELS", ac_toggle_node_labels, null],
|
|
2960
2988
|
["EV_LAYOUT_AUTOSET", ac_layout_autoset, null],
|
|
2961
2989
|
["EV_LEGEND_TOPIC", ac_legend_topic, null],
|
|
@@ -2998,7 +3026,7 @@ function create_gclass(gclass_name)
|
|
|
2998
3026
|
["EV_FIND_NODES", 0],
|
|
2999
3027
|
["EV_EXPAND_ALL", 0],
|
|
3000
3028
|
["EV_COLLAPSE_ALL", 0],
|
|
3001
|
-
["
|
|
3029
|
+
["EV_SET_NODE_MODE", 0],
|
|
3002
3030
|
["EV_TOGGLE_NODE_LABELS", 0],
|
|
3003
3031
|
["EV_FIND_RESULT", 0],
|
|
3004
3032
|
["EV_LAYOUT_AUTOSET", 0],
|
package/src/lib_graph.css
CHANGED
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
.graph-container .g6-create-popover,
|
|
87
87
|
.graph-container .g6-node-popover,
|
|
88
88
|
.graph-container .g6-edge-popover,
|
|
89
|
+
.graph-container .g6-port-popover,
|
|
89
90
|
.graph-container .g6-node-detail {
|
|
90
91
|
-webkit-user-select: text;
|
|
91
92
|
user-select: text;
|
|
@@ -99,6 +100,7 @@
|
|
|
99
100
|
.graph-container .g6-create-popover,
|
|
100
101
|
.graph-container .g6-node-popover,
|
|
101
102
|
.graph-container .g6-edge-popover,
|
|
103
|
+
.graph-container .g6-port-popover,
|
|
102
104
|
.graph-container .g6-node-detail,
|
|
103
105
|
.graph-container .g6-contextmenu {
|
|
104
106
|
touch-action: auto;
|