@yuneta/gobj-ui 7.23.84 → 7.23.86

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.
@@ -10555,6 +10555,30 @@ function getPointPosition(count, index, margin = .2) {
10555
10555
  * All Rights Reserved.
10556
10556
  ***********************************************************************/
10557
10557
  /************************************************************
10558
+ * ONE size for every glyph of a graph's toolbar ROW, in
10559
+ * `rem` and not `em`.
10560
+ *
10561
+ * In `em` the same declaration draws three different icons:
10562
+ * `1.5em` is 24px inside a plain button, 18px inside an
10563
+ * `is-small` one, and a labelled button left its icon at the
10564
+ * inherited 16px -- so one row held 16px, 18px and 24px
10565
+ * glyphs and looked like three toolbars pushed together.
10566
+ * `rem` is measured against the page, so a chip that is
10567
+ * deliberately shorter than a button still carries the same
10568
+ * glyph.
10569
+ *
10570
+ * 20px against the row's 16px text: an icon-only button is
10571
+ * legible at half its 40px height, and beside a label the
10572
+ * glyph reads as a marker rather than as a second word.
10573
+ ************************************************************/
10574
+ var YUI_GRAPH_ICON_SIZE = "1.25rem";
10575
+ function yui_graph_icon(icon_class, extra_style) {
10576
+ return ["i", {
10577
+ class: icon_class,
10578
+ style: `font-size:${YUI_GRAPH_ICON_SIZE}; line-height:1; color:inherit;` + (extra_style || "")
10579
+ }];
10580
+ }
10581
+ /************************************************************
10558
10582
  * One icon button that fires `event_name`.
10559
10583
  ************************************************************/
10560
10584
  function camera_button(gobj, icon, event_name, label_key, wide, extra_style) {
@@ -10572,10 +10596,7 @@ function camera_button(gobj, icon, event_name, label_key, wide, extra_style) {
10572
10596
  "aria-label": t(label_key),
10573
10597
  "data-i18n-aria-label": label_key
10574
10598
  },
10575
- ["i", {
10576
- style: "font-size:1.5em; color:inherit;" + (extra_style || ""),
10577
- class: icon
10578
- }],
10599
+ yui_graph_icon(icon, extra_style),
10579
10600
  { click: (evt) => {
10580
10601
  evt.stopPropagation();
10581
10602
  gobj_send_event(gobj, event_name, { evt }, gobj);
@@ -11668,7 +11689,7 @@ function make_toolbar$5(gobj) {
11668
11689
  [$find_input, [
11669
11690
  "span",
11670
11691
  { class: "icon is-left" },
11671
- [["i", { class: "yi-magnifying-glass" }]]
11692
+ [yui_graph_icon("yi-magnifying-glass")]
11672
11693
  ]]
11673
11694
  ]);
11674
11695
  attach_clear($find_control, $find_input);
@@ -18110,7 +18131,7 @@ function make_find_items(gobj) {
18110
18131
  [$find_input, [
18111
18132
  "span",
18112
18133
  { class: "icon is-left" },
18113
- [["i", { class: "yi-magnifying-glass" }]]
18134
+ [yui_graph_icon("yi-magnifying-glass")]
18114
18135
  ]]
18115
18136
  ]);
18116
18137
  attach_clear($find_control, $find_input);
@@ -55651,6 +55672,52 @@ function topic_defaults_of(gobj, topic_name) {
55651
55672
  return is_object(topic_props) && is_object(topic_props.defaults) ? topic_props.defaults : null;
55652
55673
  }
55653
55674
  /************************************************************
55675
+ * What a node is PAINTED with: its own colours, then the
55676
+ * topic's default, then the topic's colour.
55677
+ *
55678
+ * A card is html, and its html was built with `desc.color`
55679
+ * every time it was repainted -- so a colour chosen in the node
55680
+ * properties popover lasted until the next selection, focus,
55681
+ * theme or pill change, and was never written to `__graphs__`
55682
+ * at all. Only the `shape` view kept it, because a figure is a
55683
+ * native G6 node and `style.fill` is what paints it. The FIGURE
55684
+ * was already remembered (`node_shape`); this is the wiring the
55685
+ * colour was missing.
55686
+ ************************************************************/
55687
+ function node_paint_of(gobj, desc, geometry) {
55688
+ let defaults = topic_defaults_of(gobj, desc.topic_name);
55689
+ let g = is_object(geometry) ? geometry : {};
55690
+ let fill = g.fill || defaults && defaults.fill || desc.color;
55691
+ return {
55692
+ fill,
55693
+ stroke: g.stroke || defaults && defaults.stroke || getStrokeColor(fill),
55694
+ lineWidth: g.lineWidth || defaults && defaults.lineWidth || 1
55695
+ };
55696
+ }
55697
+ /************************************************************
55698
+ * Write a chosen paint into an entry of `__graphs__` -- a
55699
+ * node's or a topic's defaults.
55700
+ *
55701
+ * A colour nobody chose is not saved: the topic's own colour,
55702
+ * with the stroke and the line width that go with it, is what a
55703
+ * card wears anyway, and writing it down would freeze today's
55704
+ * palette on that card -- the trap the SIZES fell into in
55705
+ * 7.23.80, and the palette is assigned by POSITION (`ac_descs`),
55706
+ * so it moves when a topic is added. Choosing it back MEANS
55707
+ * forgetting the entry.
55708
+ ************************************************************/
55709
+ function paint_into(entry, desc, fill, stroke, line_width) {
55710
+ if (fill === desc.color && stroke === getStrokeColor(desc.color) && line_width === 1) {
55711
+ delete entry.fill;
55712
+ delete entry.stroke;
55713
+ delete entry.lineWidth;
55714
+ return;
55715
+ }
55716
+ entry.fill = fill;
55717
+ entry.stroke = stroke;
55718
+ entry.lineWidth = line_width;
55719
+ }
55720
+ /************************************************************
55654
55721
  * The CARD: an html node, the tier's size, the ports, the
55655
55722
  * saved geometry on top. The flags (focus, selection, anchor)
55656
55723
  * are not painted here: repaint_cards() reads them where they
@@ -55661,10 +55728,11 @@ function card_shape_of(gobj, desc, record, geometry, pills_html) {
55661
55728
  let node_treedb_type = desc.node_treedb_type;
55662
55729
  let label = node_label(desc, record);
55663
55730
  let ports = build_ports(gobj, desc);
55731
+ let paint = node_paint_of(gobj, desc, geometry);
55664
55732
  let style = {
55665
- fill: desc.color,
55666
- stroke: getStrokeColor(desc.color),
55667
- lineWidth: 1,
55733
+ fill: paint.fill,
55734
+ stroke: paint.stroke,
55735
+ lineWidth: paint.lineWidth,
55668
55736
  lineDash: [],
55669
55737
  halo: false,
55670
55738
  labelText: ""
@@ -55673,9 +55741,9 @@ function card_shape_of(gobj, desc, record, geometry, pills_html) {
55673
55741
  style.size = size;
55674
55742
  style.dx = -size[0] / 2;
55675
55743
  style.dy = -size[1] / 2;
55676
- if (node_treedb_type === "child") style.innerHTML = build_chip_innerHTML(desc.color, priv.theme, record.icon, label, record.id);
55677
- else if (node_treedb_type === "extended") style.innerHTML = build_node_innerHTML(desc.color, priv.theme, record.icon, label, desc.topic_name, true, record.id, false, false, false, pills_html);
55678
- else style.innerHTML = build_node_innerHTML(desc.color, priv.theme, record.icon, label, desc.topic_name, false, record.id, false, false, false, pills_html);
55744
+ if (node_treedb_type === "child") style.innerHTML = build_chip_innerHTML(paint.fill, priv.theme, record.icon, label, record.id);
55745
+ else if (node_treedb_type === "extended") style.innerHTML = build_node_innerHTML(paint.fill, priv.theme, record.icon, label, desc.topic_name, true, record.id, false, false, false, pills_html);
55746
+ else style.innerHTML = build_node_innerHTML(paint.fill, priv.theme, record.icon, label, desc.topic_name, false, record.id, false, false, false, pills_html);
55679
55747
  let topic_props = priv._graph_properties[desc.topic_name];
55680
55748
  let topic_defaults = is_object(topic_props) && is_object(topic_props.defaults) ? topic_props.defaults : null;
55681
55749
  if (topic_defaults) {
@@ -55747,17 +55815,18 @@ function pill_shape_of(gobj, desc, record, geometry) {
55747
55815
  let priv = gobj.priv;
55748
55816
  let size = PILL_SIZE[desc.node_treedb_type] || PILL_SIZE.hierarchical;
55749
55817
  let ports = build_ports(gobj, desc);
55818
+ let paint = node_paint_of(gobj, desc, geometry);
55750
55819
  let style = {
55751
- fill: desc.color,
55752
- stroke: getStrokeColor(desc.color),
55753
- lineWidth: 1,
55820
+ fill: paint.fill,
55821
+ stroke: paint.stroke,
55822
+ lineWidth: paint.lineWidth,
55754
55823
  lineDash: [],
55755
55824
  halo: false,
55756
55825
  labelText: "",
55757
55826
  size: [...size],
55758
55827
  dx: -size[0] / 2,
55759
55828
  dy: -size[1] / 2,
55760
- innerHTML: build_chip_innerHTML(desc.color, priv.theme, record.icon, node_label(desc, record), record.id)
55829
+ innerHTML: build_chip_innerHTML(paint.fill, priv.theme, record.icon, node_label(desc, record), record.id)
55761
55830
  };
55762
55831
  dress_ports(gobj, style, ports, geometry, topic_defaults_of(gobj, desc.topic_name), PORT_R_PILL, true);
55763
55832
  return {
@@ -55768,7 +55837,7 @@ function pill_shape_of(gobj, desc, record, geometry) {
55768
55837
  function pill_innerHTML_of(gobj, nd, theme, highlight, selected, anchored) {
55769
55838
  let desc = nd.data.desc;
55770
55839
  let record = nd.data.record || {};
55771
- return build_chip_innerHTML(desc.color, theme, record.icon, node_label(desc, record), record.id, highlight, selected, anchored);
55840
+ return build_chip_innerHTML(node_fill_of(nd), theme, record.icon, node_label(desc, record), record.id, highlight, selected, anchored);
55772
55841
  }
55773
55842
  function node_figure_of(gobj, desc, geometry) {
55774
55843
  let shape = geometry ? geometry.node_shape : null;
@@ -55795,8 +55864,9 @@ function figure_shape_of(gobj, desc, record, geometry, flags) {
55795
55864
  let side = SHAPE_SIZE[tier] || SHAPE_SIZE.hierarchical;
55796
55865
  let labels = gobj_read_bool_attr(gobj, "node_labels");
55797
55866
  let figure = node_figure_of(gobj, desc, geometry || {});
55798
- let stroke = getStrokeColor(desc.color);
55799
- let line_width = 1.5;
55867
+ let paint = node_paint_of(gobj, desc, geometry);
55868
+ let stroke = paint.stroke;
55869
+ let line_width = Math.max(paint.lineWidth, 1.5);
55800
55870
  if (f.selected) {
55801
55871
  stroke = SELECT_RING;
55802
55872
  line_width = 3;
@@ -55814,7 +55884,7 @@ function figure_shape_of(gobj, desc, record, geometry, flags) {
55814
55884
  let style = {
55815
55885
  size: [side, side],
55816
55886
  radius: figure === "square" ? Math.round(side / 5) : 0,
55817
- fill: desc.color,
55887
+ fill: paint.fill,
55818
55888
  stroke,
55819
55889
  lineWidth: line_width,
55820
55890
  lineDash: dash,
@@ -58639,39 +58709,23 @@ function show_node_popover(gobj) {
58639
58709
  let rect = get_node_viewport_rect(gobj, node_id);
58640
58710
  if (!rect) return;
58641
58711
  const popover = create_popover_base(rect.right + floating_popover_dx(), rect.top + floating_icon_dy(), "g6-node-popover", "#d9d9d9", 180);
58642
- let node_graph_type = nodeData.data && nodeData.data.desc ? nodeData.data.desc.node_treedb_type : null;
58643
- let undo_node = () => {
58644
- let restoreStyle = {
58645
- fill: origFill,
58646
- stroke: origStroke,
58647
- lineWidth: origLW
58648
- };
58649
- if (node_graph_type === "hierarchical") {
58650
- let record = nodeData.data.record || {};
58651
- restoreStyle.innerHTML = build_node_innerHTML(origFill, priv.theme, record.icon, node_label(nodeData.data.desc, record), nodeData.data.desc.topic_name, false, record.id, false, false, false, pills_html_of(gobj, nodeData));
58652
- }
58712
+ let paint_node = (fill, stroke, lw) => {
58653
58713
  graph.updateNodeData([{
58654
58714
  id: node_id,
58655
- style: restoreStyle
58715
+ style: {
58716
+ fill,
58717
+ stroke,
58718
+ lineWidth: lw
58719
+ }
58656
58720
  }]);
58721
+ repaint_cards(gobj, /* @__PURE__ */ new Set([node_id]));
58657
58722
  graph.draw();
58658
58723
  };
58724
+ let undo_node = () => {
58725
+ paint_node(origFill, origStroke, origLW);
58726
+ };
58659
58727
  function preview_node() {
58660
- let fill = fillInput.value;
58661
- let updateStyle = {
58662
- fill,
58663
- stroke: strokeInput.value,
58664
- lineWidth: parseInt(lwInput.value) || 1
58665
- };
58666
- if (node_graph_type === "hierarchical") {
58667
- let record = nodeData.data.record || {};
58668
- updateStyle.innerHTML = build_node_innerHTML(fill, priv.theme, record.icon, node_label(nodeData.data.desc, record), nodeData.data.desc.topic_name, false, record.id, false, false, false, pills_html_of(gobj, nodeData));
58669
- }
58670
- graph.updateNodeData([{
58671
- id: node_id,
58672
- style: updateStyle
58673
- }]);
58674
- graph.draw();
58728
+ paint_node(fillInput.value, strokeInput.value, parseInt(lwInput.value) || 1);
58675
58729
  }
58676
58730
  create_form_label(popover, "fill color");
58677
58731
  let fillInput = create_form_color_input(popover, currentFill, preview_node);
@@ -58910,15 +58964,19 @@ function refresh_minimap(gobj) {
58910
58964
  * same three-way choice — it lived inline in the theme refresh and is
58911
58965
  * shared now. Returns null for a node that carries no desc.
58912
58966
  ************************************************************/
58967
+ function node_fill_of(nd) {
58968
+ return nd && nd.style && nd.style.fill || nd.data.desc.color;
58969
+ }
58913
58970
  function node_innerHTML_of(nd, theme, highlight, selected, anchored, pills_html) {
58914
58971
  if (!nd || !nd.data || !nd.data.desc) return null;
58915
58972
  let desc = nd.data.desc;
58916
58973
  let record = nd.data.record || {};
58917
58974
  let label = node_label(desc, record);
58975
+ let fill = node_fill_of(nd);
58918
58976
  switch (desc.node_treedb_type) {
58919
- case "child": return build_chip_innerHTML(desc.color, theme, record.icon, label, record.id, highlight, selected, anchored);
58920
- case "extended": return build_node_innerHTML(desc.color, theme, record.icon, label, desc.topic_name, true, record.id, highlight, selected, anchored, pills_html);
58921
- case "hierarchical": return build_node_innerHTML(desc.color, theme, record.icon, label, desc.topic_name, false, record.id, highlight, selected, anchored, pills_html);
58977
+ case "child": return build_chip_innerHTML(fill, theme, record.icon, label, record.id, highlight, selected, anchored);
58978
+ case "extended": return build_node_innerHTML(fill, theme, record.icon, label, desc.topic_name, true, record.id, highlight, selected, anchored, pills_html);
58979
+ case "hierarchical": return build_node_innerHTML(fill, theme, record.icon, label, desc.topic_name, false, record.id, highlight, selected, anchored, pills_html);
58922
58980
  }
58923
58981
  return null;
58924
58982
  }
@@ -59473,15 +59531,19 @@ function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope, sh
59473
59531
  if (!nodeData || !nodeData.data) return;
59474
59532
  let source_topic = nodeData.data.desc ? nodeData.data.desc.topic_name : null;
59475
59533
  let updates = [];
59534
+ let repaint = /* @__PURE__ */ new Set();
59476
59535
  const nodes = graph.getData().nodes;
59477
59536
  let figure = shape && str_in_list(NODE_SHAPES, shape) ? shape : "";
59478
59537
  let reshaped = [];
59479
- if (figure && scope !== "this") {
59538
+ if (scope !== "this") {
59480
59539
  let topics = scope === "same_topic" ? [source_topic] : Object.keys(priv.descs || {});
59481
59540
  for (let topic_name of topics) {
59541
+ let desc = priv.descs[topic_name];
59542
+ if (!desc) continue;
59482
59543
  if (!is_object(priv._graph_properties[topic_name])) priv._graph_properties[topic_name] = {};
59483
59544
  let defaults = priv._graph_properties[topic_name].defaults || {};
59484
- defaults.node_shape = figure;
59545
+ if (figure) defaults.node_shape = figure;
59546
+ paint_into(defaults, desc, fill, stroke, lineWidth);
59485
59547
  priv._graph_properties[topic_name].defaults = defaults;
59486
59548
  }
59487
59549
  }
@@ -59490,27 +59552,27 @@ function apply_node_properties(gobj, node_id, fill, stroke, lineWidth, scope, sh
59490
59552
  if (!nd || !nd.data || !nd.data.desc) continue;
59491
59553
  if (scope === "this" && nodes[i].id !== node_id) continue;
59492
59554
  if (scope === "same_topic" && nd.data.desc.topic_name !== source_topic) continue;
59555
+ let entry = node_props_entry(gobj, nd);
59493
59556
  if (figure) {
59494
- node_props_entry(gobj, nd).node_shape = figure;
59557
+ entry.node_shape = figure;
59495
59558
  if (node_mode_of(gobj, nodes[i].id) === "shape") reshaped.push(nodes[i].id);
59496
59559
  }
59560
+ paint_into(entry, nd.data.desc, fill, stroke, lineWidth);
59497
59561
  let updateStyle = {
59498
59562
  fill,
59499
59563
  stroke,
59500
59564
  lineWidth
59501
59565
  };
59502
- if (nd.data.desc.node_treedb_type === "hierarchical") {
59503
- let record = nd.data.record || {};
59504
- updateStyle.innerHTML = build_node_innerHTML(fill, priv.theme, record.icon, node_label(nd.data.desc, record), nd.data.desc.topic_name, false, record.id, false, false, false, pills_html_of(gobj, nd));
59505
- }
59506
59566
  updates.push({
59507
59567
  id: nodes[i].id,
59508
59568
  style: updateStyle
59509
59569
  });
59570
+ repaint.add(nodes[i].id);
59510
59571
  }
59511
59572
  if (updates.length > 0) {
59512
59573
  graph.updateNodeData(updates);
59513
59574
  if (reshaped.length) reshape_nodes(gobj, reshaped);
59575
+ repaint_cards(gobj, repaint);
59514
59576
  graph.draw().then(() => {
59515
59577
  mark_graph_dirty(gobj);
59516
59578
  });
@@ -62036,10 +62098,7 @@ function node_shape_items(gobj, wide) {
62036
62098
  "data-i18n-aria-label": key,
62037
62099
  "aria-pressed": "false"
62038
62100
  },
62039
- ["i", {
62040
- style: "font-size:1.5em; color:inherit;",
62041
- class: NODE_MODE_ICONS[mode]
62042
- }],
62101
+ yui_graph_icon(NODE_MODE_ICONS[mode]),
62043
62102
  { click: (evt) => {
62044
62103
  evt.stopPropagation();
62045
62104
  gobj_send_event(gobj, "EV_SET_NODE_MODE", { node_mode: mode }, gobj);
@@ -62061,10 +62120,7 @@ function node_shape_items(gobj, wide) {
62061
62120
  "data-i18n-aria-label": "node labels",
62062
62121
  "aria-pressed": "false"
62063
62122
  },
62064
- ["i", {
62065
- style: "font-size:1.5em; color:inherit;",
62066
- class: "yi-font"
62067
- }],
62123
+ yui_graph_icon("yi-font"),
62068
62124
  { click: (evt) => {
62069
62125
  evt.stopPropagation();
62070
62126
  gobj_send_event(gobj, "EV_TOGGLE_NODE_LABELS", {}, gobj);
@@ -62158,7 +62214,7 @@ function make_toolbar(gobj) {
62158
62214
  [
62159
62215
  "button",
62160
62216
  { class: "GRAPH_REFRESH button" },
62161
- [["i", { class: "yi-arrows-rotate" }], [
62217
+ [yui_graph_icon("yi-arrows-rotate"), [
62162
62218
  "span",
62163
62219
  {
62164
62220
  class: "is-hidden-mobile",
@@ -62183,7 +62239,7 @@ function make_toolbar(gobj) {
62183
62239
  "data-i18n-title": "raw json",
62184
62240
  "data-i18n-aria-label": "raw json"
62185
62241
  },
62186
- [["i", { class: "yi-eye" }], [
62242
+ [yui_graph_icon("yi-eye"), [
62187
62243
  "span",
62188
62244
  {
62189
62245
  class: "is-hidden-mobile",
@@ -62228,7 +62284,7 @@ function make_toolbar(gobj) {
62228
62284
  [$find_input, [
62229
62285
  "span",
62230
62286
  { class: "icon is-left" },
62231
- [["i", { class: "yi-magnifying-glass" }]]
62287
+ [yui_graph_icon("yi-magnifying-glass")]
62232
62288
  ]]
62233
62289
  ]);
62234
62290
  attach_clear($find_control, $find_input);
@@ -63197,9 +63253,9 @@ function ac_set_operation_mode(gobj, event, kw, src) {
63197
63253
  * card's graph icon travels — as EV_TOPIC_SELECTED, which the host turns
63198
63254
  * into the URL, so what you are looking at stays linkable.
63199
63255
  ************************************************************/
63200
- var LEGEND_GLYPH_STYLE = "font-size:1.5em; line-height:1; color:inherit;";
63201
- var LEGEND_NAME_STYLE = "font-size:1.2em; line-height:1.2;";
63202
- var LEGEND_COUNT_STYLE = "margin-left:.4rem; font-size:1em;";
63256
+ var LEGEND_GLYPH_STYLE = `font-size:${YUI_GRAPH_ICON_SIZE}; line-height:1; color:inherit;`;
63257
+ var LEGEND_NAME_STYLE = "font-size:1rem; line-height:1.2;";
63258
+ var LEGEND_COUNT_STYLE = "margin-left:.4rem; font-size:.875rem;";
63203
63259
  function refresh_legend(gobj) {
63204
63260
  let priv = gobj.priv;
63205
63261
  let $container = gobj_read_attr(gobj, "$container");
@@ -63372,7 +63428,7 @@ function refresh_legend(gobj) {
63372
63428
  "div",
63373
63429
  {
63374
63430
  class: "GRAPH_LEGEND_CHIP buttons has-addons",
63375
- style: "margin:0; flex:0 0 auto; flex-wrap:nowrap;"
63431
+ style: "margin:0; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
63376
63432
  },
63377
63433
  [$body].concat(extras.map((spec) => createElement2(spec)))
63378
63434
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.84",
3
+ "version": "7.23.86",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",