@yuneta/gobj-ui 7.23.81 → 7.23.83
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 +42 -27
- package/dist/gobj-ui.cjs.js +308 -128
- package/dist/gobj-ui.es.js +308 -128
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +272 -90
- package/src/c_yui_treedb_graph.js +67 -27
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -54530,11 +54530,31 @@ var SELECT_RING = "rgba(59,130,246,0.95)";
|
|
|
54530
54530
|
var PORT_R_ENTITY = 14;
|
|
54531
54531
|
var PORT_R_CHILD = 8;
|
|
54532
54532
|
var PORT_LINE_WIDTH = 2;
|
|
54533
|
-
var
|
|
54533
|
+
var NODE_MODES$1 = [
|
|
54534
|
+
"expanded",
|
|
54535
|
+
"compact",
|
|
54536
|
+
"shape"
|
|
54537
|
+
];
|
|
54538
|
+
var PILL_SIZE = {
|
|
54539
|
+
hierarchical: [200, 30],
|
|
54540
|
+
extended: [180, 28],
|
|
54541
|
+
child: [160, 26]
|
|
54542
|
+
};
|
|
54543
|
+
var PORT_R_PILL = 6;
|
|
54544
|
+
var SHAPE_SIZE = {
|
|
54534
54545
|
hierarchical: 32,
|
|
54535
54546
|
extended: 28,
|
|
54536
54547
|
child: 22
|
|
54537
54548
|
};
|
|
54549
|
+
var NODE_SHAPES = [
|
|
54550
|
+
"square",
|
|
54551
|
+
"circle",
|
|
54552
|
+
"diamond",
|
|
54553
|
+
"triangle",
|
|
54554
|
+
"hexagon",
|
|
54555
|
+
"star"
|
|
54556
|
+
];
|
|
54557
|
+
var DEFAULT_NODE_SHAPE = "square";
|
|
54538
54558
|
/***************************************************************
|
|
54539
54559
|
* Internal layout and operation mode definitions
|
|
54540
54560
|
***************************************************************/
|
|
@@ -54615,8 +54635,8 @@ var attrs_table$4 = [
|
|
|
54615
54635
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_LIST, "hidden_topics", 0, "[]", "Topics left out of the tree: no card, no pill counts them, no edge reaches them"),
|
|
54616
54636
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "main_topic", 0, "", "The topic the tree hangs from; empty = deduced (the one whose hooks reach the most others). Its parentless records are the roots; a parentless record of a topic linked to it is LOOSE and shown only on request"),
|
|
54617
54637
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_LIST, "loose_topics", 0, "[]", "Topics whose loose records (no parent, in a topic the schema hangs from the main one) are shown as roots"),
|
|
54618
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "node_mode", 0, "expanded", "How a record is drawn: `expanded` = the card with its ports
|
|
54619
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "node_labels", 0, true, "A
|
|
54638
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "node_mode", 0, "expanded", "How a record is drawn: `expanded` = the card with its pills and ports; `compact` = a one-line pill with the name and small ports; `shape` = a figure of the topic's colour (square, circle, diamond... per node or topic, from the node properties), no ports, no text -- the topology alone. One node can be toggled against it (EV_TOGGLE_NODE_MODE)"),
|
|
54639
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "node_labels", 0, true, "A `shape` node says its name under the figure. Off, it is a coloured figure and nothing else"),
|
|
54620
54640
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "confirm_delete_node", 0, true, "Ask confirmation before deleting a node"),
|
|
54621
54641
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "confirm_unlink_edge", 0, true, "Ask confirmation before unlinking an edge"),
|
|
54622
54642
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "wide", 0, "40px", "Height of header"),
|
|
@@ -55594,14 +55614,26 @@ function create_topic_node(gobj, desc, record) {
|
|
|
55594
55614
|
* the other one would leave behind (`labelText`, `ports`).
|
|
55595
55615
|
************************************************************/
|
|
55596
55616
|
function node_shape_of(gobj, node_id, desc, record, geometry, pills_html) {
|
|
55597
|
-
|
|
55598
|
-
|
|
55617
|
+
switch (node_mode_of(gobj, node_id)) {
|
|
55618
|
+
case "shape": return figure_shape_of(gobj, desc, record, geometry, {});
|
|
55619
|
+
case "compact": return pill_shape_of(gobj, desc, record, geometry);
|
|
55620
|
+
default: return card_shape_of(gobj, desc, record, geometry, pills_html);
|
|
55621
|
+
}
|
|
55599
55622
|
}
|
|
55600
|
-
function
|
|
55623
|
+
function node_mode_of(gobj, node_id) {
|
|
55601
55624
|
let priv = gobj.priv;
|
|
55602
55625
|
if (!priv._open_nodes) priv._open_nodes = /* @__PURE__ */ new Set();
|
|
55603
|
-
let
|
|
55604
|
-
|
|
55626
|
+
let mode = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "node_mode");
|
|
55627
|
+
if (!mode || !(0, _yuneta_gobj_js.str_in_list)(NODE_MODES$1, mode)) mode = "expanded";
|
|
55628
|
+
if (priv._open_nodes.has(node_id)) return mode === "expanded" ? "compact" : "expanded";
|
|
55629
|
+
return mode;
|
|
55630
|
+
}
|
|
55631
|
+
function node_is_compact(gobj, node_id) {
|
|
55632
|
+
return node_mode_of(gobj, node_id) !== "expanded";
|
|
55633
|
+
}
|
|
55634
|
+
function topic_defaults_of(gobj, topic_name) {
|
|
55635
|
+
let topic_props = gobj.priv._graph_properties[topic_name];
|
|
55636
|
+
return (0, _yuneta_gobj_js.is_object)(topic_props) && (0, _yuneta_gobj_js.is_object)(topic_props.defaults) ? topic_props.defaults : null;
|
|
55605
55637
|
}
|
|
55606
55638
|
/************************************************************
|
|
55607
55639
|
* The CARD: an html node, the tier's size, the ports, the
|
|
@@ -55647,55 +55679,107 @@ function card_shape_of(gobj, desc, record, geometry, pills_html) {
|
|
|
55647
55679
|
style.dy = -(saved_size.length > 1 ? saved_size[1] : saved_size[0]) / 2;
|
|
55648
55680
|
}
|
|
55649
55681
|
if (geometry.portR > 0) style.portR = geometry.portR;
|
|
55650
|
-
|
|
55651
|
-
|
|
55652
|
-
|
|
55653
|
-
|
|
55654
|
-
|
|
55655
|
-
|
|
55656
|
-
|
|
55657
|
-
|
|
55658
|
-
|
|
55659
|
-
|
|
55660
|
-
|
|
55661
|
-
|
|
55662
|
-
|
|
55663
|
-
|
|
55664
|
-
|
|
55665
|
-
let port_shapes = geometry.port_shapes;
|
|
55666
|
-
let default_port_shapes = topic_defaults ? topic_defaults.port_shapes : null;
|
|
55667
|
-
let default_shape = topic_defaults ? topic_defaults.port_shape : null;
|
|
55668
|
-
for (let i = 0; i < style.ports.length; i++) {
|
|
55669
|
-
let key = style.ports[i].key;
|
|
55670
|
-
let shape = (0, _yuneta_gobj_js.is_object)(port_shapes) ? port_shapes[key] : null;
|
|
55671
|
-
if (!shape && (0, _yuneta_gobj_js.is_object)(default_port_shapes)) shape = default_port_shapes[key];
|
|
55672
|
-
if (!shape) shape = default_shape;
|
|
55673
|
-
if (shape && (0, _yuneta_gobj_js.str_in_list)(PORT_SHAPES, shape)) style.ports[i].shape = shape;
|
|
55674
|
-
}
|
|
55675
|
-
} else {
|
|
55682
|
+
dress_ports(gobj, style, ports, geometry, topic_defaults, node_treedb_type === "child" ? PORT_R_CHILD : PORT_R_ENTITY, false);
|
|
55683
|
+
return {
|
|
55684
|
+
type: "treedb-card",
|
|
55685
|
+
style
|
|
55686
|
+
};
|
|
55687
|
+
}
|
|
55688
|
+
/************************************************************
|
|
55689
|
+
* The ports of a card or a pill, dressed: the node-level radius
|
|
55690
|
+
* (saved, topic default, or the tier's), each port's own radius
|
|
55691
|
+
* and shape (saved first, then the topic's per-port defaults, then
|
|
55692
|
+
* the topic's one shape for every port). `fixed_r` -- the pill --
|
|
55693
|
+
* ignores every saved radius: a pill has one size of port.
|
|
55694
|
+
************************************************************/
|
|
55695
|
+
function dress_ports(gobj, style, ports, geometry, topic_defaults, r_default, fixed_r) {
|
|
55696
|
+
if (!(0, _yuneta_gobj_js.json_size)(ports)) {
|
|
55676
55697
|
style.port = false;
|
|
55677
55698
|
style.ports = [];
|
|
55699
|
+
return;
|
|
55678
55700
|
}
|
|
55701
|
+
(0, _yuneta_gobj_js.json_object_update_missing)(style, {
|
|
55702
|
+
port: true,
|
|
55703
|
+
ports,
|
|
55704
|
+
portR: r_default,
|
|
55705
|
+
portLineWidth: PORT_LINE_WIDTH
|
|
55706
|
+
});
|
|
55707
|
+
if (fixed_r) style.portR = r_default;
|
|
55708
|
+
let port_sizes = fixed_r ? null : geometry.port_sizes;
|
|
55709
|
+
let default_port_sizes = !fixed_r && topic_defaults ? topic_defaults.port_sizes : null;
|
|
55710
|
+
let port_shapes = geometry.port_shapes;
|
|
55711
|
+
let default_port_shapes = topic_defaults ? topic_defaults.port_shapes : null;
|
|
55712
|
+
let default_shape = topic_defaults ? topic_defaults.port_shape : null;
|
|
55713
|
+
for (let i = 0; i < style.ports.length; i++) {
|
|
55714
|
+
let key = style.ports[i].key;
|
|
55715
|
+
let r = (0, _yuneta_gobj_js.is_object)(port_sizes) ? port_sizes[key] : null;
|
|
55716
|
+
if (r == null && (0, _yuneta_gobj_js.is_object)(default_port_sizes)) r = default_port_sizes[key];
|
|
55717
|
+
if (r != null) style.ports[i].r = r;
|
|
55718
|
+
let shape = (0, _yuneta_gobj_js.is_object)(port_shapes) ? port_shapes[key] : null;
|
|
55719
|
+
if (!shape && (0, _yuneta_gobj_js.is_object)(default_port_shapes)) shape = default_port_shapes[key];
|
|
55720
|
+
if (!shape) shape = default_shape;
|
|
55721
|
+
if (shape && (0, _yuneta_gobj_js.str_in_list)(PORT_SHAPES, shape)) style.ports[i].shape = shape;
|
|
55722
|
+
}
|
|
55723
|
+
}
|
|
55724
|
+
/************************************************************
|
|
55725
|
+
* The PILL: one line with the name inside, the tint and the
|
|
55726
|
+
* border of the topic, small ports on its edges -- the half-way
|
|
55727
|
+
* house between the card and the figure, and the same one-line
|
|
55728
|
+
* chip a leaf record already is, at the tier's width. No pills:
|
|
55729
|
+
* a hook is opened from the card (expand the node).
|
|
55730
|
+
************************************************************/
|
|
55731
|
+
function pill_shape_of(gobj, desc, record, geometry) {
|
|
55732
|
+
let priv = gobj.priv;
|
|
55733
|
+
let size = PILL_SIZE[desc.node_treedb_type] || PILL_SIZE.hierarchical;
|
|
55734
|
+
let ports = build_ports(gobj, desc);
|
|
55735
|
+
let style = {
|
|
55736
|
+
fill: desc.color,
|
|
55737
|
+
stroke: getStrokeColor(desc.color),
|
|
55738
|
+
lineWidth: 1,
|
|
55739
|
+
lineDash: [],
|
|
55740
|
+
halo: false,
|
|
55741
|
+
labelText: "",
|
|
55742
|
+
size: [...size],
|
|
55743
|
+
dx: -size[0] / 2,
|
|
55744
|
+
dy: -size[1] / 2,
|
|
55745
|
+
innerHTML: build_chip_innerHTML(desc.color, priv.theme, record.icon, node_label(desc, record), record.id)
|
|
55746
|
+
};
|
|
55747
|
+
dress_ports(gobj, style, ports, geometry, topic_defaults_of(gobj, desc.topic_name), PORT_R_PILL, true);
|
|
55679
55748
|
return {
|
|
55680
55749
|
type: "treedb-card",
|
|
55681
55750
|
style
|
|
55682
55751
|
};
|
|
55683
55752
|
}
|
|
55753
|
+
function pill_innerHTML_of(gobj, nd, theme, highlight, selected, anchored) {
|
|
55754
|
+
let desc = nd.data.desc;
|
|
55755
|
+
let record = nd.data.record || {};
|
|
55756
|
+
return build_chip_innerHTML(desc.color, theme, record.icon, node_label(desc, record), record.id, highlight, selected, anchored);
|
|
55757
|
+
}
|
|
55758
|
+
function node_figure_of(gobj, desc, geometry) {
|
|
55759
|
+
let shape = geometry ? geometry.node_shape : null;
|
|
55760
|
+
if (!shape) {
|
|
55761
|
+
let defaults = topic_defaults_of(gobj, desc.topic_name);
|
|
55762
|
+
shape = defaults ? defaults.node_shape : null;
|
|
55763
|
+
}
|
|
55764
|
+
return shape && (0, _yuneta_gobj_js.str_in_list)(NODE_SHAPES, shape) ? shape : DEFAULT_NODE_SHAPE;
|
|
55765
|
+
}
|
|
55684
55766
|
/************************************************************
|
|
55685
|
-
* The
|
|
55686
|
-
*
|
|
55687
|
-
*
|
|
55688
|
-
*
|
|
55689
|
-
*
|
|
55767
|
+
* The FIGURE: a native G6 node of the topic's colour -- a square,
|
|
55768
|
+
* a circle, a diamond, a triangle, a hexagon, a star -- no ports,
|
|
55769
|
+
* the name as a label under it when `node_labels` says so. Native
|
|
55770
|
+
* and not html on purpose: G6's own stroke and halo paint on it,
|
|
55771
|
+
* so the focus, the selection and the anchor are three keys of
|
|
55772
|
+
* the style instead of a rebuilt innerHTML.
|
|
55690
55773
|
*
|
|
55691
55774
|
* flags {highlight, selected, anchored}
|
|
55692
55775
|
************************************************************/
|
|
55693
|
-
function
|
|
55776
|
+
function figure_shape_of(gobj, desc, record, geometry, flags) {
|
|
55694
55777
|
let dark = gobj.priv.theme === "dark";
|
|
55695
55778
|
let f = flags || {};
|
|
55696
55779
|
let tier = desc.node_treedb_type;
|
|
55697
|
-
let side =
|
|
55780
|
+
let side = SHAPE_SIZE[tier] || SHAPE_SIZE.hierarchical;
|
|
55698
55781
|
let labels = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "node_labels");
|
|
55782
|
+
let figure = node_figure_of(gobj, desc, geometry || {});
|
|
55699
55783
|
let stroke = getStrokeColor(desc.color);
|
|
55700
55784
|
let line_width = 1.5;
|
|
55701
55785
|
if (f.selected) {
|
|
@@ -55712,34 +55796,35 @@ function compact_shape_of(gobj, desc, record, flags) {
|
|
|
55712
55796
|
dash = [2, 2];
|
|
55713
55797
|
line_width = Math.max(line_width, 2.5);
|
|
55714
55798
|
}
|
|
55799
|
+
let style = {
|
|
55800
|
+
size: [side, side],
|
|
55801
|
+
radius: figure === "square" ? Math.round(side / 5) : 0,
|
|
55802
|
+
fill: desc.color,
|
|
55803
|
+
stroke,
|
|
55804
|
+
lineWidth: line_width,
|
|
55805
|
+
lineDash: dash,
|
|
55806
|
+
halo: !!f.highlight,
|
|
55807
|
+
haloStroke: HIGHLIGHT_HALO,
|
|
55808
|
+
haloLineWidth: 8,
|
|
55809
|
+
port: false,
|
|
55810
|
+
ports: [],
|
|
55811
|
+
labelText: labels ? node_label(desc, record) : "",
|
|
55812
|
+
labelPlacement: "bottom",
|
|
55813
|
+
labelFontSize: 11,
|
|
55814
|
+
labelFill: dark ? "#e6e9ef" : "#2e333d",
|
|
55815
|
+
labelMaxWidth: 150,
|
|
55816
|
+
labelWordWrap: true,
|
|
55817
|
+
labelMaxLines: 1,
|
|
55818
|
+
labelTextOverflow: "ellipsis",
|
|
55819
|
+
labelBackground: true,
|
|
55820
|
+
labelBackgroundFill: dark ? "#1b2230" : "#ffffff",
|
|
55821
|
+
labelBackgroundOpacity: .85,
|
|
55822
|
+
labelBackgroundRadius: 3,
|
|
55823
|
+
labelPadding: [1, 3]
|
|
55824
|
+
};
|
|
55715
55825
|
return {
|
|
55716
|
-
type: "rect",
|
|
55717
|
-
style
|
|
55718
|
-
size: [side, side],
|
|
55719
|
-
radius: Math.round(side / 5),
|
|
55720
|
-
fill: desc.color,
|
|
55721
|
-
stroke,
|
|
55722
|
-
lineWidth: line_width,
|
|
55723
|
-
lineDash: dash,
|
|
55724
|
-
halo: !!f.highlight,
|
|
55725
|
-
haloStroke: HIGHLIGHT_HALO,
|
|
55726
|
-
haloLineWidth: 8,
|
|
55727
|
-
port: false,
|
|
55728
|
-
ports: [],
|
|
55729
|
-
labelText: labels ? node_label(desc, record) : "",
|
|
55730
|
-
labelPlacement: "bottom",
|
|
55731
|
-
labelFontSize: 11,
|
|
55732
|
-
labelFill: dark ? "#e6e9ef" : "#2e333d",
|
|
55733
|
-
labelMaxWidth: 150,
|
|
55734
|
-
labelWordWrap: true,
|
|
55735
|
-
labelMaxLines: 1,
|
|
55736
|
-
labelTextOverflow: "ellipsis",
|
|
55737
|
-
labelBackground: true,
|
|
55738
|
-
labelBackgroundFill: dark ? "#1b2230" : "#ffffff",
|
|
55739
|
-
labelBackgroundOpacity: .85,
|
|
55740
|
-
labelBackgroundRadius: 3,
|
|
55741
|
-
labelPadding: [1, 3]
|
|
55742
|
-
}
|
|
55826
|
+
type: figure === "square" ? "rect" : figure,
|
|
55827
|
+
style
|
|
55743
55828
|
};
|
|
55744
55829
|
}
|
|
55745
55830
|
/************************************************************
|
|
@@ -58505,6 +58590,14 @@ function show_node_popover(gobj) {
|
|
|
58505
58590
|
let strokeInput = create_form_color_input(popover, currentStroke, preview_node);
|
|
58506
58591
|
create_form_label(popover, "line width");
|
|
58507
58592
|
let lwInput = create_form_number_input(popover, currentLW, 1, 20, preview_node);
|
|
58593
|
+
create_form_label(popover, "shape");
|
|
58594
|
+
let shapeSelect = create_form_select(popover, NODE_SHAPES.map((shape) => {
|
|
58595
|
+
return {
|
|
58596
|
+
value: shape,
|
|
58597
|
+
label: (0, i18next.t)(shape)
|
|
58598
|
+
};
|
|
58599
|
+
}));
|
|
58600
|
+
shapeSelect.value = nodeData.data && nodeData.data.desc ? node_figure_of(gobj, nodeData.data.desc, nodeData.data.graph_props || {}) : DEFAULT_NODE_SHAPE;
|
|
58508
58601
|
create_form_label(popover, "apply to");
|
|
58509
58602
|
let scopeSelect = create_form_select(popover, [
|
|
58510
58603
|
{
|
|
@@ -58544,7 +58637,7 @@ function show_node_popover(gobj) {
|
|
|
58544
58637
|
text: "apply",
|
|
58545
58638
|
style: "flex:1;padding:6px;background:#1890ff;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;font-weight:500;",
|
|
58546
58639
|
onClick: () => {
|
|
58547
|
-
apply_node_properties(gobj, node_id, fillInput.value, strokeInput.value, parseInt(lwInput.value) || 1, scopeSelect.value);
|
|
58640
|
+
apply_node_properties(gobj, node_id, fillInput.value, strokeInput.value, parseInt(lwInput.value) || 1, scopeSelect.value, shapeSelect.value);
|
|
58548
58641
|
}
|
|
58549
58642
|
}]);
|
|
58550
58643
|
priv.$container.appendChild(popover);
|
|
@@ -58775,10 +58868,11 @@ function repaint_cards(gobj, ids) {
|
|
|
58775
58868
|
continue;
|
|
58776
58869
|
}
|
|
58777
58870
|
let anchored = priv.anchor_state === "on" && id === priv.anchor_id;
|
|
58778
|
-
|
|
58871
|
+
let mode = nd && nd.data && nd.data.desc ? node_mode_of(gobj, id) : "expanded";
|
|
58872
|
+
if (mode === "shape") {
|
|
58779
58873
|
updates.push({
|
|
58780
58874
|
id,
|
|
58781
|
-
style:
|
|
58875
|
+
style: figure_shape_of(gobj, nd.data.desc, nd.data.record || {}, nd.data.graph_props || {}, {
|
|
58782
58876
|
highlight: focus.has(id),
|
|
58783
58877
|
selected: selected.has(id),
|
|
58784
58878
|
anchored
|
|
@@ -58786,7 +58880,7 @@ function repaint_cards(gobj, ids) {
|
|
|
58786
58880
|
});
|
|
58787
58881
|
continue;
|
|
58788
58882
|
}
|
|
58789
|
-
let html = node_innerHTML_of(nd, priv.theme, focus.has(id), selected.has(id), anchored, pills_html_of(gobj, nd));
|
|
58883
|
+
let html = mode === "compact" ? pill_innerHTML_of(gobj, nd, priv.theme, focus.has(id), selected.has(id), anchored) : node_innerHTML_of(nd, priv.theme, focus.has(id), selected.has(id), anchored, pills_html_of(gobj, nd));
|
|
58790
58884
|
if (html !== null) updates.push({
|
|
58791
58885
|
id,
|
|
58792
58886
|
style: { innerHTML: html }
|
|
@@ -58824,10 +58918,11 @@ function refresh_html_nodes_theme(gobj, theme) {
|
|
|
58824
58918
|
let id = nodes[i].id;
|
|
58825
58919
|
let nd = graph.getNodeData(id);
|
|
58826
58920
|
let anchored = priv.anchor_state === "on" && id === priv.anchor_id;
|
|
58827
|
-
|
|
58921
|
+
let mode = nd && nd.data && nd.data.desc ? node_mode_of(gobj, id) : "expanded";
|
|
58922
|
+
if (mode === "shape") {
|
|
58828
58923
|
updates.push({
|
|
58829
58924
|
id,
|
|
58830
|
-
style:
|
|
58925
|
+
style: figure_shape_of(gobj, nd.data.desc, nd.data.record || {}, nd.data.graph_props || {}, {
|
|
58831
58926
|
highlight: highlighted.has(id),
|
|
58832
58927
|
selected: selected.has(id),
|
|
58833
58928
|
anchored
|
|
@@ -58835,7 +58930,7 @@ function refresh_html_nodes_theme(gobj, theme) {
|
|
|
58835
58930
|
});
|
|
58836
58931
|
continue;
|
|
58837
58932
|
}
|
|
58838
|
-
let html = node_innerHTML_of(nd, theme, highlighted.has(id), selected.has(id), anchored, pills_html_of(gobj, nd));
|
|
58933
|
+
let html = mode === "compact" ? pill_innerHTML_of(gobj, nd, theme, highlighted.has(id), selected.has(id), anchored) : node_innerHTML_of(nd, theme, highlighted.has(id), selected.has(id), anchored, pills_html_of(gobj, nd));
|
|
58839
58934
|
if (html === null) html = more_innerHTML_of(gobj, nd, theme);
|
|
58840
58935
|
if (html !== null) updates.push({
|
|
58841
58936
|
id,
|
|
@@ -59293,7 +59388,7 @@ function hide_unlink_confirm(gobj) {
|
|
|
59293
59388
|
* Apply node properties to one or more nodes.
|
|
59294
59389
|
* scope: 'this', 'same_topic', 'all'
|
|
59295
59390
|
************************************************************/
|
|
59296
|
-
function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope) {
|
|
59391
|
+
function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope, shape) {
|
|
59297
59392
|
let priv = gobj.priv;
|
|
59298
59393
|
let graph = priv.graph;
|
|
59299
59394
|
let nodeData = graph.getNodeData(node_id);
|
|
@@ -59301,11 +59396,26 @@ function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope) {
|
|
|
59301
59396
|
let source_topic = nodeData.data.desc ? nodeData.data.desc.topic_name : null;
|
|
59302
59397
|
let updates = [];
|
|
59303
59398
|
const nodes = graph.getData().nodes;
|
|
59399
|
+
let figure = shape && (0, _yuneta_gobj_js.str_in_list)(NODE_SHAPES, shape) ? shape : "";
|
|
59400
|
+
let reshaped = [];
|
|
59401
|
+
if (figure && scope !== "this") {
|
|
59402
|
+
let topics = scope === "same_topic" ? [source_topic] : Object.keys(priv.descs || {});
|
|
59403
|
+
for (let topic_name of topics) {
|
|
59404
|
+
if (!(0, _yuneta_gobj_js.is_object)(priv._graph_properties[topic_name])) priv._graph_properties[topic_name] = {};
|
|
59405
|
+
let defaults = priv._graph_properties[topic_name].defaults || {};
|
|
59406
|
+
defaults.node_shape = figure;
|
|
59407
|
+
priv._graph_properties[topic_name].defaults = defaults;
|
|
59408
|
+
}
|
|
59409
|
+
}
|
|
59304
59410
|
for (let i = 0; i < nodes.length; i++) {
|
|
59305
59411
|
let nd = graph.getNodeData(nodes[i].id);
|
|
59306
59412
|
if (!nd || !nd.data || !nd.data.desc) continue;
|
|
59307
59413
|
if (scope === "this" && nodes[i].id !== node_id) continue;
|
|
59308
59414
|
if (scope === "same_topic" && nd.data.desc.topic_name !== source_topic) continue;
|
|
59415
|
+
if (figure) {
|
|
59416
|
+
node_props_entry(gobj, nd).node_shape = figure;
|
|
59417
|
+
if (node_mode_of(gobj, nodes[i].id) === "shape") reshaped.push(nodes[i].id);
|
|
59418
|
+
}
|
|
59309
59419
|
let updateStyle = {
|
|
59310
59420
|
fill,
|
|
59311
59421
|
stroke,
|
|
@@ -59322,6 +59432,7 @@ function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope) {
|
|
|
59322
59432
|
}
|
|
59323
59433
|
if (updates.length > 0) {
|
|
59324
59434
|
graph.updateNodeData(updates);
|
|
59435
|
+
if (reshaped.length) reshape_nodes(gobj, reshaped);
|
|
59325
59436
|
graph.draw().then(() => {
|
|
59326
59437
|
mark_graph_dirty(gobj);
|
|
59327
59438
|
});
|
|
@@ -59329,6 +59440,23 @@ function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope) {
|
|
|
59329
59440
|
hide_node_popover(gobj);
|
|
59330
59441
|
}
|
|
59331
59442
|
/************************************************************
|
|
59443
|
+
* The node's entry in `_graph_properties` -- the object Save
|
|
59444
|
+
* reads and writes -- created if it has none yet, and the node's
|
|
59445
|
+
* `data.graph_props` pointed at it, so a key written here is
|
|
59446
|
+
* read by the next reshape and survives the next Save.
|
|
59447
|
+
************************************************************/
|
|
59448
|
+
function node_props_entry(gobj, nd) {
|
|
59449
|
+
let priv = gobj.priv;
|
|
59450
|
+
let topic_name = nd.data.topic_name;
|
|
59451
|
+
let record = nd.data.record || {};
|
|
59452
|
+
if (!(0, _yuneta_gobj_js.is_object)(priv._graph_properties[topic_name])) priv._graph_properties[topic_name] = {};
|
|
59453
|
+
let topic_props = priv._graph_properties[topic_name];
|
|
59454
|
+
if (!(0, _yuneta_gobj_js.is_object)(topic_props.nodes)) topic_props.nodes = {};
|
|
59455
|
+
if (!(0, _yuneta_gobj_js.is_object)(topic_props.nodes[record.id])) topic_props.nodes[record.id] = (0, _yuneta_gobj_js.is_object)(nd.data.graph_props) ? nd.data.graph_props : {};
|
|
59456
|
+
nd.data.graph_props = topic_props.nodes[record.id];
|
|
59457
|
+
return nd.data.graph_props;
|
|
59458
|
+
}
|
|
59459
|
+
/************************************************************
|
|
59332
59460
|
* Apply edge properties to one or more edges.
|
|
59333
59461
|
* scope: 'this', 'same_type', 'all'
|
|
59334
59462
|
************************************************************/
|
|
@@ -59456,8 +59584,8 @@ function ctx_item(icon_id, label, value) {
|
|
|
59456
59584
|
function build_node_context_menu(gobj, node_id) {
|
|
59457
59585
|
let items = [];
|
|
59458
59586
|
inject_svg_icons();
|
|
59459
|
-
if (node_is_compact(gobj, node_id)) items.push(ctx_item("g6-icon-fullscreen", (0, i18next.t)("
|
|
59460
|
-
else items.push(ctx_item("g6-icon-fullscreen-exit", (0, i18next.t)("
|
|
59587
|
+
if (node_is_compact(gobj, node_id)) items.push(ctx_item("g6-icon-fullscreen", (0, i18next.t)("expand node"), "toggle_node_mode"));
|
|
59588
|
+
else items.push(ctx_item("g6-icon-fullscreen-exit", (0, i18next.t)("collapse node"), "toggle_node_mode"));
|
|
59461
59589
|
if (gobj.priv.edit_mode && !node_is_compact(gobj, node_id)) {
|
|
59462
59590
|
items.push(ctx_item("g6-icon-resize", (0, i18next.t)("resize all"), "resize_all_nodes"));
|
|
59463
59591
|
items.push(ctx_item("g6-icon-resize", (0, i18next.t)("resize topic nodes"), "resize_topic_nodes"));
|
|
@@ -59696,7 +59824,7 @@ var MORE_CHIP_SIZE_COMPACT = [40, 22];
|
|
|
59696
59824
|
function more_chip_is_compact(gobj, nd) {
|
|
59697
59825
|
let parent_id = nd && nd.data ? nd.data.parent_node : "";
|
|
59698
59826
|
if (parent_id) return node_is_compact(gobj, parent_id);
|
|
59699
|
-
return (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "node_mode")
|
|
59827
|
+
return (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "node_mode") !== "expanded";
|
|
59700
59828
|
}
|
|
59701
59829
|
function more_chip_style(gobj, nd, color, rest) {
|
|
59702
59830
|
let compact = more_chip_is_compact(gobj, nd);
|
|
@@ -60747,9 +60875,9 @@ function ac_set_loose_topics(gobj, event, kw, src) {
|
|
|
60747
60875
|
* and lays the graph out again, because a square and a card
|
|
60748
60876
|
* do not occupy the same room.
|
|
60749
60877
|
************************************************************/
|
|
60750
|
-
function ac_set_node_mode(gobj, event, kw, src) {
|
|
60878
|
+
function ac_set_node_mode$1(gobj, event, kw, src) {
|
|
60751
60879
|
let priv = gobj.priv;
|
|
60752
|
-
let mode = kw && kw.node_mode
|
|
60880
|
+
let mode = kw && kw.node_mode && (0, _yuneta_gobj_js.str_in_list)(NODE_MODES$1, kw.node_mode) ? kw.node_mode : "expanded";
|
|
60753
60881
|
(0, _yuneta_gobj_js.gobj_write_str_attr)(gobj, "node_mode", mode);
|
|
60754
60882
|
priv._open_nodes = /* @__PURE__ */ new Set();
|
|
60755
60883
|
if (!priv.graph || !priv._fold_model) return 0;
|
|
@@ -60762,15 +60890,15 @@ function ac_set_node_mode(gobj, event, kw, src) {
|
|
|
60762
60890
|
return 0;
|
|
60763
60891
|
}
|
|
60764
60892
|
/************************************************************
|
|
60765
|
-
* The name under a
|
|
60766
|
-
*
|
|
60767
|
-
*
|
|
60893
|
+
* The name under a figure, on or off. Only the `shape` nodes
|
|
60894
|
+
* change, and nothing moves: the label hangs outside the figure
|
|
60895
|
+
* and the layout measures the figure.
|
|
60768
60896
|
************************************************************/
|
|
60769
60897
|
function ac_set_node_labels(gobj, event, kw, src) {
|
|
60770
60898
|
let priv = gobj.priv;
|
|
60771
60899
|
(0, _yuneta_gobj_js.gobj_write_bool_attr)(gobj, "node_labels", !!(kw && kw.node_labels));
|
|
60772
60900
|
if (!priv.graph) return 0;
|
|
60773
|
-
reshape_nodes(gobj, all_record_node_ids(gobj).filter((id) =>
|
|
60901
|
+
reshape_nodes(gobj, all_record_node_ids(gobj).filter((id) => node_mode_of(gobj, id) === "shape"));
|
|
60774
60902
|
return 0;
|
|
60775
60903
|
}
|
|
60776
60904
|
/************************************************************
|
|
@@ -60778,7 +60906,7 @@ function ac_set_node_labels(gobj, event, kw, src) {
|
|
|
60778
60906
|
* or the context menu). It holds still on screen while the
|
|
60779
60907
|
* rest of the graph makes room, as a fold does.
|
|
60780
60908
|
************************************************************/
|
|
60781
|
-
function ac_toggle_node_mode
|
|
60909
|
+
function ac_toggle_node_mode(gobj, event, kw, src) {
|
|
60782
60910
|
let priv = gobj.priv;
|
|
60783
60911
|
let node_id = kw && kw.id || "";
|
|
60784
60912
|
if (!priv.graph || !node_id) {
|
|
@@ -61307,7 +61435,7 @@ function create_gclass$4(gclass_name) {
|
|
|
61307
61435
|
],
|
|
61308
61436
|
[
|
|
61309
61437
|
"EV_SET_NODE_MODE",
|
|
61310
|
-
ac_set_node_mode,
|
|
61438
|
+
ac_set_node_mode$1,
|
|
61311
61439
|
null
|
|
61312
61440
|
],
|
|
61313
61441
|
[
|
|
@@ -61317,7 +61445,7 @@ function create_gclass$4(gclass_name) {
|
|
|
61317
61445
|
],
|
|
61318
61446
|
[
|
|
61319
61447
|
"EV_TOGGLE_NODE_MODE",
|
|
61320
|
-
ac_toggle_node_mode
|
|
61448
|
+
ac_toggle_node_mode,
|
|
61321
61449
|
null
|
|
61322
61450
|
],
|
|
61323
61451
|
[
|
|
@@ -61498,8 +61626,8 @@ var attrs_table$3 = [
|
|
|
61498
61626
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_LIST, "hidden_topics", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, "[]", "Topics hidden from the graph (legend). User preference, per treedb"),
|
|
61499
61627
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "main_topic", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, "", "The topic the tree hangs from; empty = deduced by the graph. User preference, per treedb"),
|
|
61500
61628
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_LIST, "loose_topics", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, "[]", "Topics whose LOOSE records (no parent) are shown. User preference, per treedb"),
|
|
61501
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "node_mode", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, "expanded", "How the records are drawn: `expanded` = the cards with their ports, `compact` = coloured
|
|
61502
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "node_labels", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, true, "A
|
|
61629
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "node_mode", _yuneta_gobj_js.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"),
|
|
61630
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "node_labels", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, true, "A `shape` node says its name under its figure. User preference"),
|
|
61503
61631
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "Remote Yuno to request data"),
|
|
61504
61632
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "treedb_name", 0, null, "Remote service treedb name"),
|
|
61505
61633
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_DICT, "descs", 0, null, "Descriptions of topics obtained"),
|
|
@@ -61783,44 +61911,96 @@ function option_label(name) {
|
|
|
61783
61911
|
* its context menu (the child's business).
|
|
61784
61912
|
************************************************************/
|
|
61785
61913
|
function node_shape_items(gobj, wide) {
|
|
61786
|
-
|
|
61787
|
-
|
|
61788
|
-
|
|
61789
|
-
|
|
61790
|
-
|
|
61791
|
-
|
|
61792
|
-
|
|
61793
|
-
|
|
61794
|
-
|
|
61914
|
+
return [[
|
|
61915
|
+
"div",
|
|
61916
|
+
{
|
|
61917
|
+
class: "GRAPH_NODE_MODE buttons has-addons",
|
|
61918
|
+
style: "margin:0 0 0 .5rem; flex:0 0 auto; flex-wrap:nowrap;"
|
|
61919
|
+
},
|
|
61920
|
+
NODE_MODES.map((mode) => {
|
|
61921
|
+
let key = NODE_MODE_LABELS[mode];
|
|
61922
|
+
return [
|
|
61923
|
+
"button",
|
|
61924
|
+
{
|
|
61925
|
+
class: "GRAPH_NODE_MODE_BTN button",
|
|
61926
|
+
type: "button",
|
|
61927
|
+
"data-mode": mode,
|
|
61928
|
+
style: {
|
|
61929
|
+
height: wide,
|
|
61930
|
+
width: "2.5em"
|
|
61931
|
+
},
|
|
61932
|
+
title: (0, i18next.t)(key),
|
|
61933
|
+
"data-i18n-title": key,
|
|
61934
|
+
"aria-label": (0, i18next.t)(key),
|
|
61935
|
+
"data-i18n-aria-label": key,
|
|
61936
|
+
"aria-pressed": "false"
|
|
61795
61937
|
},
|
|
61796
|
-
|
|
61797
|
-
|
|
61798
|
-
|
|
61799
|
-
|
|
61800
|
-
|
|
61938
|
+
["i", {
|
|
61939
|
+
style: "font-size:1.5em; color:inherit;",
|
|
61940
|
+
class: NODE_MODE_ICONS[mode]
|
|
61941
|
+
}],
|
|
61942
|
+
{ click: (evt) => {
|
|
61943
|
+
evt.stopPropagation();
|
|
61944
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_NODE_MODE", { node_mode: mode }, gobj);
|
|
61945
|
+
} }
|
|
61946
|
+
];
|
|
61947
|
+
})
|
|
61948
|
+
], [
|
|
61949
|
+
"button",
|
|
61950
|
+
{
|
|
61951
|
+
class: "GRAPH_NODE_LABELS button",
|
|
61952
|
+
type: "button",
|
|
61953
|
+
style: {
|
|
61954
|
+
height: wide,
|
|
61955
|
+
width: "2.5em"
|
|
61801
61956
|
},
|
|
61802
|
-
|
|
61803
|
-
|
|
61804
|
-
|
|
61805
|
-
|
|
61806
|
-
|
|
61807
|
-
|
|
61808
|
-
|
|
61809
|
-
|
|
61810
|
-
|
|
61811
|
-
|
|
61812
|
-
|
|
61957
|
+
title: (0, i18next.t)("node labels"),
|
|
61958
|
+
"data-i18n-title": "node labels",
|
|
61959
|
+
"aria-label": (0, i18next.t)("node labels"),
|
|
61960
|
+
"data-i18n-aria-label": "node labels",
|
|
61961
|
+
"aria-pressed": "false"
|
|
61962
|
+
},
|
|
61963
|
+
["i", {
|
|
61964
|
+
style: "font-size:1.5em; color:inherit;",
|
|
61965
|
+
class: "yi-font"
|
|
61966
|
+
}],
|
|
61967
|
+
{ click: (evt) => {
|
|
61968
|
+
evt.stopPropagation();
|
|
61969
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
|
|
61970
|
+
} }
|
|
61971
|
+
]];
|
|
61813
61972
|
}
|
|
61973
|
+
var NODE_MODES = [
|
|
61974
|
+
"expanded",
|
|
61975
|
+
"compact",
|
|
61976
|
+
"shape"
|
|
61977
|
+
];
|
|
61978
|
+
var NODE_MODE_LABELS = {
|
|
61979
|
+
expanded: "full",
|
|
61980
|
+
compact: "compact",
|
|
61981
|
+
shape: "shape"
|
|
61982
|
+
};
|
|
61983
|
+
var NODE_MODE_ICONS = {
|
|
61984
|
+
expanded: "yi-square",
|
|
61985
|
+
compact: "yi-bars",
|
|
61986
|
+
shape: "yi-hexagon-nodes"
|
|
61987
|
+
};
|
|
61814
61988
|
function refresh_node_shape_buttons(gobj, $root) {
|
|
61815
61989
|
if (!$root) return;
|
|
61816
|
-
let
|
|
61990
|
+
let mode = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "node_mode");
|
|
61991
|
+
if (!NODE_MODES.includes(mode)) mode = "expanded";
|
|
61817
61992
|
let labels = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "node_labels");
|
|
61818
|
-
|
|
61993
|
+
for (let $btn of $root.querySelectorAll(".GRAPH_NODE_MODE_BTN")) {
|
|
61994
|
+
let on = $btn.getAttribute("data-mode") === mode;
|
|
61995
|
+
$btn.classList.toggle("pressed_state", on);
|
|
61996
|
+
$btn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
61997
|
+
}
|
|
61819
61998
|
set_pressed_state($root, ".GRAPH_NODE_LABELS", labels);
|
|
61820
|
-
let $mode = $root.querySelector(".GRAPH_NODE_MODE");
|
|
61821
|
-
if ($mode) $mode.setAttribute("aria-pressed", compact ? "true" : "false");
|
|
61822
61999
|
let $labels = $root.querySelector(".GRAPH_NODE_LABELS");
|
|
61823
|
-
if ($labels)
|
|
62000
|
+
if ($labels) {
|
|
62001
|
+
$labels.setAttribute("aria-pressed", labels ? "true" : "false");
|
|
62002
|
+
$labels.disabled = mode !== "shape";
|
|
62003
|
+
}
|
|
61824
62004
|
}
|
|
61825
62005
|
function make_toolbar(gobj) {
|
|
61826
62006
|
let priv = gobj.priv;
|
|
@@ -63207,13 +63387,13 @@ function ac_collapse_all(gobj, event, kw, src) {
|
|
|
63207
63387
|
return 0;
|
|
63208
63388
|
}
|
|
63209
63389
|
/************************************************************
|
|
63210
|
-
* The
|
|
63211
|
-
*
|
|
63212
|
-
* the nodes.
|
|
63390
|
+
* The view of the nodes and the labels toggle of the toolbar:
|
|
63391
|
+
* the attr changes, persists, shows on the control, and reaches
|
|
63392
|
+
* the G6 child, which owns the nodes.
|
|
63213
63393
|
************************************************************/
|
|
63214
|
-
function
|
|
63394
|
+
function ac_set_node_mode(gobj, event, kw, src) {
|
|
63215
63395
|
let priv = gobj.priv;
|
|
63216
|
-
let mode =
|
|
63396
|
+
let mode = kw && NODE_MODES.includes(kw.node_mode) ? kw.node_mode : "expanded";
|
|
63217
63397
|
(0, _yuneta_gobj_js.gobj_write_str_attr)(gobj, "node_mode", mode);
|
|
63218
63398
|
(0, _yuneta_gobj_js.gobj_save_persistent_attrs)(gobj, "node_mode");
|
|
63219
63399
|
refresh_node_shape_buttons(gobj, priv.$container);
|
|
@@ -63444,8 +63624,8 @@ function create_gclass$3(gclass_name) {
|
|
|
63444
63624
|
null
|
|
63445
63625
|
],
|
|
63446
63626
|
[
|
|
63447
|
-
"
|
|
63448
|
-
|
|
63627
|
+
"EV_SET_NODE_MODE",
|
|
63628
|
+
ac_set_node_mode,
|
|
63449
63629
|
null
|
|
63450
63630
|
],
|
|
63451
63631
|
[
|
|
@@ -63517,7 +63697,7 @@ function create_gclass$3(gclass_name) {
|
|
|
63517
63697
|
["EV_FIND_NODES", 0],
|
|
63518
63698
|
["EV_EXPAND_ALL", 0],
|
|
63519
63699
|
["EV_COLLAPSE_ALL", 0],
|
|
63520
|
-
["
|
|
63700
|
+
["EV_SET_NODE_MODE", 0],
|
|
63521
63701
|
["EV_TOGGLE_NODE_LABELS", 0],
|
|
63522
63702
|
["EV_FIND_RESULT", 0],
|
|
63523
63703
|
["EV_LAYOUT_AUTOSET", 0],
|