@yuneta/gobj-ui 6.3.0 → 6.3.2

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
@@ -529,9 +529,13 @@ Two implementation notes worth keeping:
529
529
 
530
530
  A landing view that draws a treedb the way its schema literal draws it in ASCII
531
531
  (`treedb_schema_*.c`, `treedb_system_schema.c`): **one card per topic**,
532
- listing its fields in schema order, and **one edge per hook**, leaving the row
533
- that declares the hook and landing on the fkey row of the child it names. Built
534
- from the schema `descs` **alone**: no data, no backend calls. It is the "every
532
+ listing its fields in schema order, and **one edge per hook**, between the row
533
+ that declares the hook and the fkey row of the child it names. The **arrowhead
534
+ is on the hook**, the way the `.c` draws it and the way the `↖` of the fkey
535
+ mark reads: the reference is held by the child and points at its parent. The
536
+ edge itself is declared parent → child, which is what ranks the parent to the
537
+ left, first, as the literal lists it. Built from the schema `descs` **alone**:
538
+ no data, no backend calls. It is the "every
535
539
  treedb is a graph" rule applied to the schema itself, and an alternate landing
536
540
  to the topic cards. A node click opens that topic's table through a real hash
537
541
  navigation, so the graph is a navigation surface rather than a picture.
@@ -19796,9 +19796,11 @@ function register_c_yui_treedb_graph() {
19796
19796
  * Schema-graph landing: the treedb drawn the way its `.c` literal
19797
19797
  * draws it in ASCII (treedb_schema_*.c, treedb_system_schema.c) —
19798
19798
  * one CARD per topic listing its fields in schema order, one edge
19799
- * per hook, from the row that declares the hook to the fkey row of
19800
- * the child it names. Built from the schema `descs` alone: no data,
19801
- * no backend calls.
19799
+ * per hook, between the row that declares the hook and the fkey row
19800
+ * of the child it names arrowhead on the HOOK, as the `.c` draws
19801
+ * it and as the `↖` of the fkey mark says: the reference is the
19802
+ * child's and it points at its parent. Built from the schema
19803
+ * `descs` alone: no data, no backend calls.
19802
19804
  *
19803
19805
  * WHY THE CARD AND NOT A DOT. A topic is its fields; a schema is
19804
19806
  * read to find out what a topic holds and what links to what. A
@@ -20058,14 +20060,17 @@ ${rows_html} </div>
20058
20060
  * Derive {nodes, edges} from the schema.
20059
20061
  *
20060
20062
  * Node = a topic, drawn as the card the `.c` literal draws in
20061
- * ASCII: its name and its fields. Edge = a hook, from the row
20062
- * that declares it to the fkey row of the child it names
20063
- * `'hook': {'users': 'departments'}` says both ends, so the
20064
- * arrow can land where the `.c` drawing lands it. An fkey
20065
- * whose parent declares no hook still gets its edge, or a
20063
+ * ASCII: its name and its fields. Edge = a hook, between the
20064
+ * row that declares it and the fkey row of the child it names
20065
+ * `'hook': {'users': 'departments'}` says both ends, so the
20066
+ * edge can land on the rows the `.c` drawing lands it on. An
20067
+ * fkey whose parent declares no hook still gets its edge, or a
20066
20068
  * half-declared schema would draw as disconnected.
20067
20069
  *
20068
- * Left-to-right dagre follows the parent -> child data flow.
20070
+ * An edge is declared parent -> child so left-to-right dagre
20071
+ * ranks the parent first, the order the `.c` literal lists
20072
+ * them in. The ARROWHEAD is the other way (see edge_style):
20073
+ * the fkey points at the hook, never the hook at the fkey.
20069
20074
  ************************************************************/
20070
20075
  function schema_to_graph(gobj) {
20071
20076
  let descs = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "descs");
@@ -20165,12 +20170,20 @@ function schema_to_graph(gobj) {
20165
20170
  * the graph is built and re-applied on a theme switch
20166
20171
  * (ac_theme), which restyles the LIVE graph — rebuilding it
20167
20172
  * would drop the user's zoom/pan and any dragged node.
20173
+ *
20174
+ * The arrowhead is at the START of the edge, on the parent's
20175
+ * hook — the direction the `.c` literals draw and the `↖` of
20176
+ * the fkey mark names: the reference is held by the CHILD and
20177
+ * points at its parent. The edge is still declared parent ->
20178
+ * child, which is what ranks the parent to the left; only the
20179
+ * marker says who points at whom.
20168
20180
  ************************************************************/
20169
20181
  function edge_style(dark) {
20170
20182
  return {
20171
20183
  stroke: dark ? "#7a8593" : "#9aa4b2",
20172
20184
  lineWidth: 1.2,
20173
- endArrow: true
20185
+ startArrow: true,
20186
+ endArrow: false
20174
20187
  };
20175
20188
  }
20176
20189
  /************************************************************
@@ -20224,11 +20237,7 @@ function build_graph$1(gobj) {
20224
20237
  let node_id = evt && evt.target && evt.target.id;
20225
20238
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_NODE_CLICK", { node_id }, gobj);
20226
20239
  });
20227
- graph.render().then(() => {
20228
- try {
20229
- graph.fitView();
20230
- } catch (e) {}
20231
- }).catch((e) => {
20240
+ graph.render().catch((e) => {
20232
20241
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: schema graph render failed: ${e}`);
20233
20242
  });
20234
20243
  }
@@ -20282,8 +20291,10 @@ function ac_node_click$2(gobj, event, kw, src) {
20282
20291
  return 0;
20283
20292
  }
20284
20293
  /************************************************************
20285
- * Shown by the host: (re)fit the view now the container is
20286
- * visible and sized (G6 renders at 0×0 while display:none).
20294
+ * Shown by the host: match the canvas to the container now it
20295
+ * is visible and sized (G6 renders at 0×0 while display:none).
20296
+ * A resize only, never a fit: the camera stays where it was, so
20297
+ * the diagram keeps its scale and the user's pan/zoom.
20287
20298
  ************************************************************/
20288
20299
  function ac_show$2(gobj, event, kw, src) {
20289
20300
  let priv = gobj.priv;
@@ -20292,7 +20303,7 @@ function ac_show$2(gobj, event, kw, src) {
20292
20303
  return 0;
20293
20304
  }
20294
20305
  try {
20295
- priv.graph.fitView();
20306
+ priv.graph.resize();
20296
20307
  } catch (e) {}
20297
20308
  return 0;
20298
20309
  }
@@ -19783,9 +19783,11 @@ function register_c_yui_treedb_graph() {
19783
19783
  * Schema-graph landing: the treedb drawn the way its `.c` literal
19784
19784
  * draws it in ASCII (treedb_schema_*.c, treedb_system_schema.c) —
19785
19785
  * one CARD per topic listing its fields in schema order, one edge
19786
- * per hook, from the row that declares the hook to the fkey row of
19787
- * the child it names. Built from the schema `descs` alone: no data,
19788
- * no backend calls.
19786
+ * per hook, between the row that declares the hook and the fkey row
19787
+ * of the child it names arrowhead on the HOOK, as the `.c` draws
19788
+ * it and as the `↖` of the fkey mark says: the reference is the
19789
+ * child's and it points at its parent. Built from the schema
19790
+ * `descs` alone: no data, no backend calls.
19789
19791
  *
19790
19792
  * WHY THE CARD AND NOT A DOT. A topic is its fields; a schema is
19791
19793
  * read to find out what a topic holds and what links to what. A
@@ -20045,14 +20047,17 @@ ${rows_html} </div>
20045
20047
  * Derive {nodes, edges} from the schema.
20046
20048
  *
20047
20049
  * Node = a topic, drawn as the card the `.c` literal draws in
20048
- * ASCII: its name and its fields. Edge = a hook, from the row
20049
- * that declares it to the fkey row of the child it names
20050
- * `'hook': {'users': 'departments'}` says both ends, so the
20051
- * arrow can land where the `.c` drawing lands it. An fkey
20052
- * whose parent declares no hook still gets its edge, or a
20050
+ * ASCII: its name and its fields. Edge = a hook, between the
20051
+ * row that declares it and the fkey row of the child it names
20052
+ * `'hook': {'users': 'departments'}` says both ends, so the
20053
+ * edge can land on the rows the `.c` drawing lands it on. An
20054
+ * fkey whose parent declares no hook still gets its edge, or a
20053
20055
  * half-declared schema would draw as disconnected.
20054
20056
  *
20055
- * Left-to-right dagre follows the parent -> child data flow.
20057
+ * An edge is declared parent -> child so left-to-right dagre
20058
+ * ranks the parent first, the order the `.c` literal lists
20059
+ * them in. The ARROWHEAD is the other way (see edge_style):
20060
+ * the fkey points at the hook, never the hook at the fkey.
20056
20061
  ************************************************************/
20057
20062
  function schema_to_graph(gobj) {
20058
20063
  let descs = gobj_read_attr(gobj, "descs");
@@ -20152,12 +20157,20 @@ function schema_to_graph(gobj) {
20152
20157
  * the graph is built and re-applied on a theme switch
20153
20158
  * (ac_theme), which restyles the LIVE graph — rebuilding it
20154
20159
  * would drop the user's zoom/pan and any dragged node.
20160
+ *
20161
+ * The arrowhead is at the START of the edge, on the parent's
20162
+ * hook — the direction the `.c` literals draw and the `↖` of
20163
+ * the fkey mark names: the reference is held by the CHILD and
20164
+ * points at its parent. The edge is still declared parent ->
20165
+ * child, which is what ranks the parent to the left; only the
20166
+ * marker says who points at whom.
20155
20167
  ************************************************************/
20156
20168
  function edge_style(dark) {
20157
20169
  return {
20158
20170
  stroke: dark ? "#7a8593" : "#9aa4b2",
20159
20171
  lineWidth: 1.2,
20160
- endArrow: true
20172
+ startArrow: true,
20173
+ endArrow: false
20161
20174
  };
20162
20175
  }
20163
20176
  /************************************************************
@@ -20211,11 +20224,7 @@ function build_graph$1(gobj) {
20211
20224
  let node_id = evt && evt.target && evt.target.id;
20212
20225
  gobj_send_event(gobj, "EV_NODE_CLICK", { node_id }, gobj);
20213
20226
  });
20214
- graph.render().then(() => {
20215
- try {
20216
- graph.fitView();
20217
- } catch (e) {}
20218
- }).catch((e) => {
20227
+ graph.render().catch((e) => {
20219
20228
  log_error(`${gobj_short_name(gobj)}: schema graph render failed: ${e}`);
20220
20229
  });
20221
20230
  }
@@ -20269,8 +20278,10 @@ function ac_node_click$2(gobj, event, kw, src) {
20269
20278
  return 0;
20270
20279
  }
20271
20280
  /************************************************************
20272
- * Shown by the host: (re)fit the view now the container is
20273
- * visible and sized (G6 renders at 0×0 while display:none).
20281
+ * Shown by the host: match the canvas to the container now it
20282
+ * is visible and sized (G6 renders at 0×0 while display:none).
20283
+ * A resize only, never a fit: the camera stays where it was, so
20284
+ * the diagram keeps its scale and the user's pan/zoom.
20274
20285
  ************************************************************/
20275
20286
  function ac_show$2(gobj, event, kw, src) {
20276
20287
  let priv = gobj.priv;
@@ -20279,7 +20290,7 @@ function ac_show$2(gobj, event, kw, src) {
20279
20290
  return 0;
20280
20291
  }
20281
20292
  try {
20282
- priv.graph.fitView();
20293
+ priv.graph.resize();
20283
20294
  } catch (e) {}
20284
20295
  return 0;
20285
20296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "6.3.0",
3
+ "version": "6.3.2",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -4,9 +4,11 @@
4
4
  * Schema-graph landing: the treedb drawn the way its `.c` literal
5
5
  * draws it in ASCII (treedb_schema_*.c, treedb_system_schema.c) —
6
6
  * one CARD per topic listing its fields in schema order, one edge
7
- * per hook, from the row that declares the hook to the fkey row of
8
- * the child it names. Built from the schema `descs` alone: no data,
9
- * no backend calls.
7
+ * per hook, between the row that declares the hook and the fkey row
8
+ * of the child it names arrowhead on the HOOK, as the `.c` draws
9
+ * it and as the `↖` of the fkey mark says: the reference is the
10
+ * child's and it points at its parent. Built from the schema
11
+ * `descs` alone: no data, no backend calls.
10
12
  *
11
13
  * WHY THE CARD AND NOT A DOT. A topic is its fields; a schema is
12
14
  * read to find out what a topic holds and what links to what. A
@@ -380,14 +382,17 @@ ${rows_html} </div>
380
382
  * Derive {nodes, edges} from the schema.
381
383
  *
382
384
  * Node = a topic, drawn as the card the `.c` literal draws in
383
- * ASCII: its name and its fields. Edge = a hook, from the row
384
- * that declares it to the fkey row of the child it names
385
- * `'hook': {'users': 'departments'}` says both ends, so the
386
- * arrow can land where the `.c` drawing lands it. An fkey
387
- * whose parent declares no hook still gets its edge, or a
385
+ * ASCII: its name and its fields. Edge = a hook, between the
386
+ * row that declares it and the fkey row of the child it names
387
+ * `'hook': {'users': 'departments'}` says both ends, so the
388
+ * edge can land on the rows the `.c` drawing lands it on. An
389
+ * fkey whose parent declares no hook still gets its edge, or a
388
390
  * half-declared schema would draw as disconnected.
389
391
  *
390
- * Left-to-right dagre follows the parent -> child data flow.
392
+ * An edge is declared parent -> child so left-to-right dagre
393
+ * ranks the parent first, the order the `.c` literal lists
394
+ * them in. The ARROWHEAD is the other way (see edge_style):
395
+ * the fkey points at the hook, never the hook at the fkey.
391
396
  ************************************************************/
392
397
  function schema_to_graph(gobj)
393
398
  {
@@ -509,13 +514,21 @@ function schema_to_graph(gobj)
509
514
  * the graph is built and re-applied on a theme switch
510
515
  * (ac_theme), which restyles the LIVE graph — rebuilding it
511
516
  * would drop the user's zoom/pan and any dragged node.
517
+ *
518
+ * The arrowhead is at the START of the edge, on the parent's
519
+ * hook — the direction the `.c` literals draw and the `↖` of
520
+ * the fkey mark names: the reference is held by the CHILD and
521
+ * points at its parent. The edge is still declared parent ->
522
+ * child, which is what ranks the parent to the left; only the
523
+ * marker says who points at whom.
512
524
  ************************************************************/
513
525
  function edge_style(dark)
514
526
  {
515
527
  return {
516
528
  stroke: dark ? "#7a8593" : "#9aa4b2",
517
529
  lineWidth: 1.2,
518
- endArrow: true,
530
+ startArrow: true,
531
+ endArrow: false,
519
532
  };
520
533
  }
521
534
 
@@ -574,13 +587,10 @@ function build_graph(gobj)
574
587
  gobj_send_event(gobj, "EV_NODE_CLICK", {node_id: node_id}, gobj);
575
588
  });
576
589
 
577
- graph.render().then(() => {
578
- try {
579
- graph.fitView();
580
- } catch(e) {
581
- // best-effort centring
582
- }
583
- }).catch((e) => {
590
+ /* No fitView: the diagram is drawn at its own scale and stays there.
591
+ * Zooming it to the container the moment it appears rewrites the size
592
+ * the reader just saw, and does it differently for every treedb. */
593
+ graph.render().catch((e) => {
584
594
  log_error(`${gobj_short_name(gobj)}: schema graph render failed: ${e}`);
585
595
  });
586
596
  }
@@ -659,8 +669,10 @@ function ac_node_click(gobj, event, kw, src)
659
669
  }
660
670
 
661
671
  /************************************************************
662
- * Shown by the host: (re)fit the view now the container is
663
- * visible and sized (G6 renders at 0×0 while display:none).
672
+ * Shown by the host: match the canvas to the container now it
673
+ * is visible and sized (G6 renders at 0×0 while display:none).
674
+ * A resize only, never a fit: the camera stays where it was, so
675
+ * the diagram keeps its scale and the user's pan/zoom.
664
676
  ************************************************************/
665
677
  function ac_show(gobj, event, kw, src)
666
678
  {
@@ -670,7 +682,7 @@ function ac_show(gobj, event, kw, src)
670
682
  return 0;
671
683
  }
672
684
  try {
673
- priv.graph.fitView();
685
+ priv.graph.resize();
674
686
  } catch(e) {
675
687
  // best-effort
676
688
  }