@yuneta/gobj-ui 7.23.21 → 7.23.22

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.
@@ -11031,6 +11031,8 @@ function build_cell_html(key, value, type, dark, matched, fold) {
11031
11031
  * forever. `+3` and `−` need no language.
11032
11032
  ************************************************************/
11033
11033
  var FOLD_SPACER = `<span style="width:24px; flex:0 0 auto;"></span>`;
11034
+ var CARD_HEADER_H$1 = 24;
11035
+ var CARD_ROW_H$1 = 22;
11034
11036
  function fold_toggle_html(path, foldable, folded, branches, colors) {
11035
11037
  if (!foldable) return FOLD_SPACER;
11036
11038
  let label = folded ? "+" + branches : "&#8722;";
@@ -11136,7 +11138,8 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11136
11138
  pending_complex.push({
11137
11139
  key,
11138
11140
  value,
11139
- port: port_key(key)
11141
+ port: port_key(key),
11142
+ row: lines.length
11140
11143
  });
11141
11144
  if (is_pure_collection(value)) {
11142
11145
  let child_path = add_segment(path, key);
@@ -11162,6 +11165,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11162
11165
  let border_width = card_matched ? 2 : 1;
11163
11166
  let content_html = lines.map((line) => `<div style="font-family:monospace; font-size:13px; padding:1px 6px; white-space:nowrap;">${line}</div>`).join("");
11164
11167
  let min_width = Math.max(180, label.length * 9);
11168
+ let card_height = CARD_HEADER_H$1 + lines.length * CARD_ROW_H$1;
11165
11169
  let node_html = `
11166
11170
  <div style="
11167
11171
  min-width: ${min_width}px;
@@ -11184,12 +11188,12 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11184
11188
  ${content_html}
11185
11189
  </div>`;
11186
11190
  let ports = [];
11187
- for (let i = 0; i < pending_complex.length; i++) {
11188
- let pending = pending_complex[i];
11191
+ for (let pending of pending_complex) {
11189
11192
  let child_colors = json_card_style((0, _yuneta_gobj_js.is_object)(pending.value) ? GROUP_COLORS.dict : GROUP_COLORS.list, dark);
11193
+ let row_mid = CARD_HEADER_H$1 + pending.row * CARD_ROW_H$1 + CARD_ROW_H$1 / 2;
11190
11194
  ports.push({
11191
11195
  key: pending.port,
11192
- placement: [getPointPosition(pending_complex.length, i), 1],
11196
+ placement: [1, row_mid / card_height],
11193
11197
  fill: child_colors.border,
11194
11198
  stroke: colors.border
11195
11199
  });
@@ -11203,9 +11207,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11203
11207
  },
11204
11208
  style: {
11205
11209
  innerHTML: node_html,
11206
- size: [min_width, 24 + lines.length * 22],
11210
+ size: [min_width, card_height],
11207
11211
  dx: -(min_width / 2),
11208
- dy: -((24 + lines.length * 22) / 2),
11212
+ dy: -(card_height / 2),
11209
11213
  port: ports.length > 0,
11210
11214
  ports,
11211
11215
  portR: 4,
@@ -11026,6 +11026,8 @@ function build_cell_html(key, value, type, dark, matched, fold) {
11026
11026
  * forever. `+3` and `−` need no language.
11027
11027
  ************************************************************/
11028
11028
  var FOLD_SPACER = `<span style="width:24px; flex:0 0 auto;"></span>`;
11029
+ var CARD_HEADER_H$1 = 24;
11030
+ var CARD_ROW_H$1 = 22;
11029
11031
  function fold_toggle_html(path, foldable, folded, branches, colors) {
11030
11032
  if (!foldable) return FOLD_SPACER;
11031
11033
  let label = folded ? "+" + branches : "&#8722;";
@@ -11131,7 +11133,8 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11131
11133
  pending_complex.push({
11132
11134
  key,
11133
11135
  value,
11134
- port: port_key(key)
11136
+ port: port_key(key),
11137
+ row: lines.length
11135
11138
  });
11136
11139
  if (is_pure_collection(value)) {
11137
11140
  let child_path = add_segment(path, key);
@@ -11157,6 +11160,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11157
11160
  let border_width = card_matched ? 2 : 1;
11158
11161
  let content_html = lines.map((line) => `<div style="font-family:monospace; font-size:13px; padding:1px 6px; white-space:nowrap;">${line}</div>`).join("");
11159
11162
  let min_width = Math.max(180, label.length * 9);
11163
+ let card_height = CARD_HEADER_H$1 + lines.length * CARD_ROW_H$1;
11160
11164
  let node_html = `
11161
11165
  <div style="
11162
11166
  min-width: ${min_width}px;
@@ -11179,12 +11183,12 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11179
11183
  ${content_html}
11180
11184
  </div>`;
11181
11185
  let ports = [];
11182
- for (let i = 0; i < pending_complex.length; i++) {
11183
- let pending = pending_complex[i];
11186
+ for (let pending of pending_complex) {
11184
11187
  let child_colors = json_card_style(is_object(pending.value) ? GROUP_COLORS.dict : GROUP_COLORS.list, dark);
11188
+ let row_mid = CARD_HEADER_H$1 + pending.row * CARD_ROW_H$1 + CARD_ROW_H$1 / 2;
11185
11189
  ports.push({
11186
11190
  key: pending.port,
11187
- placement: [getPointPosition(pending_complex.length, i), 1],
11191
+ placement: [1, row_mid / card_height],
11188
11192
  fill: child_colors.border,
11189
11193
  stroke: colors.border
11190
11194
  });
@@ -11198,9 +11202,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
11198
11202
  },
11199
11203
  style: {
11200
11204
  innerHTML: node_html,
11201
- size: [min_width, 24 + lines.length * 22],
11205
+ size: [min_width, card_height],
11202
11206
  dx: -(min_width / 2),
11203
- dy: -((24 + lines.length * 22) / 2),
11207
+ dy: -(card_height / 2),
11204
11208
  port: ports.length > 0,
11205
11209
  ports,
11206
11210
  portR: 4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.21",
3
+ "version": "7.23.22",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -72,7 +72,6 @@ import {
72
72
  import { ensure_drag_canvas_patch } from "./g6_drag_canvas_touch.js";
73
73
  import { ensure_pinch_zoom_patch } from "./g6_touch_gestures.js";
74
74
  import { yui_is_dark, yui_theme_now, yui_watch_theme } from "./yui_theme.js";
75
- import { getPointPosition } from "./lib_graph.js";
76
75
  import {
77
76
  is_pure_collection,
78
77
  has_branch,
@@ -885,6 +884,20 @@ function build_cell_html(key, value, type, dark, matched, fold)
885
884
  ************************************************************/
886
885
  const FOLD_SPACER = `<span style="width:24px; flex:0 0 auto;"></span>`;
887
886
 
887
+ /*
888
+ * The card's geometry, in ONE place.
889
+ *
890
+ * A container key's port is placed by computing WHICH ROW it is, so a
891
+ * row height changed in the markup and not here would slide every port
892
+ * off the line it belongs to -- silently, because nothing would fail:
893
+ * the dots would just stop pointing at anything.
894
+ *
895
+ * These are the rendered heights of the header (`padding: 3px 8px` on
896
+ * 12px bold) and of one body row (`padding: 1px 6px` on 13px monospace).
897
+ */
898
+ const CARD_HEADER_H = 24;
899
+ const CARD_ROW_H = 22;
900
+
888
901
  function fold_toggle_html(path, foldable, folded, branches, colors)
889
902
  {
890
903
  if(!foldable) {
@@ -1044,7 +1057,11 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
1044
1057
  */
1045
1058
  let fold = null;
1046
1059
  if(has_branch(value)) {
1047
- pending_complex.push({key: key, value: value, port: port_key(key)});
1060
+ /* `lines.length` is the index the row of this entry is about
1061
+ * to take, and it is what puts the port on that line. */
1062
+ pending_complex.push({
1063
+ key: key, value: value, port: port_key(key), row: lines.length
1064
+ });
1048
1065
 
1049
1066
  /*
1050
1067
  * A child that gets no card of its own is folded from HERE
@@ -1118,6 +1135,7 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
1118
1135
  ).join("");
1119
1136
 
1120
1137
  let min_width = Math.max(180, label.length * 9);
1138
+ let card_height = CARD_HEADER_H + lines.length * CARD_ROW_H;
1121
1139
 
1122
1140
  let node_html = `
1123
1141
  <div style="
@@ -1142,32 +1160,35 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
1142
1160
  </div>`;
1143
1161
 
1144
1162
  /*
1145
- * ONE PORT PER CONTAINER KEY, and every line leaves from its own.
1163
+ * ONE PORT PER CONTAINER KEY, ON THE LINE OF ITS OWN ROW.
1146
1164
  *
1147
- * Without them each card was a single anchor: fourteen lines came
1165
+ * Without ports each card was a single anchor: fourteen lines came
1148
1166
  * out of one point, and which row a line belonged to was a guess
1149
- * the reader had to make from where it landed. A port makes the row
1150
- * the ORIGIN, which is the same thing the treedb graph does with a
1151
- * hook column and the reason `getPointPosition` is now shared.
1167
+ * the reader made from where it landed.
1152
1168
  *
1153
- * On the BOTTOM edge because the layouts put children below, and
1154
- * exactly ON it (`y = 1`) rather than inside: an html node draws its
1155
- * HTML in a DOM layer above the canvas, so a port fully inside the
1156
- * box would be painted under the card and never seen. Half of it
1157
- * sticks out.
1169
+ * Spread along the bottom edge they were distinguishable but still
1170
+ * not ATTACHED to anything -- the reader had to count dots, count
1171
+ * rows, and trust that the two orders matched. Placed at the row's
1172
+ * own height there is nothing to match: the line leaves from beside
1173
+ * the key it belongs to, which is the whole point of a port.
1174
+ *
1175
+ * On the RIGHT edge, and exactly ON it (`x = 1`) rather than inside:
1176
+ * an html node draws its HTML in a DOM layer above the canvas, so a
1177
+ * port fully inside the box would be painted under the card and
1178
+ * never seen. Half of it sticks out.
1158
1179
  *
1159
1180
  * Coloured by what the row LEADS TO -- a dict or a list -- which is
1160
1181
  * the one thing the port can say that the row does not.
1161
1182
  */
1162
1183
  let ports = [];
1163
- for(let i = 0; i < pending_complex.length; i++) {
1164
- let pending = pending_complex[i];
1184
+ for(let pending of pending_complex) {
1165
1185
  let child_colors = json_card_style(
1166
1186
  is_object(pending.value)? GROUP_COLORS.dict: GROUP_COLORS.list, dark
1167
1187
  );
1188
+ let row_mid = CARD_HEADER_H + pending.row * CARD_ROW_H + CARD_ROW_H / 2;
1168
1189
  ports.push({
1169
1190
  key: pending.port,
1170
- placement: [getPointPosition(pending_complex.length, i), 1],
1191
+ placement: [1, row_mid / card_height],
1171
1192
  fill: child_colors.border,
1172
1193
  stroke: colors.border,
1173
1194
  });
@@ -1182,9 +1203,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
1182
1203
  },
1183
1204
  style: {
1184
1205
  innerHTML: node_html,
1185
- size: [min_width, 24 + lines.length * 22],
1206
+ size: [min_width, card_height],
1186
1207
  dx: -(min_width / 2),
1187
- dy: -((24 + lines.length * 22) / 2),
1208
+ dy: -(card_height / 2),
1188
1209
  port: ports.length > 0,
1189
1210
  ports: ports,
1190
1211
  portR: 4,