@yuneta/gobj-ui 7.26.6 → 7.26.8
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 +74 -25
- package/dist/gobj-ui.cjs.js +967 -377
- package/dist/gobj-ui.es.js +967 -377
- package/index.js +5 -1
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +69 -24
- package/src/c_yui_form.js +331 -140
- package/src/c_yui_gclass.js +26 -21
- package/src/c_yui_gobj_tree_js.js +16 -5
- package/src/c_yui_json.js +7 -6
- package/src/c_yui_json_graph.js +42 -14
- package/src/c_yui_json_pad.js +2 -1
- package/src/c_yui_map.js +139 -75
- package/src/c_yui_nav.js +60 -20
- package/src/c_yui_pager.js +14 -9
- package/src/c_yui_period.js +16 -6
- package/src/c_yui_schema_editor.js +3 -2
- package/src/c_yui_shell.js +96 -31
- package/src/c_yui_treedb_topic_with_form.js +50 -56
- package/src/c_yui_treedb_topics.js +8 -7
- package/src/c_yui_uplot.js +1 -1
- package/src/c_yui_window.js +123 -36
- package/src/c_yui_window_manager.js +8 -3
- package/src/c_yui_wizard.js +23 -8
- package/src/delete_impact.js +5 -3
- package/src/form_json_field.js +123 -0
- package/src/form_json_field.test.js +49 -0
- package/src/form_json_field.wiring.test.js +137 -0
- package/src/form_table_rearm.wiring.test.js +158 -0
- package/src/g6_event_kw.js +36 -0
- package/src/nav_cards_helpers.js +2 -1
- package/src/nav_cards_helpers.test.js +7 -3
- package/src/schema_to_c.js +27 -1
- package/src/schema_to_c.test.js +15 -1
- package/src/shell_modals.js +5 -3
- package/src/shell_route_map.js +18 -13
- package/src/treedb_topics_transport.wiring.test.js +35 -1
- package/src/vite_plugin_yuneta_html.test.js +79 -0
- package/src/window_show.wiring.test.js +83 -0
- package/src/window_veto_back.wiring.test.js +136 -0
- package/src/wizard_chrome.wiring.test.js +87 -0
- package/src/yui_dev.js +23 -14
- package/src/yui_frontend_view.js +4 -4
- package/src/yui_gclass_view.js +3 -3
- package/src/yui_table_filter_clear.js +44 -44
- package/src/yui_text.js +31 -0
- package/src/yui_text.test.js +39 -0
- package/vite-plugin-yuneta-html.js +36 -9
package/src/c_yui_gclass.js
CHANGED
|
@@ -85,6 +85,7 @@ import {yui_copy_json, yui_button_mark_done} from "./yui_clipboard.js";
|
|
|
85
85
|
import {t} from "i18next";
|
|
86
86
|
|
|
87
87
|
import "./c_yui_gclass.css";
|
|
88
|
+
import {text_node} from "./yui_text.js";
|
|
88
89
|
|
|
89
90
|
|
|
90
91
|
/***************************************************************
|
|
@@ -451,7 +452,7 @@ function render_raw(gobj)
|
|
|
451
452
|
|
|
452
453
|
let dump = json_text_dump(description, MAX_RAW_CHARS);
|
|
453
454
|
let children = [
|
|
454
|
-
['pre', {class: 'GCLASS_RAW_BODY'}, dump.text]
|
|
455
|
+
['pre', {class: 'GCLASS_RAW_BODY'}, document.createTextNode(String(dump.text))]
|
|
455
456
|
];
|
|
456
457
|
if(dump.capped) {
|
|
457
458
|
children.push(
|
|
@@ -568,7 +569,7 @@ function build_head(gobj, model)
|
|
|
568
569
|
}
|
|
569
570
|
|
|
570
571
|
for(let flag of model.gcflag) {
|
|
571
|
-
items.push(['span', {class: 'GCLASS_CHIP GCLASS_GCFLAG'}, flag]);
|
|
572
|
+
items.push(['span', {class: 'GCLASS_CHIP GCLASS_GCFLAG'}, text_node(flag)]);
|
|
572
573
|
}
|
|
573
574
|
|
|
574
575
|
let current = gobj_read_str_attr(gobj, "current_state");
|
|
@@ -633,6 +634,8 @@ function build_zone(gobj, zone)
|
|
|
633
634
|
|
|
634
635
|
let $toggle = createElement2(
|
|
635
636
|
['button', {class: 'GCLASS_ZONE_TOGGLE', type: 'button',
|
|
637
|
+
title: t(zone.key), 'data-i18n-title': zone.key,
|
|
638
|
+
'aria-label': t(zone.key), 'data-i18n-aria-label': zone.key,
|
|
636
639
|
'aria-expanded': collapsed? 'false': 'true'}, [
|
|
637
640
|
['span', {class: 'icon GCLASS_ZONE_ARROW'}, [
|
|
638
641
|
['i', {class: collapsed? 'yi-chevron-right': 'yi-chevron-down'}]
|
|
@@ -708,7 +711,7 @@ function flag_chips(flags)
|
|
|
708
711
|
} else if(flag.indexOf("REQUIRED") >= 0) {
|
|
709
712
|
cls += ' is-required';
|
|
710
713
|
}
|
|
711
|
-
return ['span', {class: cls}, flag];
|
|
714
|
+
return ['span', {class: cls}, text_node(flag)];
|
|
712
715
|
});
|
|
713
716
|
}
|
|
714
717
|
|
|
@@ -723,11 +726,13 @@ function build_attrs(attrs)
|
|
|
723
726
|
|
|
724
727
|
let rows = attrs.map(function(a) {
|
|
725
728
|
return ['tr', row_attrs(`${a.id} ${a.type} ${a.flags.join(" ")} ${a.description}`), [
|
|
726
|
-
['td', {class: 'GCLASS_CELL_KEY'}, a.id],
|
|
727
|
-
['td', {class: 'GCLASS_CELL_TYPE'}, a.type],
|
|
729
|
+
['td', {class: 'GCLASS_CELL_KEY'}, text_node(a.id)],
|
|
730
|
+
['td', {class: 'GCLASS_CELL_TYPE'}, text_node(a.type)],
|
|
728
731
|
['td', {class: 'GCLASS_CELL_FLAGS'}, flag_chips(a.flags)],
|
|
729
|
-
|
|
730
|
-
|
|
732
|
+
/* What a remote yuno answers is data, not markup: Text nodes,
|
|
733
|
+
* or a default starting with '<' would be parsed as HTML. */
|
|
734
|
+
['td', {class: 'GCLASS_CELL_DEFAULT'}, text_node(a.default_value)],
|
|
735
|
+
['td', {class: 'GCLASS_CELL_DESC'}, text_node(a.description)]
|
|
731
736
|
]];
|
|
732
737
|
});
|
|
733
738
|
|
|
@@ -763,20 +768,20 @@ function build_commands(commands)
|
|
|
763
768
|
for(let c of commands) {
|
|
764
769
|
if(c.kind === "section") {
|
|
765
770
|
rows.push(['tr', row_attrs(c.label, {class: 'GCLASS_ROW GCLASS_CMD_SECTION'}), [
|
|
766
|
-
['td', {colspan: '2'}, c.label]
|
|
771
|
+
['td', {colspan: '2'}, text_node(c.label)]
|
|
767
772
|
]]);
|
|
768
773
|
continue;
|
|
769
774
|
}
|
|
770
775
|
|
|
771
|
-
let name_items = [['span', {class: 'GCLASS_CMD_NAME'}, c.id]];
|
|
776
|
+
let name_items = [['span', {class: 'GCLASS_CMD_NAME'}, text_node(c.id)]];
|
|
772
777
|
for(let alias of c.alias) {
|
|
773
|
-
name_items.push(['span', {class: 'GCLASS_CHIP GCLASS_ALIAS'}, alias]);
|
|
778
|
+
name_items.push(['span', {class: 'GCLASS_CHIP GCLASS_ALIAS'}, text_node(alias)]);
|
|
774
779
|
}
|
|
775
780
|
name_items = name_items.concat(flag_chips(c.flags));
|
|
776
781
|
|
|
777
782
|
rows.push(['tr', row_attrs(`${c.id} ${c.alias.join(" ")} ${c.description}`), [
|
|
778
783
|
['td', {class: 'GCLASS_CELL_KEY'}, name_items],
|
|
779
|
-
['td', {class: 'GCLASS_CELL_DESC'}, c.description]
|
|
784
|
+
['td', {class: 'GCLASS_CELL_DESC'}, text_node(c.description)]
|
|
780
785
|
]]);
|
|
781
786
|
|
|
782
787
|
for(let p of c.parameters) {
|
|
@@ -784,10 +789,10 @@ function build_commands(commands)
|
|
|
784
789
|
{class: 'GCLASS_ROW GCLASS_CMD_PARAM'}), [
|
|
785
790
|
['td', {class: 'GCLASS_CELL_KEY'}, [
|
|
786
791
|
['span', {class: 'GCLASS_PARAM_MARK'}, "↳"],
|
|
787
|
-
['span', {class: 'GCLASS_PARAM_NAME'}, p.id],
|
|
788
|
-
['span', {class: 'GCLASS_PARAM_TYPE'}, p.type]
|
|
792
|
+
['span', {class: 'GCLASS_PARAM_NAME'}, text_node(p.id)],
|
|
793
|
+
['span', {class: 'GCLASS_PARAM_TYPE'}, text_node(p.type)]
|
|
789
794
|
].concat(flag_chips(p.flags))],
|
|
790
|
-
['td', {class: 'GCLASS_CELL_DESC'}, p.description]
|
|
795
|
+
['td', {class: 'GCLASS_CELL_DESC'}, text_node(p.description)]
|
|
791
796
|
]]);
|
|
792
797
|
}
|
|
793
798
|
}
|
|
@@ -838,8 +843,8 @@ function build_traces(levels)
|
|
|
838
843
|
|
|
839
844
|
let rows = levels.map(function(l) {
|
|
840
845
|
return ['tr', row_attrs(`${l.id} ${l.description}`), [
|
|
841
|
-
['td', {class: 'GCLASS_CELL_KEY'}, l.id],
|
|
842
|
-
['td', {class: 'GCLASS_CELL_DESC'}, l.description]
|
|
846
|
+
['td', {class: 'GCLASS_CELL_KEY'}, text_node(l.id)],
|
|
847
|
+
['td', {class: 'GCLASS_CELL_DESC'}, text_node(l.description)]
|
|
843
848
|
]];
|
|
844
849
|
});
|
|
845
850
|
|
|
@@ -877,7 +882,7 @@ function build_machine(gobj, fsm)
|
|
|
877
882
|
];
|
|
878
883
|
for(let state of fsm.states) {
|
|
879
884
|
let cls = 'GCLASS_MX_STATE';
|
|
880
|
-
let items = [['span', {class: 'GCLASS_MX_STATE_NAME'}, state.name]];
|
|
885
|
+
let items = [['span', {class: 'GCLASS_MX_STATE_NAME'}, text_node(state.name)]];
|
|
881
886
|
|
|
882
887
|
if(state.name === current) {
|
|
883
888
|
cls += ' is-current';
|
|
@@ -897,7 +902,7 @@ function build_machine(gobj, fsm)
|
|
|
897
902
|
let body_rows = fsm.rows.map(function(row) {
|
|
898
903
|
let cells = [
|
|
899
904
|
['td', {class: 'GCLASS_MX_EVENT'},
|
|
900
|
-
[['span', {}, row.event]].concat(event_flag_chips(row.flags))]
|
|
905
|
+
[['span', {}, text_node(row.event)]].concat(event_flag_chips(row.flags))]
|
|
901
906
|
];
|
|
902
907
|
row.cells.forEach(function(cell, i) {
|
|
903
908
|
let state = fsm.states[i];
|
|
@@ -914,7 +919,7 @@ function build_machine(gobj, fsm)
|
|
|
914
919
|
|
|
915
920
|
let items = [];
|
|
916
921
|
if(cell.action) {
|
|
917
|
-
items.push(['span', {class: 'GCLASS_MX_ACTION'}, cell.action]);
|
|
922
|
+
items.push(['span', {class: 'GCLASS_MX_ACTION'}, text_node(cell.action)]);
|
|
918
923
|
} else if(cell.has_action) {
|
|
919
924
|
/* The C side cannot name an action: `states2json()`
|
|
920
925
|
* writes the literal "action" for all of them. A mark
|
|
@@ -936,7 +941,7 @@ function build_machine(gobj, fsm)
|
|
|
936
941
|
}
|
|
937
942
|
if(cell.next_state) {
|
|
938
943
|
items.push(['span', {class: 'GCLASS_MX_ARROW'}, "▸"]);
|
|
939
|
-
items.push(['span', {class: 'GCLASS_MX_NEXT'}, cell.next_state]);
|
|
944
|
+
items.push(['span', {class: 'GCLASS_MX_NEXT'}, text_node(cell.next_state)]);
|
|
940
945
|
}
|
|
941
946
|
|
|
942
947
|
cells.push(['td', {class: 'GCLASS_MX_CELL' +
|
|
@@ -963,7 +968,7 @@ function build_machine(gobj, fsm)
|
|
|
963
968
|
blocks.push(['div', {class: 'GCLASS_CHIPS GCLASS_PUBLISHED'},
|
|
964
969
|
fsm.published.map(function(p) {
|
|
965
970
|
return ['span', row_attrs(p.event, {class: 'GCLASS_PUB_ROW'}), [
|
|
966
|
-
['span', {class: 'GCLASS_CHIP GCLASS_PUB_EVENT'}, p.event]
|
|
971
|
+
['span', {class: 'GCLASS_CHIP GCLASS_PUB_EVENT'}, text_node(p.event)]
|
|
967
972
|
].concat(event_flag_chips(p.flags))];
|
|
968
973
|
})]);
|
|
969
974
|
}
|
|
@@ -81,6 +81,7 @@ import {
|
|
|
81
81
|
import { ensure_drag_canvas_patch } from "./g6_drag_canvas_touch.js";
|
|
82
82
|
import { ensure_pinch_zoom_patch } from "./g6_touch_gestures.js";
|
|
83
83
|
import { yui_is_dark, yui_theme_now, yui_watch_theme } from "./yui_theme.js";
|
|
84
|
+
import {g6_event_kw} from "./g6_event_kw.js";
|
|
84
85
|
|
|
85
86
|
/***************************************************************
|
|
86
87
|
* Constants
|
|
@@ -649,6 +650,10 @@ function mt_destroy(gobj)
|
|
|
649
650
|
cancelAnimationFrame(priv._resize_raf);
|
|
650
651
|
priv._resize_raf = 0;
|
|
651
652
|
}
|
|
653
|
+
if(priv.find_timer) {
|
|
654
|
+
clearTimeout(priv.find_timer);
|
|
655
|
+
priv.find_timer = null;
|
|
656
|
+
}
|
|
652
657
|
|
|
653
658
|
if(priv.graph) {
|
|
654
659
|
priv.graph.destroy();
|
|
@@ -1177,7 +1182,9 @@ function build_graph(gobj)
|
|
|
1177
1182
|
});
|
|
1178
1183
|
|
|
1179
1184
|
graph.on(NodeEvent.CLICK, (evt) => {
|
|
1180
|
-
|
|
1185
|
+
/* An identity, never the G6 event: a kw is plain json, and the
|
|
1186
|
+
* event is circular -- the machine trace dumps the kw. */
|
|
1187
|
+
gobj_send_event(gobj, "EV_NODE_CLICK", g6_event_kw(evt), gobj);
|
|
1181
1188
|
});
|
|
1182
1189
|
|
|
1183
1190
|
graph.on(CanvasEvent.CLICK, (evt) => {
|
|
@@ -2691,7 +2698,7 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2691
2698
|
{
|
|
2692
2699
|
let priv = gobj.priv;
|
|
2693
2700
|
let graph = priv.graph;
|
|
2694
|
-
let node_id = kw.
|
|
2701
|
+
let node_id = kw.id;
|
|
2695
2702
|
|
|
2696
2703
|
/*
|
|
2697
2704
|
* Prefer our own cached node_data (richer) and fall back to
|
|
@@ -2704,7 +2711,11 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2704
2711
|
if(nd && nd.data) {
|
|
2705
2712
|
node_data = nd.data;
|
|
2706
2713
|
}
|
|
2707
|
-
} catch(e) {
|
|
2714
|
+
} catch(e) {
|
|
2715
|
+
/* G6 throws for an id it no longer holds (a click that raced
|
|
2716
|
+
* a redraw): the click lands on nothing. */
|
|
2717
|
+
log_warning(`${gobj_short_name(gobj)}: node '${node_id}' clicked, not in the graph: ${e}`);
|
|
2718
|
+
}
|
|
2708
2719
|
}
|
|
2709
2720
|
|
|
2710
2721
|
if(!node_data) {
|
|
@@ -2734,8 +2745,8 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2734
2745
|
/*
|
|
2735
2746
|
* Show popover at click position
|
|
2736
2747
|
*/
|
|
2737
|
-
let client_x =
|
|
2738
|
-
let client_y =
|
|
2748
|
+
let client_x = kw.client_x || 0;
|
|
2749
|
+
let client_y = kw.client_y || 0;
|
|
2739
2750
|
show_popover(gobj, node_data, client_x, client_y);
|
|
2740
2751
|
|
|
2741
2752
|
return 0;
|
package/src/c_yui_json.js
CHANGED
|
@@ -111,6 +111,7 @@ import {attach_clear} from "./yui_inputs.js";
|
|
|
111
111
|
import {t} from "i18next";
|
|
112
112
|
|
|
113
113
|
import "./c_yui_json.css";
|
|
114
|
+
import {text_node} from "./yui_text.js";
|
|
114
115
|
|
|
115
116
|
|
|
116
117
|
/***************************************************************
|
|
@@ -884,7 +885,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows)
|
|
|
884
885
|
|
|
885
886
|
let key_spec = (key === null || key === "")
|
|
886
887
|
? null
|
|
887
|
-
: ['span', {class: 'JSON_KEY'},
|
|
888
|
+
: ['span', {class: 'JSON_KEY'}, text_node(key)];
|
|
888
889
|
|
|
889
890
|
let stub_text = (info.is_array ? "[" : "{") +
|
|
890
891
|
(size !== undefined ? String(size) : "?") +
|
|
@@ -895,7 +896,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows)
|
|
|
895
896
|
children.push(key_spec);
|
|
896
897
|
children.push(['span', {class: 'JSON_PUNCT'}, ': ']);
|
|
897
898
|
}
|
|
898
|
-
children.push(['span', {class: 'JSON_STUB'}, stub_text]);
|
|
899
|
+
children.push(['span', {class: 'JSON_STUB'}, text_node(stub_text)]);
|
|
899
900
|
children.push(['span', {class: 'JSON_STUB_HINT is-size-7 ml-2',
|
|
900
901
|
'data-i18n': is_pending ? 'loading' : 'click to load'},
|
|
901
902
|
is_pending ? 'loading' : 'click to load']);
|
|
@@ -935,7 +936,7 @@ function toggle_row(gobj, key, size, is_object, depth, path, open, value)
|
|
|
935
936
|
|
|
936
937
|
let body = [];
|
|
937
938
|
if(key !== null && key !== "") {
|
|
938
|
-
body.push(['span', {class: 'JSON_KEY'},
|
|
939
|
+
body.push(['span', {class: 'JSON_KEY'}, text_node(key)]);
|
|
939
940
|
body.push(['span', {class: 'JSON_PUNCT'}, ': ']);
|
|
940
941
|
}
|
|
941
942
|
body.push(['span', {class: 'JSON_SUMMARY yui-text-quiet'}, summary]);
|
|
@@ -952,7 +953,7 @@ function toggle_row(gobj, key, size, is_object, depth, path, open, value)
|
|
|
952
953
|
*/
|
|
953
954
|
let label = container_label(value, MAX_LABEL_CHARS);
|
|
954
955
|
if(label) {
|
|
955
|
-
body.push(['span', {class: 'JSON_SUMMARY_ID ml-2'}, label]);
|
|
956
|
+
body.push(['span', {class: 'JSON_SUMMARY_ID ml-2'}, text_node(label)]);
|
|
956
957
|
}
|
|
957
958
|
|
|
958
959
|
return ['div', {class: 'JSON_ROW JSON_CONTAINER', style: row_indent(depth)}, [
|
|
@@ -992,10 +993,10 @@ function leaf_row(key, value, depth)
|
|
|
992
993
|
|
|
993
994
|
let body = [];
|
|
994
995
|
if(key !== null && key !== "") {
|
|
995
|
-
body.push(['span', {class: 'JSON_KEY'},
|
|
996
|
+
body.push(['span', {class: 'JSON_KEY'}, text_node(key)]);
|
|
996
997
|
body.push(['span', {class: 'JSON_PUNCT'}, ': ']);
|
|
997
998
|
}
|
|
998
|
-
body.push(['span', {class: 'JSON_VALUE JSON_TYPE_' + type.toUpperCase()}, text]);
|
|
999
|
+
body.push(['span', {class: 'JSON_VALUE JSON_TYPE_' + type.toUpperCase()}, text_node(text)]);
|
|
999
1000
|
|
|
1000
1001
|
if(key !== null && is_time_field(String(key))) {
|
|
1001
1002
|
let wall = format_epoch(value);
|
package/src/c_yui_json_graph.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Displays JSON data as a hierarchical graph visualization
|
|
6
6
|
* Migrated from mx_json_viewer.js (mxGraph)
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2025, ArtGins.
|
|
8
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
9
9
|
* All Rights Reserved.
|
|
10
10
|
***********************************************************************/
|
|
11
11
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
gclass_create,
|
|
18
18
|
gclass_find_by_name,
|
|
19
19
|
log_error,
|
|
20
|
+
log_warning,
|
|
20
21
|
gobj_read_pointer_attr,
|
|
21
22
|
gobj_parent,
|
|
22
23
|
gobj_subscribe_event,
|
|
@@ -81,6 +82,7 @@ import {
|
|
|
81
82
|
has_branch,
|
|
82
83
|
count_branches,
|
|
83
84
|
} from "./json_view_helpers.js";
|
|
85
|
+
import {g6_event_kw} from "./g6_event_kw.js";
|
|
84
86
|
|
|
85
87
|
/***************************************************************
|
|
86
88
|
* Constants
|
|
@@ -753,7 +755,9 @@ function build_graph(gobj)
|
|
|
753
755
|
}
|
|
754
756
|
|
|
755
757
|
graph.on(NodeEvent.CLICK, (evt) => {
|
|
756
|
-
|
|
758
|
+
/* An identity, never the G6 event: a kw is plain json, and the
|
|
759
|
+
* event is circular -- the machine trace dumps the kw. */
|
|
760
|
+
gobj_send_event(gobj, "EV_NODE_CLICK", g6_event_kw(evt), gobj);
|
|
757
761
|
});
|
|
758
762
|
|
|
759
763
|
/* ONE hook for the readout, the same one the treedb graph uses:
|
|
@@ -1071,12 +1075,24 @@ function cell_matches(key, value, type, needle)
|
|
|
1071
1075
|
************************************************************/
|
|
1072
1076
|
function get_json_type(value)
|
|
1073
1077
|
{
|
|
1074
|
-
if(is_string(value))
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
if(
|
|
1078
|
-
|
|
1079
|
-
|
|
1078
|
+
if(is_string(value)) {
|
|
1079
|
+
return "string";
|
|
1080
|
+
}
|
|
1081
|
+
if(is_null(value)) {
|
|
1082
|
+
return "null";
|
|
1083
|
+
}
|
|
1084
|
+
if(is_number(value)) {
|
|
1085
|
+
return "number";
|
|
1086
|
+
}
|
|
1087
|
+
if(is_boolean(value)) {
|
|
1088
|
+
return "boolean";
|
|
1089
|
+
}
|
|
1090
|
+
if(is_object(value)) {
|
|
1091
|
+
return "dict";
|
|
1092
|
+
}
|
|
1093
|
+
if(is_array(value)) {
|
|
1094
|
+
return "list";
|
|
1095
|
+
}
|
|
1080
1096
|
return "unknown";
|
|
1081
1097
|
}
|
|
1082
1098
|
|
|
@@ -1787,7 +1803,9 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1787
1803
|
}
|
|
1788
1804
|
let total = 0;
|
|
1789
1805
|
for(let i = 0; i < kids.length; i++) {
|
|
1790
|
-
if(i > 0)
|
|
1806
|
+
if(i > 0) {
|
|
1807
|
+
total += H_GAP;
|
|
1808
|
+
}
|
|
1791
1809
|
total += calc_subtree_width(kids[i]);
|
|
1792
1810
|
}
|
|
1793
1811
|
subtree_widths[node_id] = Math.max(total, node_dims[node_id].w);
|
|
@@ -1818,11 +1836,15 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1818
1836
|
positions[node_id] = {x, y};
|
|
1819
1837
|
|
|
1820
1838
|
let kids = children_map[node_id] || [];
|
|
1821
|
-
if(kids.length === 0)
|
|
1839
|
+
if(kids.length === 0) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1822
1842
|
|
|
1823
1843
|
let total_width = 0;
|
|
1824
1844
|
for(let i = 0; i < kids.length; i++) {
|
|
1825
|
-
if(i > 0)
|
|
1845
|
+
if(i > 0) {
|
|
1846
|
+
total_width += H_GAP;
|
|
1847
|
+
}
|
|
1826
1848
|
total_width += subtree_widths[kids[i]];
|
|
1827
1849
|
}
|
|
1828
1850
|
|
|
@@ -1842,7 +1864,9 @@ class JsonTreeLayout extends BaseLayout {
|
|
|
1842
1864
|
*/
|
|
1843
1865
|
let total_root_width = 0;
|
|
1844
1866
|
for(let i = 0; i < roots.length; i++) {
|
|
1845
|
-
if(i > 0)
|
|
1867
|
+
if(i > 0) {
|
|
1868
|
+
total_root_width += H_GAP;
|
|
1869
|
+
}
|
|
1846
1870
|
total_root_width += subtree_widths[roots[i].id];
|
|
1847
1871
|
}
|
|
1848
1872
|
|
|
@@ -2323,12 +2347,16 @@ function ac_node_click(gobj, event, kw, src)
|
|
|
2323
2347
|
{
|
|
2324
2348
|
let priv = gobj.priv;
|
|
2325
2349
|
let graph = priv.graph;
|
|
2326
|
-
let node_id = kw.
|
|
2350
|
+
let node_id = kw.id;
|
|
2327
2351
|
|
|
2328
2352
|
let nodedata;
|
|
2329
2353
|
try {
|
|
2330
2354
|
nodedata = graph.getNodeData(node_id);
|
|
2331
|
-
} catch(e) {
|
|
2355
|
+
} catch(e) {
|
|
2356
|
+
/* G6 throws for an id it no longer holds (a click that raced a
|
|
2357
|
+
* redraw): the click lands on nothing. */
|
|
2358
|
+
log_warning(`${gobj_short_name(gobj)}: node '${node_id}' clicked, not in the graph: ${e}`);
|
|
2359
|
+
}
|
|
2332
2360
|
|
|
2333
2361
|
/*
|
|
2334
2362
|
* A waiting anchor TAKES the click: it is what the reader armed
|
package/src/c_yui_json_pad.js
CHANGED
|
@@ -110,6 +110,7 @@ import {json_diff_rows} from "./json_view_helpers.js";
|
|
|
110
110
|
import {t} from "i18next";
|
|
111
111
|
|
|
112
112
|
import "./c_yui_json_pad.css";
|
|
113
|
+
import {text_node} from "./yui_text.js";
|
|
113
114
|
|
|
114
115
|
/***************************************************************
|
|
115
116
|
* Constants
|
|
@@ -605,7 +606,7 @@ function render_diff(gobj)
|
|
|
605
606
|
['tbody', {}, rows.map((row) => {
|
|
606
607
|
return ['tr', {class: `JSON_PAD_DIFF_ROW JSON_PAD_DIFF_${row.kind.toUpperCase()}`}, [
|
|
607
608
|
['td', {}, [KIND_TAG[row.kind]()]],
|
|
608
|
-
['td', {class: 'JSON_PAD_DIFF_PATH'}, row.id],
|
|
609
|
+
['td', {class: 'JSON_PAD_DIFF_PATH'}, text_node(row.id)],
|
|
609
610
|
value_cell('JSON_PAD_DIFF_FROM', row, 'from'),
|
|
610
611
|
value_cell('JSON_PAD_DIFF_TO', row, 'to')
|
|
611
612
|
]];
|
package/src/c_yui_map.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Map Manager
|
|
5
5
|
*
|
|
6
|
-
* Copyright (c) 2025, ArtGins.
|
|
6
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
7
7
|
* All Rights Reserved.
|
|
8
8
|
***********************************************************************/
|
|
9
9
|
import {
|
|
@@ -30,6 +30,11 @@ import {
|
|
|
30
30
|
gobj_start,
|
|
31
31
|
gobj_name,
|
|
32
32
|
gobj_unsubscribe_event,
|
|
33
|
+
gobj_stop_children,
|
|
34
|
+
gobj_match_children,
|
|
35
|
+
gobj_is_running,
|
|
36
|
+
gobj_stop,
|
|
37
|
+
gobj_destroy,
|
|
33
38
|
} from "@yuneta/gobj-js";
|
|
34
39
|
|
|
35
40
|
import "maplibre-gl/dist/maplibre-gl.css"; // Import MapLibre styles
|
|
@@ -308,9 +313,31 @@ function mt_stop(gobj)
|
|
|
308
313
|
if(shell) {
|
|
309
314
|
gobj_unsubscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
310
315
|
}
|
|
316
|
+
/* The marker windows are children of the map, and they go with it:
|
|
317
|
+
* a C_YUI_WINDOW has no mt_stop, so stopping one leaves it on screen
|
|
318
|
+
* holding its service name. They are destroyed here, not in
|
|
319
|
+
* mt_destroy (gobj_destroy() destroys the children BEFORE calling
|
|
320
|
+
* mt_destroy). */
|
|
321
|
+
retire_marker_windows(gobj);
|
|
322
|
+
gobj_stop_children(gobj);
|
|
311
323
|
return 0;
|
|
312
324
|
}
|
|
313
325
|
|
|
326
|
+
/***************************************************************
|
|
327
|
+
* Destroy the windows the markers opened.
|
|
328
|
+
***************************************************************/
|
|
329
|
+
function retire_marker_windows(gobj)
|
|
330
|
+
{
|
|
331
|
+
let windows = gobj_match_children(gobj, {__gclass_name__: "C_YUI_WINDOW"}) || [];
|
|
332
|
+
for(let win of windows) {
|
|
333
|
+
if(gobj_is_running(win)) {
|
|
334
|
+
gobj_stop(win);
|
|
335
|
+
}
|
|
336
|
+
gobj_stop_children(win);
|
|
337
|
+
gobj_destroy(win);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
314
341
|
/***************************************************************
|
|
315
342
|
* Framework Method: Destroy
|
|
316
343
|
***************************************************************/
|
|
@@ -710,84 +737,25 @@ function find_device(gobj, id)
|
|
|
710
737
|
}
|
|
711
738
|
|
|
712
739
|
/************************************************************
|
|
713
|
-
* Event handler for click
|
|
740
|
+
* Event handler for click: maplibre's callback only turns the
|
|
741
|
+
* click into an event; the work is ac_marker_clicked().
|
|
742
|
+
* Plain json: the marker's identity and where it is.
|
|
714
743
|
************************************************************/
|
|
715
744
|
function onClick(gobj, e)
|
|
716
745
|
{
|
|
717
|
-
let
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
// Get feature properties and coordinates
|
|
722
|
-
const coordinates = e.features[0].geometry.coordinates.slice();
|
|
723
|
-
const properties = e.features[0].properties;
|
|
724
|
-
|
|
725
|
-
/* A marker may or may not be backed by a gobj service. Only look it up
|
|
726
|
-
* when the feature carries a name (verbose=false: a marker without a
|
|
727
|
-
* service is a normal case handled by the popup branch below, not an
|
|
728
|
-
* error). gobj_find_service() would otherwise crash on undefined. */
|
|
729
|
-
const gobj_service = properties.gobj_service_name
|
|
730
|
-
? gobj_find_service(properties.gobj_service_name, false)
|
|
731
|
-
: null;
|
|
732
|
-
if(gobj_service) {
|
|
733
|
-
let name = clean_name(gobj_name(gobj_service));
|
|
734
|
-
let window_service_name = `window-map-${name}`;
|
|
735
|
-
|
|
736
|
-
let popupContent = createElement2(
|
|
737
|
-
['div',
|
|
738
|
-
{
|
|
739
|
-
class: 'xmap columns m-0 p-0 is-flex-wrap-wrap',
|
|
740
|
-
},
|
|
741
|
-
gobj_read_attr(gobj_service, "$container")
|
|
742
|
-
]
|
|
743
|
-
);
|
|
744
|
-
|
|
745
|
-
let gobj_window = gobj_create_service(
|
|
746
|
-
window_service_name,
|
|
747
|
-
"C_YUI_WINDOW",
|
|
748
|
-
{
|
|
749
|
-
$parent: document.getElementById('top-layer'),
|
|
750
|
-
width: 700,
|
|
751
|
-
height: 500,
|
|
752
|
-
auto_save_size_and_position: false,
|
|
753
|
-
center: true,
|
|
754
|
-
showMax: false,
|
|
755
|
-
content_size: true,
|
|
756
|
-
/* The marker's own name: this window is one marker's
|
|
757
|
-
* detail, and several can be open at once, so the bar
|
|
758
|
-
* must say WHICH. It is DATA, so it travels in
|
|
759
|
-
* title_prefix (never translated) — in `title` it
|
|
760
|
-
* would get a data-i18n and a marker named like a
|
|
761
|
-
* locale key ("status") would render translated. */
|
|
762
|
-
title_prefix: gobj_name(gobj_service),
|
|
763
|
-
title: "",
|
|
764
|
-
icon: "yi-location-dot",
|
|
765
|
-
logical_class: "MAP_MARKER_WINDOW",
|
|
766
|
-
body: popupContent
|
|
767
|
-
},
|
|
768
|
-
gobj
|
|
769
|
-
);
|
|
770
|
-
if(!gobj_window) {
|
|
771
|
-
log_error(`${gobj_name(gobj)}: cannot create the marker window`);
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
gobj_start(gobj_window);
|
|
775
|
-
|
|
776
|
-
} else {
|
|
777
|
-
// Initialize a popup
|
|
778
|
-
const popup = new maplibregl.Popup({
|
|
779
|
-
closeButton: true,
|
|
780
|
-
closeOnClick: true, // Automatically close when clicking elsewhere
|
|
781
|
-
closeOnMove: true,
|
|
782
|
-
anchor: 'center',
|
|
783
|
-
maxWidth: 'none',
|
|
784
|
-
});
|
|
785
|
-
|
|
786
|
-
const popupContent = `
|
|
787
|
-
<b>${properties.name}</b><br>Id: ${properties.id}
|
|
788
|
-
`;
|
|
789
|
-
popup.setLngLat(coordinates).setHTML(popupContent).addTo(map);
|
|
746
|
+
let feature = e && e.features && e.features[0];
|
|
747
|
+
if(!feature) {
|
|
748
|
+
log_error(`${gobj_name(gobj)}: marker click with no feature`);
|
|
749
|
+
return;
|
|
790
750
|
}
|
|
751
|
+
let properties = feature.properties || {};
|
|
752
|
+
let coordinates = feature.geometry.coordinates.slice();
|
|
753
|
+
gobj_send_event(gobj, "EV_MARKER_CLICKED", {
|
|
754
|
+
gobj_service_name: properties.gobj_service_name || "",
|
|
755
|
+
name: (properties.name !== undefined)? String(properties.name) : "",
|
|
756
|
+
id: (properties.id !== undefined)? String(properties.id) : "",
|
|
757
|
+
coordinates: coordinates
|
|
758
|
+
}, gobj);
|
|
791
759
|
}
|
|
792
760
|
|
|
793
761
|
/************************************************************
|
|
@@ -983,6 +951,100 @@ function ac_refresh(gobj, event, kw, src)
|
|
|
983
951
|
return 0;
|
|
984
952
|
}
|
|
985
953
|
|
|
954
|
+
/************************************************************
|
|
955
|
+
* EV_MARKER_CLICKED {gobj_service_name, name, id, coordinates}
|
|
956
|
+
*
|
|
957
|
+
* A marker backed by a gobj service opens that service's view in
|
|
958
|
+
* a window -- ONE per marker: a second click is told to the open
|
|
959
|
+
* one (EV_SHOW). (It created a second window under the same service
|
|
960
|
+
* name, moved the one $container into it and left the first one
|
|
961
|
+
* empty; closing the first then unregistered the second's name.)
|
|
962
|
+
* A marker without a service gets a popup with its name and id.
|
|
963
|
+
************************************************************/
|
|
964
|
+
function ac_marker_clicked(gobj, event, kw, src)
|
|
965
|
+
{
|
|
966
|
+
let priv = gobj.priv;
|
|
967
|
+
const map = priv.xmap;
|
|
968
|
+
|
|
969
|
+
/* A marker may or may not be backed by a gobj service. Only look it up
|
|
970
|
+
* when the feature carries a name (verbose=false: a marker without a
|
|
971
|
+
* service is a normal case handled by the popup branch below, not an
|
|
972
|
+
* error). gobj_find_service() would otherwise crash on undefined. */
|
|
973
|
+
const gobj_service = kw.gobj_service_name
|
|
974
|
+
? gobj_find_service(kw.gobj_service_name, false)
|
|
975
|
+
: null;
|
|
976
|
+
|
|
977
|
+
if(gobj_service) {
|
|
978
|
+
let name = clean_name(gobj_name(gobj_service));
|
|
979
|
+
let window_service_name = `window-map-${name}`;
|
|
980
|
+
|
|
981
|
+
let gobj_window = gobj_find_service(window_service_name, false);
|
|
982
|
+
if(gobj_window) {
|
|
983
|
+
gobj_send_event(gobj_window, "EV_SHOW", {}, gobj);
|
|
984
|
+
return 0;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
let popupContent = createElement2(
|
|
988
|
+
['div',
|
|
989
|
+
{
|
|
990
|
+
class: 'xmap columns m-0 p-0 is-flex-wrap-wrap',
|
|
991
|
+
},
|
|
992
|
+
gobj_read_attr(gobj_service, "$container")
|
|
993
|
+
]
|
|
994
|
+
);
|
|
995
|
+
|
|
996
|
+
gobj_window = gobj_create_service(
|
|
997
|
+
window_service_name,
|
|
998
|
+
"C_YUI_WINDOW",
|
|
999
|
+
{
|
|
1000
|
+
$parent: document.getElementById('top-layer'),
|
|
1001
|
+
width: 700,
|
|
1002
|
+
height: 500,
|
|
1003
|
+
auto_save_size_and_position: false,
|
|
1004
|
+
center: true,
|
|
1005
|
+
showMax: false,
|
|
1006
|
+
content_size: true,
|
|
1007
|
+
/* The marker's own name: this window is one marker's
|
|
1008
|
+
* detail, and several can be open at once, so the bar
|
|
1009
|
+
* must say WHICH. It is DATA, so it travels in
|
|
1010
|
+
* title_prefix (never translated) — in `title` it
|
|
1011
|
+
* would get a data-i18n and a marker named like a
|
|
1012
|
+
* locale key ("status") would render translated. */
|
|
1013
|
+
title_prefix: gobj_name(gobj_service),
|
|
1014
|
+
title: "",
|
|
1015
|
+
icon: "yi-location-dot",
|
|
1016
|
+
logical_class: "MAP_MARKER_WINDOW",
|
|
1017
|
+
body: popupContent
|
|
1018
|
+
},
|
|
1019
|
+
gobj
|
|
1020
|
+
);
|
|
1021
|
+
if(!gobj_window) {
|
|
1022
|
+
log_error(`${gobj_name(gobj)}: cannot create the marker window`);
|
|
1023
|
+
return -1;
|
|
1024
|
+
}
|
|
1025
|
+
gobj_start(gobj_window);
|
|
1026
|
+
return 0;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
const popup = new maplibregl.Popup({
|
|
1030
|
+
closeButton: true,
|
|
1031
|
+
closeOnClick: true, // Automatically close when clicking elsewhere
|
|
1032
|
+
closeOnMove: true,
|
|
1033
|
+
anchor: 'center',
|
|
1034
|
+
maxWidth: 'none',
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
/* Built as nodes, never as markup: the name and the id are data. */
|
|
1038
|
+
let $content = document.createElement('div');
|
|
1039
|
+
let $name = document.createElement('b');
|
|
1040
|
+
$name.textContent = kw.name;
|
|
1041
|
+
$content.appendChild($name);
|
|
1042
|
+
$content.appendChild(document.createElement('br'));
|
|
1043
|
+
$content.appendChild(document.createTextNode(`Id: ${kw.id}`));
|
|
1044
|
+
popup.setLngLat(kw.coordinates).setDOMContent($content).addTo(map);
|
|
1045
|
+
return 0;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
986
1048
|
/************************************************************
|
|
987
1049
|
*
|
|
988
1050
|
************************************************************/
|
|
@@ -1056,6 +1118,7 @@ function create_gclass(gclass_name)
|
|
|
1056
1118
|
["EV_MAP_ON_LOAD", ac_map_on_load, null],
|
|
1057
1119
|
["EV_REFRESH", ac_refresh, null],
|
|
1058
1120
|
["EV_SELECT", ac_select, null],
|
|
1121
|
+
["EV_MARKER_CLICKED", ac_marker_clicked, null],
|
|
1059
1122
|
["EV_SHOW", ac_show, null],
|
|
1060
1123
|
["EV_HIDE", ac_hide, null]
|
|
1061
1124
|
]]
|
|
@@ -1071,6 +1134,7 @@ function create_gclass(gclass_name)
|
|
|
1071
1134
|
["EV_MAP_ON_LOAD", 0],
|
|
1072
1135
|
["EV_REFRESH", 0],
|
|
1073
1136
|
["EV_SELECT", 0],
|
|
1137
|
+
["EV_MARKER_CLICKED", 0],
|
|
1074
1138
|
["EV_SHOW", 0],
|
|
1075
1139
|
["EV_HIDE", 0]
|
|
1076
1140
|
];
|