@yuneta/gobj-ui 7.23.162 → 7.23.164

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 CHANGED
@@ -861,6 +861,19 @@ C_YUI_TREEDB_TOPIC_WITH_FORM C_YUI_TREEDB_TOPICS
861
861
  "which topic" dialog. All three are input events; `EV_OPEN_LINKED` is the one
862
862
  output event, and `C_YUI_TREEDB_TOPICS` declares it.
863
863
 
864
+ **The table loads a hook as its count** (since `7.23.163`). Its three loads
865
+ ask with `hook_size`, so a hook arrives as `[{"size": N}]` and not as the ids
866
+ of its children, which nothing in the table reads any more:
867
+
868
+ ```js
869
+ const TABLE_READ_OPTIONS = {list_dict: true, hook_size: true};
870
+ ```
871
+
872
+ The node events still carry whole hooks, so after a live update a row can
873
+ hold the list again; the cell and a delete's question count either shape. The
874
+ search box no longer finds a parent row by the id of one of its children: to
875
+ find what hangs from a row, click its hook.
876
+
864
877
  ### Read-only treedbs: `readonly`
865
878
 
866
879
  `C_YUI_TREEDB_TOPICS` and `C_YUI_TREEDB_GRAPH` take a **`readonly`** attr; the
@@ -1003,7 +1016,22 @@ priv.unforward_wheel();
1003
1016
 
1004
1017
  An element that must scroll by itself inside the graph (a popover) stops the
1005
1018
  wheel with `stopPropagation()` before it reaches `$host`.
1006
- `C_YUI_TREEDB_SCHEMA` uses it; `C_G6_NODES_TREE` does not yet.
1019
+
1020
+ A graph that puts other DOM in its container, such as its own toolbars or a
1021
+ legend, passes `opts.selector`. Then only a wheel whose target is inside a
1022
+ matching element is forwarded, and a wheel over the rest keeps its own
1023
+ behaviour:
1024
+
1025
+ ```js
1026
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, {
1027
+ selector: ".TREEDB_CARD, .TREEDB_PILLS"
1028
+ });
1029
+ ```
1030
+
1031
+ `C_YUI_TREEDB_SCHEMA` forwards every wheel (its container holds only the
1032
+ cards). `C_G6_NODES_TREE` forwards only the wheels over its cards and pill
1033
+ strips (since `7.23.164`), so Ctrl + wheel over its toolbar does not zoom the
1034
+ graph.
1007
1035
 
1008
1036
  ### The anchor: one element the camera holds
1009
1037
 
@@ -11526,9 +11526,15 @@ function yui_graph_camera_behaviors() {
11526
11526
  * element that must scroll by itself (a popover) stops the
11527
11527
  * wheel before it gets here.
11528
11528
  *
11529
+ * `opts.selector` narrows it to the wheels whose target is
11530
+ * inside an element that matches, e.g. the root class of the
11531
+ * cards. A graph that puts other DOM in its container -- its
11532
+ * own toolbars, a legend -- passes one, so a wheel over those
11533
+ * is left to them instead of scrolling the graph.
11534
+ *
11529
11535
  * Returns the function that removes the listener.
11530
11536
  ************************************************************/
11531
- function yui_graph_forward_wheel(graph, $host) {
11537
+ function yui_graph_forward_wheel(graph, $host, opts = {}) {
11532
11538
  if (!graph || !$host) return () => {};
11533
11539
  const on_wheel = (e) => {
11534
11540
  let dom = null;
@@ -11538,6 +11544,7 @@ function yui_graph_forward_wheel(graph, $host) {
11538
11544
  return;
11539
11545
  }
11540
11546
  if (!dom || e.target === dom) return;
11547
+ if (opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) return;
11541
11548
  e.preventDefault();
11542
11549
  e.stopPropagation();
11543
11550
  dom.dispatchEvent(new WheelEvent("wheel", {
@@ -23057,6 +23064,10 @@ function nodes_answer(data) {
23057
23064
  * Constants
23058
23065
  ***************************************************************/
23059
23066
  var GCLASS_NAME$6 = "C_YUI_TREEDB_TOPICS";
23067
+ var TABLE_READ_OPTIONS = {
23068
+ list_dict: true,
23069
+ hook_size: true
23070
+ };
23060
23071
  /***************************************************************
23061
23072
  * Data
23062
23073
  ***************************************************************/
@@ -24089,7 +24100,7 @@ function get_nodes$1(gobj, topic_name) {
24089
24100
  subscribe_treedb$1(gobj, topic_name);
24090
24101
  let gobj_topic_form = get_gobj_formtable(gobj, topic_name);
24091
24102
  if (gobj_topic_form && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj_topic_form, "with_remote_paging")) return;
24092
- treedb_nodes$1(gobj, treedb_name, topic_name, { list_dict: true });
24103
+ treedb_nodes$1(gobj, treedb_name, topic_name, Object.assign({}, TABLE_READ_OPTIONS));
24093
24104
  }
24094
24105
  /************************************************************
24095
24106
  *
@@ -24672,7 +24683,7 @@ function ac_request_page(gobj, event, kw, src) {
24672
24683
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: a page request with no topic or no id`);
24673
24684
  return -1;
24674
24685
  }
24675
- if (treedb_nodes$1(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name"), topic_name, { list_dict: true }, {
24686
+ if (treedb_nodes$1(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name"), topic_name, Object.assign({}, TABLE_READ_OPTIONS), {
24676
24687
  from: kw.from,
24677
24688
  limit: kw.limit,
24678
24689
  req_id: kw.req_id
@@ -24826,7 +24837,8 @@ function ac_refresh_topic(gobj, event, kw, src) {
24826
24837
  (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_REPULL_PAGE", {}, gobj);
24827
24838
  return 0;
24828
24839
  }
24829
- treedb_nodes$1(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name"), kw.topic_name, { list_dict: true });
24840
+ let options = Object.assign({}, TABLE_READ_OPTIONS);
24841
+ treedb_nodes$1(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name"), kw.topic_name, options);
24830
24842
  return 0;
24831
24843
  }
24832
24844
  /********************************************
@@ -57665,6 +57677,7 @@ var PRIVATE_DATA$4 = {
57665
57677
  _on_pointerdown_focus: null,
57666
57678
  _on_native_contextmenu: null,
57667
57679
  _uninstall_long_press: null,
57680
+ _unforward_wheel: null,
57668
57681
  toolbar_collapsed: true,
57669
57682
  _toolbars_could_collapse: null,
57670
57683
  _on_focusout_restore: null,
@@ -57783,6 +57796,10 @@ function mt_destroy$4(gobj) {
57783
57796
  priv._uninstall_long_press();
57784
57797
  priv._uninstall_long_press = null;
57785
57798
  }
57799
+ if (priv._unforward_wheel) {
57800
+ priv._unforward_wheel();
57801
+ priv._unforward_wheel = null;
57802
+ }
57786
57803
  if (priv.graph) {
57787
57804
  priv.graph.destroy();
57788
57805
  priv.graph = null;
@@ -57892,6 +57909,7 @@ function build_graph$1(gobj) {
57892
57909
  plugins: []
57893
57910
  });
57894
57911
  graph.setTheme(priv.theme);
57912
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57895
57913
  graph.setLayout(layout);
57896
57914
  priv.graph_rendered = false;
57897
57915
  graph_render(gobj).then(() => {
@@ -11521,9 +11521,15 @@ function yui_graph_camera_behaviors() {
11521
11521
  * element that must scroll by itself (a popover) stops the
11522
11522
  * wheel before it gets here.
11523
11523
  *
11524
+ * `opts.selector` narrows it to the wheels whose target is
11525
+ * inside an element that matches, e.g. the root class of the
11526
+ * cards. A graph that puts other DOM in its container -- its
11527
+ * own toolbars, a legend -- passes one, so a wheel over those
11528
+ * is left to them instead of scrolling the graph.
11529
+ *
11524
11530
  * Returns the function that removes the listener.
11525
11531
  ************************************************************/
11526
- function yui_graph_forward_wheel(graph, $host) {
11532
+ function yui_graph_forward_wheel(graph, $host, opts = {}) {
11527
11533
  if (!graph || !$host) return () => {};
11528
11534
  const on_wheel = (e) => {
11529
11535
  let dom = null;
@@ -11533,6 +11539,7 @@ function yui_graph_forward_wheel(graph, $host) {
11533
11539
  return;
11534
11540
  }
11535
11541
  if (!dom || e.target === dom) return;
11542
+ if (opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) return;
11536
11543
  e.preventDefault();
11537
11544
  e.stopPropagation();
11538
11545
  dom.dispatchEvent(new WheelEvent("wheel", {
@@ -23052,6 +23059,10 @@ function nodes_answer(data) {
23052
23059
  * Constants
23053
23060
  ***************************************************************/
23054
23061
  var GCLASS_NAME$6 = "C_YUI_TREEDB_TOPICS";
23062
+ var TABLE_READ_OPTIONS = {
23063
+ list_dict: true,
23064
+ hook_size: true
23065
+ };
23055
23066
  /***************************************************************
23056
23067
  * Data
23057
23068
  ***************************************************************/
@@ -24084,7 +24095,7 @@ function get_nodes$1(gobj, topic_name) {
24084
24095
  subscribe_treedb$1(gobj, topic_name);
24085
24096
  let gobj_topic_form = get_gobj_formtable(gobj, topic_name);
24086
24097
  if (gobj_topic_form && gobj_read_bool_attr(gobj_topic_form, "with_remote_paging")) return;
24087
- treedb_nodes$1(gobj, treedb_name, topic_name, { list_dict: true });
24098
+ treedb_nodes$1(gobj, treedb_name, topic_name, Object.assign({}, TABLE_READ_OPTIONS));
24088
24099
  }
24089
24100
  /************************************************************
24090
24101
  *
@@ -24667,7 +24678,7 @@ function ac_request_page(gobj, event, kw, src) {
24667
24678
  log_error(`${gobj_short_name(gobj)}: a page request with no topic or no id`);
24668
24679
  return -1;
24669
24680
  }
24670
- if (treedb_nodes$1(gobj, gobj_read_str_attr(gobj, "treedb_name"), topic_name, { list_dict: true }, {
24681
+ if (treedb_nodes$1(gobj, gobj_read_str_attr(gobj, "treedb_name"), topic_name, Object.assign({}, TABLE_READ_OPTIONS), {
24671
24682
  from: kw.from,
24672
24683
  limit: kw.limit,
24673
24684
  req_id: kw.req_id
@@ -24821,7 +24832,8 @@ function ac_refresh_topic(gobj, event, kw, src) {
24821
24832
  gobj_send_event(gobj_topic_form, "EV_REPULL_PAGE", {}, gobj);
24822
24833
  return 0;
24823
24834
  }
24824
- treedb_nodes$1(gobj, gobj_read_str_attr(gobj, "treedb_name"), kw.topic_name, { list_dict: true });
24835
+ let options = Object.assign({}, TABLE_READ_OPTIONS);
24836
+ treedb_nodes$1(gobj, gobj_read_str_attr(gobj, "treedb_name"), kw.topic_name, options);
24825
24837
  return 0;
24826
24838
  }
24827
24839
  /********************************************
@@ -57660,6 +57672,7 @@ var PRIVATE_DATA$4 = {
57660
57672
  _on_pointerdown_focus: null,
57661
57673
  _on_native_contextmenu: null,
57662
57674
  _uninstall_long_press: null,
57675
+ _unforward_wheel: null,
57663
57676
  toolbar_collapsed: true,
57664
57677
  _toolbars_could_collapse: null,
57665
57678
  _on_focusout_restore: null,
@@ -57778,6 +57791,10 @@ function mt_destroy$4(gobj) {
57778
57791
  priv._uninstall_long_press();
57779
57792
  priv._uninstall_long_press = null;
57780
57793
  }
57794
+ if (priv._unforward_wheel) {
57795
+ priv._unforward_wheel();
57796
+ priv._unforward_wheel = null;
57797
+ }
57781
57798
  if (priv.graph) {
57782
57799
  priv.graph.destroy();
57783
57800
  priv.graph = null;
@@ -57887,6 +57904,7 @@ function build_graph$1(gobj) {
57887
57904
  plugins: []
57888
57905
  });
57889
57906
  graph.setTheme(priv.theme);
57907
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
57890
57908
  graph.setLayout(layout);
57891
57909
  priv.graph_rendered = false;
57892
57910
  graph_render(gobj).then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.162",
3
+ "version": "7.23.164",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -112,6 +112,7 @@ import {
112
112
  yui_graph_center_on,
113
113
  yui_graph_viewport_of,
114
114
  yui_graph_camera_behaviors,
115
+ yui_graph_forward_wheel,
115
116
  yui_graph_place_at,
116
117
  } from "./yui_graph_camera.js";
117
118
  import {
@@ -531,6 +532,7 @@ let PRIVATE_DATA = {
531
532
  _on_pointerdown_focus: null, // listener keeping the keyboard on the canvas
532
533
  _on_native_contextmenu: null, // listener keeping the browser's menu out
533
534
  _uninstall_long_press: null, // touch door to the context menu
535
+ _unforward_wheel: null, // removes the wheel forwarding of the cards
534
536
  toolbar_collapsed: true, // floating toolbars folded (narrow only)
535
537
  _toolbars_could_collapse: null, // last answer, to notice it changed
536
538
  _on_focusout_restore: null, // ...and putting it back when it goes nowhere
@@ -743,6 +745,11 @@ function mt_destroy(gobj)
743
745
  priv._uninstall_long_press = null;
744
746
  }
745
747
 
748
+ if(priv._unforward_wheel) {
749
+ priv._unforward_wheel();
750
+ priv._unforward_wheel = null;
751
+ }
752
+
746
753
  if(priv.graph) {
747
754
  priv.graph.destroy();
748
755
  priv.graph = null;
@@ -994,6 +1001,14 @@ function build_graph(gobj)
994
1001
  */
995
1002
  graph.setTheme(priv.theme);
996
1003
 
1004
+ /* A card is an HTML node, and G6's HTML nodes do not pass the wheel
1005
+ * on: over a card the graph neither scrolled nor zoomed. Only a wheel
1006
+ * over a CARD is handed back to the canvas -- the toolbars and the
1007
+ * legend live in this container too, and keep their own wheel. */
1008
+ priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, {
1009
+ selector: ".TREEDB_CARD, .TREEDB_PILLS"
1010
+ });
1011
+
997
1012
  graph.setLayout(layout);
998
1013
  //show_positions(gobj);
999
1014
 
@@ -74,6 +74,21 @@ import {t} from "i18next";
74
74
  ***************************************************************/
75
75
  const GCLASS_NAME = "C_YUI_TREEDB_TOPICS";
76
76
 
77
+ /*
78
+ * How a topic TABLE reads its rows. `hook_size`: a hook comes back as
79
+ * its COUNT, `[{"size": N}]`, not as the id of every child. The cell
80
+ * only ever showed the number, and a click on it opens the child topic
81
+ * filtered (EV_OPEN_LINKED) -- so the ids were downloaded for nothing:
82
+ * every device id, once per device type, on every load of that topic.
83
+ *
84
+ * Only the table LOADS use it. The writes keep their own options, and
85
+ * the node events still carry whole hooks (c_node publishes them with
86
+ * `list_dict`, whatever a reader asked for); the cell counts either
87
+ * shape (`treedb_hook_data_size`), and so does a delete's question
88
+ * (`delete_impact`'s ref_count).
89
+ */
90
+ const TABLE_READ_OPTIONS = {list_dict: true, hook_size: true};
91
+
77
92
  /***************************************************************
78
93
  * Data
79
94
  ***************************************************************/
@@ -1316,9 +1331,7 @@ function get_nodes(gobj, topic_name)
1316
1331
  gobj,
1317
1332
  treedb_name,
1318
1333
  topic_name,
1319
- {
1320
- list_dict: true
1321
- }
1334
+ Object.assign({}, TABLE_READ_OPTIONS)
1322
1335
  );
1323
1336
  }
1324
1337
 
@@ -2371,7 +2384,7 @@ function ac_request_page(gobj, event, kw, src)
2371
2384
  gobj,
2372
2385
  gobj_read_str_attr(gobj, "treedb_name"),
2373
2386
  topic_name,
2374
- {list_dict: true},
2387
+ Object.assign({}, TABLE_READ_OPTIONS),
2375
2388
  {from: kw.from, limit: kw.limit, req_id: kw.req_id}
2376
2389
  );
2377
2390
 
@@ -2592,9 +2605,7 @@ function ac_refresh_topic(gobj, event, kw, src)
2592
2605
  return 0;
2593
2606
  }
2594
2607
 
2595
- let options = {
2596
- list_dict: true
2597
- };
2608
+ let options = Object.assign({}, TABLE_READ_OPTIONS);
2598
2609
 
2599
2610
  let treedb_name = gobj_read_str_attr(gobj, "treedb_name");
2600
2611
 
@@ -171,9 +171,15 @@ export function yui_graph_camera_behaviors()
171
171
  * element that must scroll by itself (a popover) stops the
172
172
  * wheel before it gets here.
173
173
  *
174
+ * `opts.selector` narrows it to the wheels whose target is
175
+ * inside an element that matches, e.g. the root class of the
176
+ * cards. A graph that puts other DOM in its container -- its
177
+ * own toolbars, a legend -- passes one, so a wheel over those
178
+ * is left to them instead of scrolling the graph.
179
+ *
174
180
  * Returns the function that removes the listener.
175
181
  ************************************************************/
176
- export function yui_graph_forward_wheel(graph, $host)
182
+ export function yui_graph_forward_wheel(graph, $host, opts = {})
177
183
  {
178
184
  if(!graph || !$host) {
179
185
  return () => {};
@@ -188,6 +194,9 @@ export function yui_graph_forward_wheel(graph, $host)
188
194
  if(!dom || e.target === dom) {
189
195
  return;
190
196
  }
197
+ if(opts.selector && !(e.target instanceof Element && e.target.closest(opts.selector))) {
198
+ return; /* not over a card: that DOM keeps its own wheel */
199
+ }
191
200
  e.preventDefault();
192
201
  e.stopPropagation();
193
202
  dom.dispatchEvent(new WheelEvent("wheel", {