@yuneta/gobj-ui 7.26.10 → 7.26.11
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 +21 -7
- package/dist/gobj-ui.cjs.js +104 -59
- package/dist/gobj-ui.es.js +104 -59
- package/package.json +3 -2
- package/scripts/check-markup-strings.mjs +278 -0
- package/src/c_g6_nodes_tree.js +9 -3
- package/src/c_yui_form.js +2 -1
- package/src/c_yui_gclass.js +3 -3
- package/src/c_yui_json.js +1 -1
- package/src/c_yui_schema_editor.js +2 -2
- package/src/c_yui_shell.js +43 -2
- package/src/c_yui_treedb_topic_with_form.js +8 -4
- package/src/c_yui_window.js +2 -1
- package/src/c_yui_window_manager.js +14 -4
- package/src/overlay_marker_after_back.wiring.test.js +79 -0
- package/src/window_show.wiring.test.js +48 -0
- package/src/yui_text.js +16 -0
- package/src/yui_text.test.js +13 -1
package/dist/gobj-ui.es.js
CHANGED
|
@@ -466,6 +466,59 @@ function resolve_route(item_index, route) {
|
|
|
466
466
|
};
|
|
467
467
|
}
|
|
468
468
|
//#endregion
|
|
469
|
+
//#region src/yui_text.js
|
|
470
|
+
/***********************************************************************
|
|
471
|
+
* yui_text.js
|
|
472
|
+
*
|
|
473
|
+
* DATA as text for createElement2().
|
|
474
|
+
*
|
|
475
|
+
* createElement2() takes a string content that starts with '<' for
|
|
476
|
+
* MARKUP and parses it (that is how a component passes an inline
|
|
477
|
+
* icon). So a value that came from outside -- a backend answer, a
|
|
478
|
+
* treedb node, a name somebody typed, a frame of the traffic -- must
|
|
479
|
+
* never go in as a bare string: "<img src=x onerror=...>" would run.
|
|
480
|
+
* It goes in as a Text node, which is always text.
|
|
481
|
+
*
|
|
482
|
+
* Trimmed like createElement2() trims a string, so the change of
|
|
483
|
+
* form does not change what is shown. A Text node under an
|
|
484
|
+
* `i18n`/`data-i18n` element is still re-translated by
|
|
485
|
+
* refresh_language(), which sets textContent.
|
|
486
|
+
*
|
|
487
|
+
* Copyright (c) 2026, ArtGins.
|
|
488
|
+
* All Rights Reserved.
|
|
489
|
+
***********************************************************************/
|
|
490
|
+
/************************************************************
|
|
491
|
+
* A Text node with `value` as its text ("" for null/undefined).
|
|
492
|
+
************************************************************/
|
|
493
|
+
function text_node(value) {
|
|
494
|
+
if (value === null || value === void 0) return document.createTextNode("");
|
|
495
|
+
return document.createTextNode(String(value).trim());
|
|
496
|
+
}
|
|
497
|
+
/************************************************************
|
|
498
|
+
* A Tabulator `titleFormatter` that shows the column title as text.
|
|
499
|
+
*
|
|
500
|
+
* Tabulator puts a STRING title in with innerHTML, so a title taken
|
|
501
|
+
* from a schema (`header`, which the schema editor writes) is markup
|
|
502
|
+
* unless the column carries a formatter that returns a Node.
|
|
503
|
+
************************************************************/
|
|
504
|
+
function text_title_formatter(cell) {
|
|
505
|
+
return text_node(cell.getValue());
|
|
506
|
+
}
|
|
507
|
+
/************************************************************
|
|
508
|
+
* A Tabulator `itemFormatter` for a `list` editor or header filter
|
|
509
|
+
* that shows each item's label as text.
|
|
510
|
+
*
|
|
511
|
+
* Tabulator appends what an itemFormatter returns only when it is an
|
|
512
|
+
* HTMLElement (a Text node would be innerHTML'd as "[object Text]"),
|
|
513
|
+
* and it puts a bare label in with innerHTML. A label taken from a
|
|
514
|
+
* schema (`enum_list`) is data, so it goes in a span, as text.
|
|
515
|
+
************************************************************/
|
|
516
|
+
function text_list_item_formatter(label) {
|
|
517
|
+
const span = document.createElement("span");
|
|
518
|
+
span.textContent = label === null || label === void 0 ? "" : String(label);
|
|
519
|
+
return span;
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
469
522
|
//#region src/route_map_model.js
|
|
470
523
|
/***********************************************************************
|
|
471
524
|
* route_map_model.js
|
|
@@ -914,6 +967,7 @@ var PRIVATE_DATA$22 = {
|
|
|
914
967
|
overlay_stack: [],
|
|
915
968
|
overlay_seq: 0,
|
|
916
969
|
expected_pops: 0,
|
|
970
|
+
expected_pop_hash: "",
|
|
917
971
|
pending_markers: [],
|
|
918
972
|
popstate_handler: null,
|
|
919
973
|
avatar_provider: null,
|
|
@@ -963,6 +1017,8 @@ function mt_start$20(gobj) {
|
|
|
963
1017
|
preinstantiate_eager_views(gobj);
|
|
964
1018
|
if (gobj_read_attr(gobj, "use_hash")) {
|
|
965
1019
|
priv.hash_handler = () => {
|
|
1020
|
+
let p = gobj.priv;
|
|
1021
|
+
if (p && p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) drop_expected_pops(gobj);
|
|
966
1022
|
let route = hash_to_route(window.location.hash);
|
|
967
1023
|
if (!empty_string(route)) navigate_to(gobj, route);
|
|
968
1024
|
};
|
|
@@ -970,6 +1026,7 @@ function mt_start$20(gobj) {
|
|
|
970
1026
|
priv.popstate_handler = (ev) => {
|
|
971
1027
|
let p = gobj.priv;
|
|
972
1028
|
if (!p) return;
|
|
1029
|
+
if (p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) drop_expected_pops(gobj);
|
|
973
1030
|
if (p.expected_pops > 0) {
|
|
974
1031
|
p.expected_pops--;
|
|
975
1032
|
if (p.expected_pops === 0) push_pending_markers(gobj);
|
|
@@ -1021,6 +1078,9 @@ function mt_stop$20(gobj) {
|
|
|
1021
1078
|
window.removeEventListener("popstate", priv.popstate_handler);
|
|
1022
1079
|
priv.popstate_handler = null;
|
|
1023
1080
|
}
|
|
1081
|
+
priv.expected_pops = 0;
|
|
1082
|
+
priv.expected_pop_hash = "";
|
|
1083
|
+
priv.pending_markers = [];
|
|
1024
1084
|
if (priv.keydown_handler) {
|
|
1025
1085
|
window.removeEventListener("keydown", priv.keydown_handler);
|
|
1026
1086
|
priv.keydown_handler = null;
|
|
@@ -1824,7 +1884,7 @@ function build_toolbar_action_item(gobj, it) {
|
|
|
1824
1884
|
class: "yui-toolbar-item-label",
|
|
1825
1885
|
i18n: it.name
|
|
1826
1886
|
},
|
|
1827
|
-
it.name
|
|
1887
|
+
text_node(it.name)
|
|
1828
1888
|
]);
|
|
1829
1889
|
let aria_key = it.aria_label || it.name || it.id || "";
|
|
1830
1890
|
let i18n_aria = it.aria_label || it.name;
|
|
@@ -2240,7 +2300,7 @@ function build_dropdown_row(gobj, sub, idx) {
|
|
|
2240
2300
|
class: "yui-toolbar-dropdown-label",
|
|
2241
2301
|
i18n: sub.name
|
|
2242
2302
|
},
|
|
2243
|
-
sub.name
|
|
2303
|
+
text_node(sub.name)
|
|
2244
2304
|
]);
|
|
2245
2305
|
children.push([
|
|
2246
2306
|
"span",
|
|
@@ -2438,6 +2498,14 @@ function push_overlay_marker(gobj, entry) {
|
|
|
2438
2498
|
}
|
|
2439
2499
|
return true;
|
|
2440
2500
|
}
|
|
2501
|
+
function drop_expected_pops(gobj) {
|
|
2502
|
+
let priv = gobj.priv;
|
|
2503
|
+
if (!priv || priv.expected_pops === 0) return;
|
|
2504
|
+
log_warning(`C_YUI_SHELL: ${priv.expected_pops} history.back() of ours did not land on '${priv.expected_pop_hash}' (now '${window.location.hash}'), dropped`);
|
|
2505
|
+
priv.expected_pops = 0;
|
|
2506
|
+
priv.expected_pop_hash = "";
|
|
2507
|
+
push_pending_markers(gobj);
|
|
2508
|
+
}
|
|
2441
2509
|
function push_pending_markers(gobj) {
|
|
2442
2510
|
let priv = gobj.priv;
|
|
2443
2511
|
let pending = priv.pending_markers.splice(0);
|
|
@@ -2459,6 +2527,7 @@ function overlay_dismissed(gobj, entry) {
|
|
|
2459
2527
|
let st = window.history.state;
|
|
2460
2528
|
if (st && st.__yui_overlay__ === entry.id) {
|
|
2461
2529
|
priv.expected_pops++;
|
|
2530
|
+
priv.expected_pop_hash = window.location.hash;
|
|
2462
2531
|
try {
|
|
2463
2532
|
window.history.back();
|
|
2464
2533
|
} catch (e) {
|
|
@@ -3051,45 +3120,6 @@ function yui_shell_close_dropdown(shell_gobj) {
|
|
|
3051
3120
|
close_toolbar_dropdown(shell_gobj);
|
|
3052
3121
|
}
|
|
3053
3122
|
//#endregion
|
|
3054
|
-
//#region src/yui_text.js
|
|
3055
|
-
/***********************************************************************
|
|
3056
|
-
* yui_text.js
|
|
3057
|
-
*
|
|
3058
|
-
* DATA as text for createElement2().
|
|
3059
|
-
*
|
|
3060
|
-
* createElement2() takes a string content that starts with '<' for
|
|
3061
|
-
* MARKUP and parses it (that is how a component passes an inline
|
|
3062
|
-
* icon). So a value that came from outside -- a backend answer, a
|
|
3063
|
-
* treedb node, a name somebody typed, a frame of the traffic -- must
|
|
3064
|
-
* never go in as a bare string: "<img src=x onerror=...>" would run.
|
|
3065
|
-
* It goes in as a Text node, which is always text.
|
|
3066
|
-
*
|
|
3067
|
-
* Trimmed like createElement2() trims a string, so the change of
|
|
3068
|
-
* form does not change what is shown. A Text node under an
|
|
3069
|
-
* `i18n`/`data-i18n` element is still re-translated by
|
|
3070
|
-
* refresh_language(), which sets textContent.
|
|
3071
|
-
*
|
|
3072
|
-
* Copyright (c) 2026, ArtGins.
|
|
3073
|
-
* All Rights Reserved.
|
|
3074
|
-
***********************************************************************/
|
|
3075
|
-
/************************************************************
|
|
3076
|
-
* A Text node with `value` as its text ("" for null/undefined).
|
|
3077
|
-
************************************************************/
|
|
3078
|
-
function text_node(value) {
|
|
3079
|
-
if (value === null || value === void 0) return document.createTextNode("");
|
|
3080
|
-
return document.createTextNode(String(value).trim());
|
|
3081
|
-
}
|
|
3082
|
-
/************************************************************
|
|
3083
|
-
* A Tabulator `titleFormatter` that shows the column title as text.
|
|
3084
|
-
*
|
|
3085
|
-
* Tabulator puts a STRING title in with innerHTML, so a title taken
|
|
3086
|
-
* from a schema (`header`, which the schema editor writes) is markup
|
|
3087
|
-
* unless the column carries a formatter that returns a Node.
|
|
3088
|
-
************************************************************/
|
|
3089
|
-
function text_title_formatter(cell) {
|
|
3090
|
-
return text_node(cell.getValue());
|
|
3091
|
-
}
|
|
3092
|
-
//#endregion
|
|
3093
3123
|
//#region src/shell_modals.js
|
|
3094
3124
|
/***********************************************************************
|
|
3095
3125
|
* shell_modals.js
|
|
@@ -3855,7 +3885,7 @@ function build_default_header(gobj) {
|
|
|
3855
3885
|
if (icon.charAt(0) === "<") items.push([
|
|
3856
3886
|
"span",
|
|
3857
3887
|
{ class: "icon" },
|
|
3858
|
-
icon
|
|
3888
|
+
html_markup(icon)
|
|
3859
3889
|
]);
|
|
3860
3890
|
else items.push([
|
|
3861
3891
|
"span",
|
|
@@ -4860,7 +4890,7 @@ function chip_lead(icon) {
|
|
|
4860
4890
|
if (icon.charAt(0) === "<") return [
|
|
4861
4891
|
"span",
|
|
4862
4892
|
{ class: "yui-dock-icon" },
|
|
4863
|
-
icon
|
|
4893
|
+
html_markup(icon)
|
|
4864
4894
|
];
|
|
4865
4895
|
return [
|
|
4866
4896
|
"span",
|
|
@@ -4869,9 +4899,6 @@ function chip_lead(icon) {
|
|
|
4869
4899
|
];
|
|
4870
4900
|
}
|
|
4871
4901
|
/************************************************************
|
|
4872
|
-
* Find a registry entry by its window gobj.
|
|
4873
|
-
************************************************************/
|
|
4874
|
-
/************************************************************
|
|
4875
4902
|
* The window an event is about. A kw is plain json (the machine
|
|
4876
4903
|
* trace dumps it), so the window travels in it as its FULL NAME,
|
|
4877
4904
|
* which the trace can print, and the gobj is the event's src --
|
|
@@ -4886,6 +4913,10 @@ function window_of(gobj, event, kw, src) {
|
|
|
4886
4913
|
warned_gobj_in_kw = true;
|
|
4887
4914
|
log_warning(`${gobj_short_name(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
|
|
4888
4915
|
}
|
|
4916
|
+
if (w !== src) {
|
|
4917
|
+
log_error(`${gobj_short_name(gobj)}: ${event}: window '${gobj_full_name(w)}' is not the src of the event (${is_gobj(src) ? gobj_full_name(src) : String(src)})`);
|
|
4918
|
+
return null;
|
|
4919
|
+
}
|
|
4889
4920
|
return w;
|
|
4890
4921
|
}
|
|
4891
4922
|
if (!is_gobj(src) || gobj_full_name(src) !== w) {
|
|
@@ -4894,6 +4925,9 @@ function window_of(gobj, event, kw, src) {
|
|
|
4894
4925
|
}
|
|
4895
4926
|
return src;
|
|
4896
4927
|
}
|
|
4928
|
+
/************************************************************
|
|
4929
|
+
* Find a registry entry by its window gobj.
|
|
4930
|
+
************************************************************/
|
|
4897
4931
|
function find_entry(priv, win) {
|
|
4898
4932
|
for (let e of priv.windows) if (e.gobj === win) return e;
|
|
4899
4933
|
return null;
|
|
@@ -10049,7 +10083,7 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
10049
10083
|
break;
|
|
10050
10084
|
case "enum":
|
|
10051
10085
|
column.editor = "list";
|
|
10052
|
-
column.editorParams = {};
|
|
10086
|
+
column.editorParams = { itemFormatter: text_list_item_formatter };
|
|
10053
10087
|
switch (field_desc.real_type) {
|
|
10054
10088
|
case "string":
|
|
10055
10089
|
case "object":
|
|
@@ -15950,7 +15984,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows) {
|
|
|
15950
15984
|
else if (err) children.push([
|
|
15951
15985
|
"span",
|
|
15952
15986
|
{ class: "JSON_STUB_ERR has-text-danger is-size-7 ml-2" },
|
|
15953
|
-
|
|
15987
|
+
text_node(err.error)
|
|
15954
15988
|
]);
|
|
15955
15989
|
let attrs = {
|
|
15956
15990
|
class: "JSON_ROW JSON_COLLAPSED" + (is_pending ? " is-pending" : ""),
|
|
@@ -18935,7 +18969,7 @@ function render_raw(gobj) {
|
|
|
18935
18969
|
if (dump.error) children.push([
|
|
18936
18970
|
"div",
|
|
18937
18971
|
{ class: "GCLASS_RAW_ERROR has-text-danger is-size-7 p-2" },
|
|
18938
|
-
dump.error
|
|
18972
|
+
text_node(dump.error)
|
|
18939
18973
|
]);
|
|
18940
18974
|
let $body = createElement2([
|
|
18941
18975
|
"div",
|
|
@@ -19392,7 +19426,7 @@ function build_methods(model) {
|
|
|
19392
19426
|
model.methods.map((m) => [
|
|
19393
19427
|
"span",
|
|
19394
19428
|
row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
|
|
19395
|
-
m
|
|
19429
|
+
text_node(m)
|
|
19396
19430
|
])
|
|
19397
19431
|
]);
|
|
19398
19432
|
if (model.internal_methods.length) {
|
|
@@ -19410,7 +19444,7 @@ function build_methods(model) {
|
|
|
19410
19444
|
model.internal_methods.map((m) => [
|
|
19411
19445
|
"span",
|
|
19412
19446
|
row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
|
|
19413
|
-
m
|
|
19447
|
+
text_node(m)
|
|
19414
19448
|
])
|
|
19415
19449
|
]);
|
|
19416
19450
|
}
|
|
@@ -29190,7 +29224,10 @@ function create_tabulator(gobj) {
|
|
|
29190
29224
|
break;
|
|
29191
29225
|
case "enum":
|
|
29192
29226
|
colDef.editor = "list";
|
|
29193
|
-
colDef.editorParams = {
|
|
29227
|
+
colDef.editorParams = {
|
|
29228
|
+
values: field_desc.enum_list || [],
|
|
29229
|
+
itemFormatter: text_list_item_formatter
|
|
29230
|
+
};
|
|
29194
29231
|
break;
|
|
29195
29232
|
case "integer":
|
|
29196
29233
|
case "real":
|
|
@@ -29234,7 +29271,8 @@ function create_tabulator(gobj) {
|
|
|
29234
29271
|
colDef.headerFilter = "list";
|
|
29235
29272
|
colDef.headerFilterParams = {
|
|
29236
29273
|
values: field_desc.enum_list || [],
|
|
29237
|
-
clearable: true
|
|
29274
|
+
clearable: true,
|
|
29275
|
+
itemFormatter: text_list_item_formatter
|
|
29238
29276
|
};
|
|
29239
29277
|
break;
|
|
29240
29278
|
case "fkey":
|
|
@@ -29644,7 +29682,7 @@ function icon_formatter(cell) {
|
|
|
29644
29682
|
class: "ICON_CELL_UNKNOWN is-size-7 yui-text-quiet",
|
|
29645
29683
|
title: name
|
|
29646
29684
|
},
|
|
29647
|
-
name
|
|
29685
|
+
text_node(name)
|
|
29648
29686
|
]);
|
|
29649
29687
|
return createElement2(["span", {
|
|
29650
29688
|
class: `ICON_CELL ${name}`,
|
|
@@ -60582,7 +60620,7 @@ var YuiToolbar = class extends Toolbar {
|
|
|
60582
60620
|
const disabled = item.disabled ? " disabled" : "";
|
|
60583
60621
|
const is_text = item.text !== void 0;
|
|
60584
60622
|
const kind_class = is_text ? " g6-toolbar-item-text" : "";
|
|
60585
|
-
const body = is_text ? `<span class="g6-toolbar-text">${item.text}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${item.id}"></use></svg>`;
|
|
60623
|
+
const body = is_text ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${item.id}"></use></svg>`;
|
|
60586
60624
|
return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${item.value}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
|
|
60587
60625
|
}).join("");
|
|
60588
60626
|
}
|
|
@@ -61812,10 +61850,17 @@ function topic_defaults_of(gobj, topic_name) {
|
|
|
61812
61850
|
* It is written into a card's html (see yui_data_color.js): a
|
|
61813
61851
|
* refused value logs, and the node wears the topic's colour.
|
|
61814
61852
|
************************************************************/
|
|
61853
|
+
var refused_colors_logged = /* @__PURE__ */ new Set();
|
|
61815
61854
|
function data_color(gobj, value) {
|
|
61816
61855
|
if (value === void 0 || value === null || value === "") return null;
|
|
61817
61856
|
let color = css_color_or_null(value);
|
|
61818
|
-
if (!color)
|
|
61857
|
+
if (!color) {
|
|
61858
|
+
let key = `${gobj_short_name(gobj)}\u0000${String(value)}`;
|
|
61859
|
+
if (!refused_colors_logged.has(key) && refused_colors_logged.size < 200) {
|
|
61860
|
+
refused_colors_logged.add(key);
|
|
61861
|
+
log_warning(`${gobj_short_name(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
|
|
61862
|
+
}
|
|
61863
|
+
}
|
|
61819
61864
|
return color;
|
|
61820
61865
|
}
|
|
61821
61866
|
/************************************************************
|
|
@@ -66299,7 +66344,7 @@ function build_context_menu_items(gobj, e) {
|
|
|
66299
66344
|
************************************************************/
|
|
66300
66345
|
function ctx_item(icon_id, label, value) {
|
|
66301
66346
|
return {
|
|
66302
|
-
name: `<svg style="width:1em;height:1em;vertical-align:-0.125em;margin-right:8px;pointer-events:none;fill:currentColor"><use href="#${icon_id}"></use></svg>${label}`,
|
|
66347
|
+
name: `<svg style="width:1em;height:1em;vertical-align:-0.125em;margin-right:8px;pointer-events:none;fill:currentColor"><use href="#${icon_id}"></use></svg>${escapeHtml(String(label))}`,
|
|
66303
66348
|
value
|
|
66304
66349
|
};
|
|
66305
66350
|
}
|
|
@@ -75762,7 +75807,7 @@ function select_input(name, value, options) {
|
|
|
75762
75807
|
value: `${option}`,
|
|
75763
75808
|
selected: `${option}` === `${value}` ? "selected" : void 0
|
|
75764
75809
|
}),
|
|
75765
|
-
`${option}`
|
|
75810
|
+
text_node(`${option}`)
|
|
75766
75811
|
];
|
|
75767
75812
|
});
|
|
75768
75813
|
return [
|
|
@@ -75784,7 +75829,7 @@ function textarea_input(name, value, rows, placeholder) {
|
|
|
75784
75829
|
rows: `${rows || 3}`,
|
|
75785
75830
|
placeholder: placeholder || ""
|
|
75786
75831
|
},
|
|
75787
|
-
value === void 0 || value === null ? "" : `${value}`
|
|
75832
|
+
text_node(value === void 0 || value === null ? "" : `${value}`)
|
|
75788
75833
|
];
|
|
75789
75834
|
}
|
|
75790
75835
|
/***************************************************************
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"dist/gobj-ui.cjs.js",
|
|
19
19
|
"index.js",
|
|
20
20
|
"src/",
|
|
21
|
-
"vite-plugin-yuneta-html.js"
|
|
21
|
+
"vite-plugin-yuneta-html.js",
|
|
22
|
+
"scripts/check-markup-strings.mjs"
|
|
22
23
|
],
|
|
23
24
|
"description": "Yuneta UI Library — the active line: declarative shell (C_YUI_SHELL+NAV+PAGER+WIZARD) + windows, TreeDB views, forms, charts and maps. Consumed from the npm registry by the Yuneta SPAs (gui_agent, gui_treedb, wattyzer, yunovatios). The frozen legacy GClass GUI stack (C_YUI_MAIN/TABS/ROUTING) lives on the v1 branch, npm dist-tag 'legacy' (consumed by estadodelaire and hidraulia).",
|
|
24
25
|
"scripts": {
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/***********************************************************************
|
|
3
|
+
* check-markup-strings.mjs
|
|
4
|
+
*
|
|
5
|
+
* createElement2() reads a plain string that starts with '<' as
|
|
6
|
+
* html (gobj-js), so whether a string RUNS depends on its content,
|
|
7
|
+
* not on who wrote it. The way out is to say markup out loud --
|
|
8
|
+
* html_markup('<i class="yi-copy"></i>') -- and, once every
|
|
9
|
+
* deliberate markup does, to turn on set_strings_are_text(true),
|
|
10
|
+
* where a plain string is always text.
|
|
11
|
+
*
|
|
12
|
+
* This check finds, in the CONTENT of a createElement2()
|
|
13
|
+
* description (`[tag, attrs, content]`) and in its list of
|
|
14
|
+
* children:
|
|
15
|
+
*
|
|
16
|
+
* literal a string literal that starts with '<': deliberate
|
|
17
|
+
* markup, to be wrapped in html_markup().
|
|
18
|
+
* built a template with ${...} or a '+' concatenation that
|
|
19
|
+
* starts with '<': markup BUILT WITH VALUES. If a value
|
|
20
|
+
* is data, that is the hole; build the element with
|
|
21
|
+
* createElement2() and pass the value as text.
|
|
22
|
+
* in-list a string that starts with '<' inside a LIST of
|
|
23
|
+
* children: since gobj-js 7.26.2 a string there is
|
|
24
|
+
* text, so it renders as the literal tags.
|
|
25
|
+
* list-head a list of children whose FIRST item is a string that
|
|
26
|
+
* starts with '<': createElement2() reads such a list as
|
|
27
|
+
* one description, so the string would be its tag.
|
|
28
|
+
*
|
|
29
|
+
* A ternary or a `||`/`&&` in the content is checked branch by
|
|
30
|
+
* branch; `'<b>'.concat(x)` counts as built; a computed tag is
|
|
31
|
+
* taken when the attrs slot is an object literal.
|
|
32
|
+
*
|
|
33
|
+
* What it cannot see: a VARIABLE or a function result holding a
|
|
34
|
+
* string (its type is not known before running); a description
|
|
35
|
+
* built piece by piece (push() into an array that is later the
|
|
36
|
+
* content); a computed tag with an attrs slot that is not an object
|
|
37
|
+
* literal; markup given to innerHTML, or to a widget (Tabulator,
|
|
38
|
+
* G6), which are other sinks. set_strings_are_text(true) logs, once
|
|
39
|
+
* at run time, every string that reaches createElement2() starting
|
|
40
|
+
* with '<': that is the other half of the check.
|
|
41
|
+
*
|
|
42
|
+
* Usage (from the package root):
|
|
43
|
+
* node scripts/check-markup-strings.mjs [dir|file ...] # default: src
|
|
44
|
+
* Exit 1 when anything is found.
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) 2026, ArtGins.
|
|
47
|
+
* All Rights Reserved.
|
|
48
|
+
***********************************************************************/
|
|
49
|
+
import {readFileSync, readdirSync, statSync, realpathSync} from "node:fs";
|
|
50
|
+
import {join, relative} from "node:path";
|
|
51
|
+
import {fileURLToPath} from "node:url";
|
|
52
|
+
import {parse} from "acorn";
|
|
53
|
+
|
|
54
|
+
const TAG_RE = /^[a-z][a-z0-9-]*$/;
|
|
55
|
+
const SKIP_DIRS = new Set(["node_modules", "dist", ".git", "build", "_build"]);
|
|
56
|
+
|
|
57
|
+
function list_files(path, out)
|
|
58
|
+
{
|
|
59
|
+
let st = statSync(path);
|
|
60
|
+
if(st.isDirectory()) {
|
|
61
|
+
for(const name of readdirSync(path)) {
|
|
62
|
+
if(SKIP_DIRS.has(name)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
list_files(join(path, name), out);
|
|
66
|
+
}
|
|
67
|
+
} else if(/\.(js|mjs)$/.test(path) && !/\.test\.(js|mjs)$/.test(path)) {
|
|
68
|
+
out.push(path);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function is_string_literal(n)
|
|
74
|
+
{
|
|
75
|
+
return n && n.type === "Literal" && typeof n.value === "string";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function static_string(n)
|
|
79
|
+
{
|
|
80
|
+
if(is_string_literal(n)) {
|
|
81
|
+
return n.value;
|
|
82
|
+
}
|
|
83
|
+
if(n && n.type === "TemplateLiteral" && n.expressions.length === 0) {
|
|
84
|
+
return n.quasis[0].value.cooked;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function starts_with_markup(s)
|
|
90
|
+
{
|
|
91
|
+
return typeof s === "string" && s.trim().startsWith("<");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* The leftmost string of a '+' chain, the head of a template, or the
|
|
95
|
+
* receiver of a '.concat()'. */
|
|
96
|
+
function built_markup(n)
|
|
97
|
+
{
|
|
98
|
+
if(!n) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if(n.type === "CallExpression" && n.callee.type === "MemberExpression" &&
|
|
102
|
+
!n.callee.computed && n.callee.property.name === "concat") {
|
|
103
|
+
let head = n.callee.object;
|
|
104
|
+
let s = static_string(head);
|
|
105
|
+
if(s !== null) {
|
|
106
|
+
return starts_with_markup(s);
|
|
107
|
+
}
|
|
108
|
+
return built_markup(head);
|
|
109
|
+
}
|
|
110
|
+
if(n.type === "TemplateLiteral" && n.expressions.length > 0) {
|
|
111
|
+
return starts_with_markup(n.quasis[0].value.cooked);
|
|
112
|
+
}
|
|
113
|
+
if(n.type === "BinaryExpression" && n.operator === "+") {
|
|
114
|
+
let left = n;
|
|
115
|
+
while(left.type === "BinaryExpression" && left.operator === "+") {
|
|
116
|
+
left = left.left;
|
|
117
|
+
}
|
|
118
|
+
let s = static_string(left);
|
|
119
|
+
if(s !== null) {
|
|
120
|
+
return starts_with_markup(s);
|
|
121
|
+
}
|
|
122
|
+
return left.type === "TemplateLiteral" && starts_with_markup(left.quasis[0].value.cooked);
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* [tag, attrs, content, events?]: a tag and an attrs slot. A literal
|
|
128
|
+
* tag must look like one; a computed tag (a variable, a ternary) is
|
|
129
|
+
* taken when the attrs slot is an object literal, which is what makes
|
|
130
|
+
* the array a description and not some other triple. */
|
|
131
|
+
function is_description(n)
|
|
132
|
+
{
|
|
133
|
+
if(!n || n.type !== "ArrayExpression" || n.elements.length < 3 || n.elements.length > 4) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
let tag = n.elements[0];
|
|
137
|
+
let attrs = n.elements[1];
|
|
138
|
+
if(!tag || !attrs) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if(is_string_literal(tag)) {
|
|
142
|
+
if(!TAG_RE.test(tag.value)) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return attrs.type === "ObjectExpression" || attrs.type === "Identifier" ||
|
|
146
|
+
attrs.type === "MemberExpression" || attrs.type === "CallExpression" ||
|
|
147
|
+
attrs.type === "ConditionalExpression" ||
|
|
148
|
+
(attrs.type === "Literal" && attrs.value === null);
|
|
149
|
+
}
|
|
150
|
+
if(tag.type === "SpreadElement" || tag.type === "ArrayExpression" ||
|
|
151
|
+
tag.type === "ObjectExpression" || tag.type === "Literal") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return attrs.type === "ObjectExpression";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function walk(node, visit)
|
|
158
|
+
{
|
|
159
|
+
if(!node || typeof node.type !== "string") {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
visit(node);
|
|
163
|
+
for(const key of Object.keys(node)) {
|
|
164
|
+
if(key === "loc" || key === "start" || key === "end") {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
let v = node[key];
|
|
168
|
+
if(Array.isArray(v)) {
|
|
169
|
+
for(const c of v) {
|
|
170
|
+
if(c && typeof c.type === "string") {
|
|
171
|
+
walk(c, visit);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else if(v && typeof v.type === "string") {
|
|
175
|
+
walk(v, visit);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function check_content(n, findings, file, src, where)
|
|
181
|
+
{
|
|
182
|
+
if(!n) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if(n.type === "ConditionalExpression") {
|
|
186
|
+
check_content(n.consequent, findings, file, src, where);
|
|
187
|
+
check_content(n.alternate, findings, file, src, where);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if(n.type === "LogicalExpression") {
|
|
191
|
+
check_content(n.left, findings, file, src, where);
|
|
192
|
+
check_content(n.right, findings, file, src, where);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
let s = static_string(n);
|
|
196
|
+
if(s !== null && starts_with_markup(s)) {
|
|
197
|
+
findings.push({file, line: n.loc.start.line, rule: where === "list" ? "in-list" : "literal",
|
|
198
|
+
text: src.slice(n.start, Math.min(n.end, n.start + 90))});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if(built_markup(n)) {
|
|
202
|
+
findings.push({file, line: n.loc.start.line, rule: "built",
|
|
203
|
+
text: src.slice(n.start, Math.min(n.end, n.start + 90))});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function check_file(file, root)
|
|
208
|
+
{
|
|
209
|
+
const src = readFileSync(file, "utf8");
|
|
210
|
+
let ast;
|
|
211
|
+
try {
|
|
212
|
+
ast = parse(src, {ecmaVersion: "latest", sourceType: "module", locations: true,
|
|
213
|
+
allowHashBang: true, allowAwaitOutsideFunction: true});
|
|
214
|
+
} catch(e) {
|
|
215
|
+
console.error(`${relative(root, file)}: cannot parse: ${e.message}`);
|
|
216
|
+
return [{file, line: 0, rule: "parse", text: e.message}];
|
|
217
|
+
}
|
|
218
|
+
const findings = [];
|
|
219
|
+
const rel = relative(root, file);
|
|
220
|
+
walk(ast, (n) => {
|
|
221
|
+
if(!is_description(n)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
let content = n.elements[2];
|
|
225
|
+
if(content && content.type === "ArrayExpression" && content.elements.length > 0) {
|
|
226
|
+
let head = static_string(content.elements[0]);
|
|
227
|
+
if(head !== null && starts_with_markup(head)) {
|
|
228
|
+
/* createElement2() reads a list that starts with a string
|
|
229
|
+
* as ONE description: '<b>' would be its tag. */
|
|
230
|
+
findings.push({file: rel, line: content.loc.start.line, rule: "list-head",
|
|
231
|
+
text: src.slice(content.start, Math.min(content.end, content.start + 90))});
|
|
232
|
+
} else if(head === null) {
|
|
233
|
+
for(const child of content.elements) {
|
|
234
|
+
check_content(child, findings, rel, src, "list");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
check_content(content, findings, rel, src, "slot");
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return findings;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export {check_file};
|
|
245
|
+
|
|
246
|
+
/* Run as a command (not imported by a test). Both sides through
|
|
247
|
+
* realpath: argv[1] keeps a symlinked path, import.meta.url does not. */
|
|
248
|
+
if(process.argv[1] &&
|
|
249
|
+
realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1])) {
|
|
250
|
+
main();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function main()
|
|
254
|
+
{
|
|
255
|
+
const root = process.cwd();
|
|
256
|
+
const targets = process.argv.slice(2).length ? process.argv.slice(2) : ["src"];
|
|
257
|
+
let files = [];
|
|
258
|
+
for(const t of targets) {
|
|
259
|
+
list_files(join(root, t), files);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let all = [];
|
|
263
|
+
for(const f of files) {
|
|
264
|
+
all = all.concat(check_file(f, root));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const by_rule = {};
|
|
268
|
+
for(const f of all) {
|
|
269
|
+
by_rule[f.rule] = (by_rule[f.rule] || 0) + 1;
|
|
270
|
+
console.log(`${f.file}:${f.line}: ${f.rule}: ${f.text.replace(/\s+/g, " ")}`);
|
|
271
|
+
}
|
|
272
|
+
if(all.length) {
|
|
273
|
+
console.log(`\ncheck-markup-strings: ${all.length} found ` +
|
|
274
|
+
`(${Object.entries(by_rule).map(([k, v]) => `${k} ${v}`).join(", ")}) in ${files.length} files`);
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
console.log(`check-markup-strings: OK (${files.length} files)`);
|
|
278
|
+
}
|
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -229,7 +229,7 @@ class YuiToolbar extends Toolbar
|
|
|
229
229
|
const is_text = (item.text !== undefined);
|
|
230
230
|
const kind_class = is_text ? ' g6-toolbar-item-text' : '';
|
|
231
231
|
const body = is_text
|
|
232
|
-
? `<span class="g6-toolbar-text">${item.text}</span>`
|
|
232
|
+
? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
|
|
233
233
|
: `<svg aria-hidden="true" focusable="false">` +
|
|
234
234
|
`<use xlink:href="#${item.id}"></use>` +
|
|
235
235
|
`</svg>`;
|
|
@@ -2301,6 +2301,8 @@ function topic_defaults_of(gobj, topic_name)
|
|
|
2301
2301
|
* It is written into a card's html (see yui_data_color.js): a
|
|
2302
2302
|
* refused value logs, and the node wears the topic's colour.
|
|
2303
2303
|
************************************************************/
|
|
2304
|
+
const refused_colors_logged = new Set(); // once per (gobj, value): every repaint asks again
|
|
2305
|
+
|
|
2304
2306
|
function data_color(gobj, value)
|
|
2305
2307
|
{
|
|
2306
2308
|
if(value === undefined || value === null || value === "") {
|
|
@@ -2308,7 +2310,11 @@ function data_color(gobj, value)
|
|
|
2308
2310
|
}
|
|
2309
2311
|
let color = css_color_or_null(value);
|
|
2310
2312
|
if(!color) {
|
|
2311
|
-
|
|
2313
|
+
let key = `${gobj_short_name(gobj)}\u0000${String(value)}`;
|
|
2314
|
+
if(!refused_colors_logged.has(key) && refused_colors_logged.size < 200) {
|
|
2315
|
+
refused_colors_logged.add(key);
|
|
2316
|
+
log_warning(`${gobj_short_name(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
|
|
2317
|
+
}
|
|
2312
2318
|
}
|
|
2313
2319
|
return color;
|
|
2314
2320
|
}
|
|
@@ -9017,7 +9023,7 @@ function ctx_item(icon_id, label, value)
|
|
|
9017
9023
|
`vertical-align:-0.125em;margin-right:8px;` +
|
|
9018
9024
|
`pointer-events:none;fill:currentColor">` +
|
|
9019
9025
|
`<use href="#${icon_id}"></use></svg>` +
|
|
9020
|
-
`${label}`;
|
|
9026
|
+
`${escapeHtml(String(label))}`; // text: G6 innerHTMLs the name
|
|
9021
9027
|
return { name: name, value: value };
|
|
9022
9028
|
}
|
|
9023
9029
|
|