@yuneta/gobj-ui 7.23.140 → 7.23.141

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.
@@ -13111,7 +13111,7 @@ function ac_find_nodes$3(gobj, event, kw, src) {
13111
13111
  /************************************************************
13112
13112
  * EV_EXPAND_ALL
13113
13113
  ************************************************************/
13114
- function ac_expand_all$4(gobj, event, kw, src) {
13114
+ function ac_expand_all$2(gobj, event, kw, src) {
13115
13115
  let priv = gobj.priv;
13116
13116
  if (priv.collapsed.size === 0) return 0;
13117
13117
  priv.collapsed.clear();
@@ -13123,7 +13123,7 @@ function ac_expand_all$4(gobj, event, kw, src) {
13123
13123
  /************************************************************
13124
13124
  * EV_COLLAPSE_ALL — fold every card but the root.
13125
13125
  ************************************************************/
13126
- function ac_collapse_all$4(gobj, event, kw, src) {
13126
+ function ac_collapse_all$2(gobj, event, kw, src) {
13127
13127
  let priv = gobj.priv;
13128
13128
  let json_data = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "json_data");
13129
13129
  if (!json_data) return 0;
@@ -13423,12 +13423,12 @@ function create_gclass$13(gclass_name) {
13423
13423
  ],
13424
13424
  [
13425
13425
  "EV_EXPAND_ALL",
13426
- ac_expand_all$4,
13426
+ ac_expand_all$2,
13427
13427
  null
13428
13428
  ],
13429
13429
  [
13430
13430
  "EV_COLLAPSE_ALL",
13431
- ac_collapse_all$4,
13431
+ ac_collapse_all$2,
13432
13432
  null
13433
13433
  ],
13434
13434
  [
@@ -14500,7 +14500,7 @@ function ac_search$2(gobj, event, kw, src) {
14500
14500
  /************************************************************
14501
14501
  * EV_EXPAND_ALL — expand every already-loaded container
14502
14502
  ************************************************************/
14503
- function ac_expand_all$3(gobj, event, kw, src) {
14503
+ function ac_expand_all$1(gobj, event, kw, src) {
14504
14504
  let priv = gobj.priv;
14505
14505
  if (priv.root === null || priv.root === void 0) return 0;
14506
14506
  let paths = [];
@@ -14518,7 +14518,7 @@ function ac_expand_all$3(gobj, event, kw, src) {
14518
14518
  /************************************************************
14519
14519
  * EV_COLLAPSE_ALL
14520
14520
  ************************************************************/
14521
- function ac_collapse_all$3(gobj, event, kw, src) {
14521
+ function ac_collapse_all$1(gobj, event, kw, src) {
14522
14522
  gobj.priv.expanded.clear();
14523
14523
  render_view$1(gobj);
14524
14524
  return 0;
@@ -14703,12 +14703,12 @@ function create_gclass$12(gclass_name) {
14703
14703
  ],
14704
14704
  [
14705
14705
  "EV_EXPAND_ALL",
14706
- ac_expand_all$3,
14706
+ ac_expand_all$1,
14707
14707
  null
14708
14708
  ],
14709
14709
  [
14710
14710
  "EV_COLLAPSE_ALL",
14711
- ac_collapse_all$3,
14711
+ ac_collapse_all$1,
14712
14712
  null
14713
14713
  ],
14714
14714
  [
@@ -19730,7 +19730,7 @@ function ac_toggle_collapse(gobj, event, kw, src) {
19730
19730
  /************************************************************
19731
19731
  * Force every node visible (overrides threshold).
19732
19732
  ************************************************************/
19733
- function ac_expand_all$2(gobj, event, kw, src) {
19733
+ function ac_expand_all(gobj, event, kw, src) {
19734
19734
  let priv = gobj.priv;
19735
19735
  if (!priv.collapse_state) priv.collapse_state = {};
19736
19736
  if (priv.node_by_id) for (let id of Object.keys(priv.node_by_id)) {
@@ -19743,7 +19743,7 @@ function ac_expand_all$2(gobj, event, kw, src) {
19743
19743
  /************************************************************
19744
19744
  * Collapse every node that has children.
19745
19745
  ************************************************************/
19746
- function ac_collapse_all$2(gobj, event, kw, src) {
19746
+ function ac_collapse_all(gobj, event, kw, src) {
19747
19747
  let priv = gobj.priv;
19748
19748
  if (!priv.collapse_state) priv.collapse_state = {};
19749
19749
  if (priv.node_by_id) for (let id of Object.keys(priv.node_by_id)) {
@@ -20095,12 +20095,12 @@ function create_gclass$9(gclass_name) {
20095
20095
  ],
20096
20096
  [
20097
20097
  "EV_EXPAND_ALL",
20098
- ac_expand_all$2,
20098
+ ac_expand_all,
20099
20099
  null
20100
20100
  ],
20101
20101
  [
20102
20102
  "EV_COLLAPSE_ALL",
20103
- ac_collapse_all$2,
20103
+ ac_collapse_all,
20104
20104
  null
20105
20105
  ],
20106
20106
  [
@@ -27739,7 +27739,7 @@ function fold_build_model(descs, records, opts) {
27739
27739
  for (let k of reach_from(nodes, [node.key])) reached.add(k);
27740
27740
  }
27741
27741
  for (let topic_name of topics) if (roots[topic_name].length > 0) groups.set(fold_root_group_key(topic_name), roots[topic_name]);
27742
- return {
27742
+ let model = {
27743
27743
  nodes,
27744
27744
  groups,
27745
27745
  topics,
@@ -27748,8 +27748,52 @@ function fold_build_model(descs, records, opts) {
27748
27748
  main_topic,
27749
27749
  linked,
27750
27750
  loose,
27751
- loose_shown
27751
+ loose_shown,
27752
+ level_of: null,
27753
+ levels: 0
27752
27754
  };
27755
+ count_levels(model);
27756
+ return model;
27757
+ }
27758
+ /************************************************************
27759
+ * The LEVELS of the main tree: the roots of the main topic --
27760
+ * and of the topics hung from it, whose roots are the loose
27761
+ * records the reader asked for -- are level 1, their children
27762
+ * level 2, and so on down every hook of every topic that is not
27763
+ * hidden. A node reached by two paths takes the shallowest.
27764
+ *
27765
+ * With no main topic every topic is a tree of its own and all
27766
+ * of them count. A topic the schema does not tie to the main
27767
+ * one is a separate tree, and has no level: the stepper of the
27768
+ * toolbar speaks for the main tree and nothing else, those
27769
+ * trees are opened by their own pills.
27770
+ ************************************************************/
27771
+ function count_levels(model) {
27772
+ let level_of = /* @__PURE__ */ new Map();
27773
+ let queue = [];
27774
+ let deepest = 0;
27775
+ for (let topic_name of model.topics) {
27776
+ if (model.main_topic && !model.linked.has(topic_name)) continue;
27777
+ let roots = model.groups.get(fold_root_group_key(topic_name)) || [];
27778
+ for (let key of roots) if (!level_of.has(key)) {
27779
+ level_of.set(key, 1);
27780
+ queue.push(key);
27781
+ }
27782
+ }
27783
+ let head = 0;
27784
+ while (head < queue.length) {
27785
+ let key = queue[head++];
27786
+ let lv = level_of.get(key);
27787
+ if (lv > deepest) deepest = lv;
27788
+ let node = model.nodes.get(key);
27789
+ if (!node) continue;
27790
+ for (let hook of Object.keys(node.hooks)) for (let child of node.hooks[hook]) if (!level_of.has(child)) {
27791
+ level_of.set(child, lv + 1);
27792
+ queue.push(child);
27793
+ }
27794
+ }
27795
+ model.level_of = level_of;
27796
+ model.levels = deepest;
27753
27797
  }
27754
27798
  /************************************************************
27755
27799
  * The topic the schema hangs the others from: the one whose hooks
@@ -27875,14 +27919,6 @@ function fold_show_more(model, state, group_key) {
27875
27919
  return n;
27876
27920
  }
27877
27921
  /************************************************************
27878
- * Every group open on ALL its children. This is the reader
27879
- * asking for the whole thing; the pages are for the other way in.
27880
- ************************************************************/
27881
- function fold_expand_all(model, state) {
27882
- state.shown.clear();
27883
- for (let [group_key, list] of model.groups) if (list.length > 0) state.shown.set(group_key, list.length);
27884
- }
27885
- /************************************************************
27886
27922
  * The roots and nothing else -- the first page of each topic's
27887
27923
  * roots, the way the graph looks before anything is opened.
27888
27924
  ************************************************************/
@@ -27894,40 +27930,51 @@ function fold_collapse_all(model, state) {
27894
27930
  }
27895
27931
  }
27896
27932
  /************************************************************
27897
- * Open the tree down to `depth` levels: the roots are level 1,
27898
- * their children level 2. A node reached by two paths takes the
27899
- * shallowest. Each group opens on its first page. `depth` of 1
27900
- * is the roots alone; anything below that is treated as 1.
27933
+ * The toolbar's STEPPER over the levels of the main tree (see
27934
+ * count_levels): level N shows the roots and N-1 levels under
27935
+ * them. A level is a floor of what is open, not a picture that
27936
+ * replaces it:
27937
+ *
27938
+ * opening to N opens, on its first page, every hook of
27939
+ * every node above level N that is folded;
27940
+ * what the reader opened, and every page
27941
+ * already shown, stays
27942
+ * closing to N folds every hook of every node at level N
27943
+ * or below, and touches nothing above it
27944
+ *
27945
+ * A separate tree (a topic not tied to the main one) has no
27946
+ * level, so neither ever touches it.
27901
27947
  ************************************************************/
27902
- function fold_expand_to_depth(model, state, depth) {
27903
- fold_collapse_all(model, state);
27904
- if (!(depth > 1)) return;
27905
- let level = /* @__PURE__ */ new Map();
27906
- let queue = [];
27907
- for (let topic_name of model.topics) {
27908
- let roots = model.groups.get(fold_root_group_key(topic_name)) || [];
27909
- for (let key of roots) if (!level.has(key)) {
27910
- level.set(key, 1);
27911
- queue.push(key);
27912
- }
27913
- }
27914
- while (queue.length) {
27915
- let key = queue.shift();
27916
- let lv = level.get(key);
27917
- if (lv >= depth) continue;
27948
+ function fold_level_clamp(model, level) {
27949
+ let top = model.levels > 0 ? model.levels : 1;
27950
+ level = Math.floor(Number(level)) || 1;
27951
+ if (level < 1) return 1;
27952
+ if (level > top) return top;
27953
+ return level;
27954
+ }
27955
+ function fold_open_levels(model, state, level) {
27956
+ for (let [key, lv] of model.level_of) {
27957
+ if (lv >= level) continue;
27918
27958
  let node = model.nodes.get(key);
27919
27959
  if (!node) continue;
27920
27960
  for (let hook of Object.keys(node.hooks)) {
27921
- let children = node.hooks[hook];
27922
- if (children.length === 0) continue;
27923
- state.shown.set(fold_group_key(key, hook), state.page_size);
27924
- for (let child of children) if (!level.has(child)) {
27925
- level.set(child, lv + 1);
27926
- queue.push(child);
27927
- }
27961
+ let group_key = fold_group_key(key, hook);
27962
+ if (node.hooks[hook].length > 0 && !fold_is_open(state, group_key)) state.shown.set(group_key, state.page_size);
27928
27963
  }
27929
27964
  }
27930
27965
  }
27966
+ function fold_close_levels(model, state, level) {
27967
+ for (let [key, lv] of model.level_of) {
27968
+ if (lv < level) continue;
27969
+ let node = model.nodes.get(key);
27970
+ if (!node) continue;
27971
+ for (let hook of Object.keys(node.hooks)) state.shown.delete(fold_group_key(key, hook));
27972
+ }
27973
+ }
27974
+ function fold_expand_to_level(model, state, level) {
27975
+ fold_collapse_all(model, state);
27976
+ fold_open_levels(model, state, fold_level_clamp(model, level));
27977
+ }
27931
27978
  /************************************************************
27932
27979
  * The set of node keys on screen, from the roots down through
27933
27980
  * every open group -- and only through open groups whose parent
@@ -55170,8 +55217,9 @@ function ensure_brush_select_owned() {
55170
55217
  * The graph opens FOLDED, like a JSON viewer.
55171
55218
  *
55172
55219
  * Every record of every topic is fetched, but only the ones on
55173
- * screen become G6 nodes: the roots, `expand_depth` levels under
55174
- * them, one page (`fold_page_size`) of children per hook. Each
55220
+ * screen become G6 nodes: the roots, and the MAIN tree open to
55221
+ * the reader's level (`fold_level`, `expand_depth` until they
55222
+ * step it), one page (`fold_page_size`) of children per hook. Each
55175
55223
  * card carries a pill per hook that has children -- `▸ devices
55176
55224
  * 142` -- which opens or folds that hook; an open hook with more
55177
55225
  * children than its page ends in a `+N` chip that opens the next
@@ -55349,7 +55397,8 @@ var attrs_table$4 = [
55349
55397
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_LIST, "layout_names", _yuneta_gobj_js.sdata_flag_t.SDF_RD, JSON.stringify(Object.keys(_layouts)), "Available layout names (read-only, for parent to query)"),
55350
55398
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "hook_port_position", 0, "bottom", "Hook port position"),
55351
55399
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "fkey_port_position", 0, "top", "Fkey port position"),
55352
- (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "expand_depth", 0, 2, "Levels open when a treedb loads: 1 = the roots alone, 2 = the roots and their children. Every open hook shows its first page"),
55400
+ (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "expand_depth", 0, 2, "Levels open when a treedb loads, until the reader steps (`fold_level`): 1 = the roots alone, 2 = the roots and their children. Every open hook shows its first page"),
55401
+ (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "fold_level", 0, 0, "The level of the MAIN tree the toolbar's stepper stands on: 1 = its roots, N = N-1 levels under them; 0 = `expand_depth`. The host persists it and sends EV_SET_FOLD_LEVEL; it is published back in EV_LEGEND_STATE (`fold`) with the levels the tree has"),
55353
55402
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "fold_page_size", 0, 24, "Children of one hook shown per page; the `+N` chip after the page opens the next one"),
55354
55403
  (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"),
55355
55404
  (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"),
@@ -55441,6 +55490,7 @@ var PRIVATE_DATA$4 = {
55441
55490
  _nodes_total: 0,
55442
55491
  _nodes_placed: 0,
55443
55492
  expand_depth: 2,
55493
+ fold_level: 0,
55444
55494
  fold_page_size: 24,
55445
55495
  hidden_topics: null,
55446
55496
  main_topic: "",
@@ -61325,7 +61375,12 @@ function publish_legend_state(gobj, visible) {
61325
61375
  (0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_LEGEND_STATE", {
61326
61376
  main_topic: model.main_topic,
61327
61377
  main_chosen: !!(0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "main_topic"),
61328
- topics
61378
+ topics,
61379
+ fold: {
61380
+ topic: model.main_topic,
61381
+ level: current_fold_level(gobj),
61382
+ levels: model.levels
61383
+ }
61329
61384
  });
61330
61385
  }
61331
61386
  async function reconcile_fold_apply(gobj, opts, visible) {
@@ -61630,7 +61685,7 @@ function ac_load_data(gobj, event, kw, src) {
61630
61685
  }
61631
61686
  if (all_loaded && priv.graph) {
61632
61687
  rebuild_fold_model(gobj);
61633
- fold_expand_to_depth(priv._fold_model, priv._fold_state, (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "expand_depth"));
61688
+ fold_expand_to_level(priv._fold_model, priv._fold_state, current_fold_level(gobj));
61634
61689
  count_placed_records(gobj);
61635
61690
  let auto_laid = false;
61636
61691
  try {
@@ -62034,19 +62089,46 @@ function ac_show_more(gobj, event, kw, src) {
62034
62089
  return 0;
62035
62090
  }
62036
62091
  /************************************************************
62037
- * The whole treedb, every hook open on all its children. This
62038
- * is the reader asking for the pile on purpose; the pages are
62039
- * the other way in.
62092
+ * The level of the main tree the toolbar's stepper stands on:
62093
+ * `fold_level` once the reader has stepped, `expand_depth`
62094
+ * until then, clamped to the levels the tree has.
62040
62095
  ************************************************************/
62041
- function ac_expand_all$1(gobj, event, kw, src) {
62096
+ function current_fold_level(gobj) {
62042
62097
  let priv = gobj.priv;
62043
- if (!priv._fold_model) {
62044
- (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: expand all with no tree loaded`);
62098
+ let level = (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "fold_level");
62099
+ if (!(level > 0)) level = (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "expand_depth");
62100
+ if (!priv._fold_model) return level;
62101
+ return fold_level_clamp(priv._fold_model, level);
62102
+ }
62103
+ /************************************************************
62104
+ * The toolbar's stepper: one level more or one less of the
62105
+ * MAIN tree (the host owns the number and persists it; this
62106
+ * applies it). Deeper opens the hooks above the new level,
62107
+ * shallower folds from it down -- a level is a floor, not a
62108
+ * picture, so what the reader opened by its pill stays (see
62109
+ * treedb_fold_model). Replaces expand all / collapse all
62110
+ * (7.23.141): the whole treedb at once was the pile, and
62111
+ * closing threw away everything the reader had opened.
62112
+ ************************************************************/
62113
+ function ac_set_fold_level(gobj, event, kw, src) {
62114
+ let priv = gobj.priv;
62115
+ let level = Number(kw && kw.level);
62116
+ if (!(level > 0)) {
62117
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: fold level '${kw && kw.level}' is not a level`);
62045
62118
  return -1;
62046
62119
  }
62120
+ if (!priv._fold_model) {
62121
+ (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "fold_level", level);
62122
+ return 0;
62123
+ }
62124
+ let from = current_fold_level(gobj);
62125
+ level = fold_level_clamp(priv._fold_model, level);
62126
+ (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "fold_level", level);
62127
+ if (level === from) return 0;
62047
62128
  let keep = fold_keep_node(gobj);
62048
62129
  let vp = yui_graph_viewport_of(priv.graph, keep);
62049
- fold_expand_all(priv._fold_model, priv._fold_state);
62130
+ if (level > from) fold_open_levels(priv._fold_model, priv._fold_state, level);
62131
+ else fold_close_levels(priv._fold_model, priv._fold_state, level);
62050
62132
  reconcile_fold(gobj, {
62051
62133
  keep,
62052
62134
  keep_vp: vp
@@ -62074,29 +62156,11 @@ function fold_keep_node(gobj) {
62074
62156
  return "";
62075
62157
  }
62076
62158
  /************************************************************
62077
- * The roots alone.
62078
- ************************************************************/
62079
- function ac_collapse_all$1(gobj, event, kw, src) {
62080
- let priv = gobj.priv;
62081
- if (!priv._fold_model) {
62082
- (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: collapse all with no tree loaded`);
62083
- return -1;
62084
- }
62085
- let keep = fold_keep_node(gobj);
62086
- let vp = yui_graph_viewport_of(priv.graph, keep);
62087
- fold_collapse_all(priv._fold_model, priv._fold_state);
62088
- reconcile_fold(gobj, {
62089
- keep,
62090
- keep_vp: vp
62091
- });
62092
- return 0;
62093
- }
62094
- /************************************************************
62095
62159
  * The legend's three settings, from the host, which persists
62096
62160
  * them. Each rebuilds the tree; the fold state is kept -- it is
62097
62161
  * keyed by group, and a group that is gone is never read -- except
62098
62162
  * for a new MAIN topic, whose roots are other roots: the tree
62099
- * opens again at `expand_depth`.
62163
+ * opens again at the reader's level, now counted from them.
62100
62164
  ************************************************************/
62101
62165
  function ac_set_hidden_topics(gobj, event, kw, src) {
62102
62166
  let priv = gobj.priv;
@@ -62114,7 +62178,7 @@ function ac_set_main_topic(gobj, event, kw, src) {
62114
62178
  let keep = fold_keep_node(gobj);
62115
62179
  let vp = yui_graph_viewport_of(priv.graph, keep);
62116
62180
  rebuild_fold_model(gobj);
62117
- fold_expand_to_depth(priv._fold_model, priv._fold_state, (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "expand_depth"));
62181
+ fold_expand_to_level(priv._fold_model, priv._fold_state, current_fold_level(gobj));
62118
62182
  reconcile_fold(gobj, {
62119
62183
  relayout: true,
62120
62184
  keep,
@@ -62675,13 +62739,8 @@ function create_gclass$4(gclass_name) {
62675
62739
  null
62676
62740
  ],
62677
62741
  [
62678
- "EV_EXPAND_ALL",
62679
- ac_expand_all$1,
62680
- null
62681
- ],
62682
- [
62683
- "EV_COLLAPSE_ALL",
62684
- ac_collapse_all$1,
62742
+ "EV_SET_FOLD_LEVEL",
62743
+ ac_set_fold_level,
62685
62744
  null
62686
62745
  ],
62687
62746
  [
@@ -62824,8 +62883,7 @@ function create_gclass$4(gclass_name) {
62824
62883
  ["EV_CAMERA_CHANGED", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
62825
62884
  ["EV_TOGGLE_FOLD", 0],
62826
62885
  ["EV_SHOW_MORE", 0],
62827
- ["EV_EXPAND_ALL", 0],
62828
- ["EV_COLLAPSE_ALL", 0],
62886
+ ["EV_SET_FOLD_LEVEL", 0],
62829
62887
  ["EV_SET_HIDDEN_TOPICS", 0],
62830
62888
  ["EV_SET_MAIN_TOPIC", 0],
62831
62889
  ["EV_SET_LOOSE_TOPICS", 0],
@@ -62909,6 +62967,7 @@ var attrs_table$3 = [
62909
62967
  (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"),
62910
62968
  (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"),
62911
62969
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_DICT, "camera", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, "{}", "Where the reader left the viewport: {zoom, x, y}. Handed to the engine on creation and written back when a move settles, so the graph opens where it was left. User preference, per treedb"),
62970
+ (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "fold_level", _yuneta_gobj_js.sdata_flag_t.SDF_PERSIST, 0, "The level of the MAIN tree the toolbar's stepper stands on: 1 = the main topic's roots, N = N-1 levels under them; 0 = never stepped, `expand_depth`. Handed to the engine on creation, so the graph opens at the level it was left. User preference, per treedb"),
62912
62971
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_POINTER, "gobj_remote_yuno", 0, null, "Remote Yuno to request data"),
62913
62972
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "treedb_name", 0, null, "Remote service treedb name"),
62914
62973
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_DICT, "descs", 0, null, "Descriptions of topics obtained"),
@@ -62984,6 +63043,7 @@ function mt_create$3(gobj) {
62984
63043
  hook_port_position: "bottom",
62985
63044
  fkey_port_position: "top",
62986
63045
  expand_depth: (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "expand_depth"),
63046
+ fold_level: (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "fold_level"),
62987
63047
  fold_page_size: (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "fold_page_size"),
62988
63048
  minimap_min_nodes: (0, _yuneta_gobj_js.gobj_read_integer_attr)(gobj, "minimap_min_nodes"),
62989
63049
  with_gridline: (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_gridline"),
@@ -63291,6 +63351,127 @@ function refresh_node_shape_buttons(gobj, $root) {
63291
63351
  $labels.disabled = mode !== "shape";
63292
63352
  }
63293
63353
  }
63354
+ /************************************************************
63355
+ * The fold STEPPER: one level less, where the tree stands, one
63356
+ * level more.
63357
+ *
63358
+ * It replaces the fold pair (7.23.141). `expand all` opened every
63359
+ * hook of the treedb -- the pile, on purpose, which on a treedb
63360
+ * of thousands is a pile nobody reads -- and `collapse all` threw
63361
+ * away everything the reader had opened. The stepper walks the
63362
+ * MAIN tree a level at a time, the way the frontend view opens
63363
+ * one level per press: `+` opens the next level under the main
63364
+ * topic's roots, through every topic that is not hidden; `-`
63365
+ * folds the deepest one. Pages and pills the reader opened stay.
63366
+ *
63367
+ * The readout says what the two buttons act on, which no chevron
63368
+ * can: the main topic -- its swatch and its name, which is DATA
63369
+ * and never translated -- and `level/levels`. On a phone the name
63370
+ * goes and the numbers stay. The level is the reader's, per
63371
+ * treedb: persisted (`fold_level`) and handed to the engine on
63372
+ * creation, so a reload opens where it was left.
63373
+ *
63374
+ * Both buttons are born disabled: nothing can be stepped until
63375
+ * the engine has said how deep the tree goes (EV_LEGEND_STATE).
63376
+ ************************************************************/
63377
+ function fold_level_items(gobj, wide) {
63378
+ let step_button = (cls, icon, key, event_name) => {
63379
+ return [
63380
+ "button",
63381
+ {
63382
+ class: `${cls} button`,
63383
+ type: "button",
63384
+ style: {
63385
+ height: wide,
63386
+ width: "2.5em"
63387
+ },
63388
+ disabled: true,
63389
+ title: (0, i18next.t)(key),
63390
+ "data-i18n-title": key,
63391
+ "aria-label": (0, i18next.t)(key),
63392
+ "data-i18n-aria-label": key
63393
+ },
63394
+ yui_toolbar_icon(icon),
63395
+ { click: (evt) => {
63396
+ evt.stopPropagation();
63397
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, event_name, {}, gobj);
63398
+ } }
63399
+ ];
63400
+ };
63401
+ return [[
63402
+ "div",
63403
+ {
63404
+ class: "GRAPH_FOLD_STEPPER buttons has-addons",
63405
+ style: "margin:0; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
63406
+ },
63407
+ [
63408
+ step_button("GRAPH_FOLD_COLLAPSE", "yi-chevron-right", "collapse one level", "EV_COLLAPSE_LEVEL"),
63409
+ [
63410
+ "div",
63411
+ {
63412
+ class: "GRAPH_FOLD_LEVEL button",
63413
+ style: {
63414
+ height: wide,
63415
+ cursor: "default",
63416
+ gap: ".35rem"
63417
+ },
63418
+ role: "status",
63419
+ title: (0, i18next.t)("fold level"),
63420
+ "data-i18n-title": "fold level"
63421
+ },
63422
+ [
63423
+ ["span", {
63424
+ class: "GRAPH_FOLD_SWATCH",
63425
+ style: "display:none; width:.8rem; height:.8rem; border-radius:3px; flex:0 0 auto; border:1px solid rgba(0,0,0,.25);"
63426
+ }],
63427
+ ["span", {
63428
+ class: "GRAPH_FOLD_TOPIC is-hidden-mobile",
63429
+ style: "max-width:10em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600;"
63430
+ }],
63431
+ [
63432
+ "span",
63433
+ {
63434
+ class: "GRAPH_FOLD_WORD",
63435
+ i18n: "level"
63436
+ },
63437
+ "level"
63438
+ ],
63439
+ [
63440
+ "span",
63441
+ {
63442
+ class: "GRAPH_FOLD_COUNT",
63443
+ style: "font-variant-numeric:tabular-nums;"
63444
+ },
63445
+ "–"
63446
+ ]
63447
+ ]
63448
+ ],
63449
+ step_button("GRAPH_FOLD_EXPAND", "yi-chevron-down", "expand one level", "EV_EXPAND_LEVEL")
63450
+ ]
63451
+ ]];
63452
+ }
63453
+ function refresh_fold_level(gobj) {
63454
+ let priv = gobj.priv;
63455
+ let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
63456
+ if (!$container) return;
63457
+ let $readout = $container.querySelector(".GRAPH_FOLD_LEVEL");
63458
+ if (!$readout) return;
63459
+ let state = priv._legend_state || {};
63460
+ let fold = state.fold || {};
63461
+ let levels = fold.levels > 0 ? fold.levels : 0;
63462
+ let level = fold.level > 0 ? fold.level : 0;
63463
+ let topic = fold.topic || "";
63464
+ let entry = ((0, _yuneta_gobj_js.is_array)(state.topics) ? state.topics : []).find((e) => e.topic === topic);
63465
+ let $swatch = $readout.querySelector(".GRAPH_FOLD_SWATCH");
63466
+ $swatch.style.display = topic ? "inline-block" : "none";
63467
+ $swatch.style.background = entry && entry.color || "#94a3b8";
63468
+ $readout.querySelector(".GRAPH_FOLD_TOPIC").textContent = topic;
63469
+ $readout.querySelector(".GRAPH_FOLD_COUNT").textContent = levels ? `${level}/${levels}` : "–";
63470
+ let $collapse = $container.querySelector(".GRAPH_FOLD_COLLAPSE");
63471
+ let $expand = $container.querySelector(".GRAPH_FOLD_EXPAND");
63472
+ if ($collapse) $collapse.disabled = !(levels && level > 1);
63473
+ if ($expand) $expand.disabled = !(levels && level < levels);
63474
+ }
63294
63475
  function make_toolbar(gobj) {
63295
63476
  let priv = gobj.priv;
63296
63477
  let modes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "operation_modes");
@@ -63357,7 +63538,7 @@ function make_toolbar(gobj) {
63357
63538
  } }
63358
63539
  ]
63359
63540
  ];
63360
- let center_items = [...yui_graph_fold_items(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide")), ...node_shape_items(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide"))];
63541
+ let center_items = [...fold_level_items(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide")), ...node_shape_items(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide"))];
63361
63542
  let backend_items = [[
63362
63543
  "button",
63363
63544
  {
@@ -64613,6 +64794,7 @@ function ac_legend_state(gobj, event, kw, src) {
64613
64794
  let priv = gobj.priv;
64614
64795
  priv._legend_state = kw || null;
64615
64796
  refresh_legend(gobj);
64797
+ refresh_fold_level(gobj);
64616
64798
  return 0;
64617
64799
  }
64618
64800
  /************************************************************
@@ -64725,17 +64907,33 @@ function ac_find_nodes(gobj, event, kw, src) {
64725
64907
  return 0;
64726
64908
  }
64727
64909
  /************************************************************
64728
- * The fold pair of the toolbar, forwarded to the G6 child,
64729
- * which owns the tree.
64910
+ * One press of the fold stepper (EV_EXPAND_LEVEL /
64911
+ * EV_COLLAPSE_LEVEL): the level moves by one, is SAVED (the
64912
+ * reader's, per treedb) and reaches the G6 child, which owns
64913
+ * the tree.
64914
+ *
64915
+ * The readout moves at once, not when the engine speaks again:
64916
+ * a reconcile is asynchronous, and a second press that came
64917
+ * before it would step from the level already left -- two
64918
+ * presses, one level.
64730
64919
  ************************************************************/
64731
- function ac_expand_all(gobj, event, kw, src) {
64920
+ function ac_fold_level_step(gobj, event, kw, src) {
64732
64921
  let priv = gobj.priv;
64733
- if (priv.gobj_nodes_tree) (0, _yuneta_gobj_js.gobj_send_event)(priv.gobj_nodes_tree, "EV_EXPAND_ALL", {}, gobj);
64734
- return 0;
64735
- }
64736
- function ac_collapse_all(gobj, event, kw, src) {
64737
- let priv = gobj.priv;
64738
- if (priv.gobj_nodes_tree) (0, _yuneta_gobj_js.gobj_send_event)(priv.gobj_nodes_tree, "EV_COLLAPSE_ALL", {}, gobj);
64922
+ let fold = priv._legend_state && priv._legend_state.fold;
64923
+ if (!fold || !(fold.levels > 0)) {
64924
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} with no tree to step through`);
64925
+ return -1;
64926
+ }
64927
+ let level = fold.level + (event === "EV_EXPAND_LEVEL" ? 1 : -1);
64928
+ if (level < 1 || level > fold.levels) {
64929
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event}: level ${level} out of 1..${fold.levels}`);
64930
+ return -1;
64931
+ }
64932
+ (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "fold_level", level);
64933
+ (0, _yuneta_gobj_js.gobj_save_persistent_attrs)(gobj, "fold_level");
64934
+ fold.level = level;
64935
+ refresh_fold_level(gobj);
64936
+ if (priv.gobj_nodes_tree) (0, _yuneta_gobj_js.gobj_send_event)(priv.gobj_nodes_tree, "EV_SET_FOLD_LEVEL", { level }, gobj);
64739
64937
  return 0;
64740
64938
  }
64741
64939
  /************************************************************
@@ -64972,13 +65170,13 @@ function create_gclass$3(gclass_name) {
64972
65170
  null
64973
65171
  ],
64974
65172
  [
64975
- "EV_EXPAND_ALL",
64976
- ac_expand_all,
65173
+ "EV_EXPAND_LEVEL",
65174
+ ac_fold_level_step,
64977
65175
  null
64978
65176
  ],
64979
65177
  [
64980
- "EV_COLLAPSE_ALL",
64981
- ac_collapse_all,
65178
+ "EV_COLLAPSE_LEVEL",
65179
+ ac_fold_level_step,
64982
65180
  null
64983
65181
  ],
64984
65182
  [
@@ -65063,8 +65261,8 @@ function create_gclass$3(gclass_name) {
65063
65261
  ["EV_SET_OPERATION_MODE", 0],
65064
65262
  ["EV_SET_FOCUS_TOPIC", 0],
65065
65263
  ["EV_FIND_NODES", 0],
65066
- ["EV_EXPAND_ALL", 0],
65067
- ["EV_COLLAPSE_ALL", 0],
65264
+ ["EV_EXPAND_LEVEL", 0],
65265
+ ["EV_COLLAPSE_LEVEL", 0],
65068
65266
  ["EV_SET_NODE_MODE", 0],
65069
65267
  ["EV_TOGGLE_NODE_LABELS", 0],
65070
65268
  ["EV_FIND_RESULT", 0],