@yuneta/gobj-ui 7.23.21 → 7.23.23
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/dist/gobj-ui.cjs.js +22 -7
- package/dist/gobj-ui.es.js +22 -7
- package/package.json +1 -1
- package/src/c_yui_json_graph.js +77 -17
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -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 : "−";
|
|
@@ -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,18 @@ 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
|
-
|
|
11188
|
-
|
|
11191
|
+
if (parent_id) ports.push({
|
|
11192
|
+
key: "in",
|
|
11193
|
+
placement: [.5, 0],
|
|
11194
|
+
fill: colors.border,
|
|
11195
|
+
stroke: colors.border
|
|
11196
|
+
});
|
|
11197
|
+
for (let pending of pending_complex) {
|
|
11189
11198
|
let child_colors = json_card_style((0, _yuneta_gobj_js.is_object)(pending.value) ? GROUP_COLORS.dict : GROUP_COLORS.list, dark);
|
|
11199
|
+
let row_mid = CARD_HEADER_H$1 + pending.row * CARD_ROW_H$1 + CARD_ROW_H$1 / 2;
|
|
11190
11200
|
ports.push({
|
|
11191
11201
|
key: pending.port,
|
|
11192
|
-
placement: [
|
|
11202
|
+
placement: [1, row_mid / card_height],
|
|
11193
11203
|
fill: child_colors.border,
|
|
11194
11204
|
stroke: colors.border
|
|
11195
11205
|
});
|
|
@@ -11203,9 +11213,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
11203
11213
|
},
|
|
11204
11214
|
style: {
|
|
11205
11215
|
innerHTML: node_html,
|
|
11206
|
-
size: [min_width,
|
|
11216
|
+
size: [min_width, card_height],
|
|
11207
11217
|
dx: -(min_width / 2),
|
|
11208
|
-
dy: -(
|
|
11218
|
+
dy: -(card_height / 2),
|
|
11209
11219
|
port: ports.length > 0,
|
|
11210
11220
|
ports,
|
|
11211
11221
|
portR: 4,
|
|
@@ -11219,7 +11229,12 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
11219
11229
|
target: group_id,
|
|
11220
11230
|
style: {
|
|
11221
11231
|
stroke: colors.border,
|
|
11222
|
-
lineWidth: 1
|
|
11232
|
+
lineWidth: 1,
|
|
11233
|
+
endArrow: true,
|
|
11234
|
+
endArrowSize: 8,
|
|
11235
|
+
endArrowFill: colors.border,
|
|
11236
|
+
endArrowStroke: colors.border,
|
|
11237
|
+
targetPort: "in"
|
|
11223
11238
|
}
|
|
11224
11239
|
};
|
|
11225
11240
|
if (parent_port) edge.style.sourcePort = parent_port;
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -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 : "−";
|
|
@@ -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,18 @@ 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
|
-
|
|
11183
|
-
|
|
11186
|
+
if (parent_id) ports.push({
|
|
11187
|
+
key: "in",
|
|
11188
|
+
placement: [.5, 0],
|
|
11189
|
+
fill: colors.border,
|
|
11190
|
+
stroke: colors.border
|
|
11191
|
+
});
|
|
11192
|
+
for (let pending of pending_complex) {
|
|
11184
11193
|
let child_colors = json_card_style(is_object(pending.value) ? GROUP_COLORS.dict : GROUP_COLORS.list, dark);
|
|
11194
|
+
let row_mid = CARD_HEADER_H$1 + pending.row * CARD_ROW_H$1 + CARD_ROW_H$1 / 2;
|
|
11185
11195
|
ports.push({
|
|
11186
11196
|
key: pending.port,
|
|
11187
|
-
placement: [
|
|
11197
|
+
placement: [1, row_mid / card_height],
|
|
11188
11198
|
fill: child_colors.border,
|
|
11189
11199
|
stroke: colors.border
|
|
11190
11200
|
});
|
|
@@ -11198,9 +11208,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
11198
11208
|
},
|
|
11199
11209
|
style: {
|
|
11200
11210
|
innerHTML: node_html,
|
|
11201
|
-
size: [min_width,
|
|
11211
|
+
size: [min_width, card_height],
|
|
11202
11212
|
dx: -(min_width / 2),
|
|
11203
|
-
dy: -(
|
|
11213
|
+
dy: -(card_height / 2),
|
|
11204
11214
|
port: ports.length > 0,
|
|
11205
11215
|
ports,
|
|
11206
11216
|
portR: 4,
|
|
@@ -11214,7 +11224,12 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
11214
11224
|
target: group_id,
|
|
11215
11225
|
style: {
|
|
11216
11226
|
stroke: colors.border,
|
|
11217
|
-
lineWidth: 1
|
|
11227
|
+
lineWidth: 1,
|
|
11228
|
+
endArrow: true,
|
|
11229
|
+
endArrowSize: 8,
|
|
11230
|
+
endArrowFill: colors.border,
|
|
11231
|
+
endArrowStroke: colors.border,
|
|
11232
|
+
targetPort: "in"
|
|
11218
11233
|
}
|
|
11219
11234
|
};
|
|
11220
11235
|
if (parent_port) edge.style.sourcePort = parent_port;
|
package/package.json
CHANGED
package/src/c_yui_json_graph.js
CHANGED
|
@@ -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
|
-
|
|
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,57 @@ 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,
|
|
1163
|
+
* ONE PORT PER CONTAINER KEY, ON THE LINE OF ITS OWN ROW.
|
|
1146
1164
|
*
|
|
1147
|
-
* Without
|
|
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
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1167
|
+
* the reader made from where it landed.
|
|
1168
|
+
*
|
|
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.
|
|
1152
1174
|
*
|
|
1153
|
-
* On the
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* sticks out.
|
|
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
|
-
|
|
1164
|
-
|
|
1184
|
+
|
|
1185
|
+
/*
|
|
1186
|
+
* The port a line ARRIVES at: one per card, above the title and
|
|
1187
|
+
* centred, and only on a card that has a parent -- the root
|
|
1188
|
+
* receives nothing, so a dot there would mark a door onto nothing.
|
|
1189
|
+
*
|
|
1190
|
+
* One and not one-per-parent because a card has exactly ONE parent
|
|
1191
|
+
* in a JSON document: what varies is which key of that parent it
|
|
1192
|
+
* hangs from, and that is what the source ports say.
|
|
1193
|
+
*
|
|
1194
|
+
* Keyed `in` with no prefix, which is why the key ports carry one:
|
|
1195
|
+
* no `p_<key>` can ever collide with it.
|
|
1196
|
+
*/
|
|
1197
|
+
if(parent_id) {
|
|
1198
|
+
ports.push({
|
|
1199
|
+
key: "in",
|
|
1200
|
+
placement: [0.5, 0],
|
|
1201
|
+
fill: colors.border,
|
|
1202
|
+
stroke: colors.border,
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
for(let pending of pending_complex) {
|
|
1165
1207
|
let child_colors = json_card_style(
|
|
1166
1208
|
is_object(pending.value)? GROUP_COLORS.dict: GROUP_COLORS.list, dark
|
|
1167
1209
|
);
|
|
1210
|
+
let row_mid = CARD_HEADER_H + pending.row * CARD_ROW_H + CARD_ROW_H / 2;
|
|
1168
1211
|
ports.push({
|
|
1169
1212
|
key: pending.port,
|
|
1170
|
-
placement: [
|
|
1213
|
+
placement: [1, row_mid / card_height],
|
|
1171
1214
|
fill: child_colors.border,
|
|
1172
1215
|
stroke: colors.border,
|
|
1173
1216
|
});
|
|
@@ -1182,9 +1225,9 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1182
1225
|
},
|
|
1183
1226
|
style: {
|
|
1184
1227
|
innerHTML: node_html,
|
|
1185
|
-
size: [min_width,
|
|
1228
|
+
size: [min_width, card_height],
|
|
1186
1229
|
dx: -(min_width / 2),
|
|
1187
|
-
dy: -(
|
|
1230
|
+
dy: -(card_height / 2),
|
|
1188
1231
|
port: ports.length > 0,
|
|
1189
1232
|
ports: ports,
|
|
1190
1233
|
portR: 4,
|
|
@@ -1203,6 +1246,23 @@ function build_json_nodes(gobj, path, kw, nodes, edges, parent_id, parent_port)
|
|
|
1203
1246
|
style: {
|
|
1204
1247
|
stroke: colors.border,
|
|
1205
1248
|
lineWidth: 1,
|
|
1249
|
+
/*
|
|
1250
|
+
* Said on the EDGE and not left to the graph's element
|
|
1251
|
+
* default: a per-element `style` is what the reader of
|
|
1252
|
+
* this code sees, and an arrow that lives somewhere
|
|
1253
|
+
* else is an arrow nobody can find when it stops
|
|
1254
|
+
* being drawn.
|
|
1255
|
+
*
|
|
1256
|
+
* Filled with the line's own colour, because an
|
|
1257
|
+
* arrowhead in the default fill is a black triangle on
|
|
1258
|
+
* a teal line in light and an invisible one in dark.
|
|
1259
|
+
*/
|
|
1260
|
+
endArrow: true,
|
|
1261
|
+
endArrowSize: 8,
|
|
1262
|
+
endArrowFill: colors.border,
|
|
1263
|
+
endArrowStroke: colors.border,
|
|
1264
|
+
/* It lands on the card's `in` port, above the title. */
|
|
1265
|
+
targetPort: "in",
|
|
1206
1266
|
}
|
|
1207
1267
|
};
|
|
1208
1268
|
if(parent_port) {
|