@yuneta/gobj-ui 7.26.10 → 7.26.12

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.
@@ -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,13 +1017,30 @@ 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
+ let dropped = false;
1022
+ if (p && p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) {
1023
+ drop_expected_pops(gobj);
1024
+ dropped = true;
1025
+ }
966
1026
  let route = hash_to_route(window.location.hash);
967
1027
  if (!empty_string(route)) navigate_to(gobj, route);
1028
+ if (dropped) push_pending_markers(gobj);
968
1029
  };
969
1030
  window.addEventListener("hashchange", priv.hash_handler);
970
1031
  priv.popstate_handler = (ev) => {
971
1032
  let p = gobj.priv;
972
1033
  if (!p) return;
1034
+ if (p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) {
1035
+ drop_expected_pops(gobj);
1036
+ on_traversal(ev);
1037
+ push_pending_markers(gobj);
1038
+ return;
1039
+ }
1040
+ on_traversal(ev);
1041
+ };
1042
+ let on_traversal = (ev) => {
1043
+ let p = gobj.priv;
973
1044
  if (p.expected_pops > 0) {
974
1045
  p.expected_pops--;
975
1046
  if (p.expected_pops === 0) push_pending_markers(gobj);
@@ -977,6 +1048,7 @@ function mt_start$20(gobj) {
977
1048
  }
978
1049
  if (p.overlay_stack.length === 0) return;
979
1050
  let top = p.overlay_stack[p.overlay_stack.length - 1];
1051
+ if (top.marker_pending) return;
980
1052
  if (window.location.hash !== top.hash) return;
981
1053
  let st = ev && ev.state;
982
1054
  if (st && st.__yui_overlay__ === top.id) return;
@@ -1021,6 +1093,9 @@ function mt_stop$20(gobj) {
1021
1093
  window.removeEventListener("popstate", priv.popstate_handler);
1022
1094
  priv.popstate_handler = null;
1023
1095
  }
1096
+ priv.expected_pops = 0;
1097
+ priv.expected_pop_hash = "";
1098
+ priv.pending_markers = [];
1024
1099
  if (priv.keydown_handler) {
1025
1100
  window.removeEventListener("keydown", priv.keydown_handler);
1026
1101
  priv.keydown_handler = null;
@@ -1824,7 +1899,7 @@ function build_toolbar_action_item(gobj, it) {
1824
1899
  class: "yui-toolbar-item-label",
1825
1900
  i18n: it.name
1826
1901
  },
1827
- it.name
1902
+ text_node(it.name)
1828
1903
  ]);
1829
1904
  let aria_key = it.aria_label || it.name || it.id || "";
1830
1905
  let i18n_aria = it.aria_label || it.name;
@@ -2240,7 +2315,7 @@ function build_dropdown_row(gobj, sub, idx) {
2240
2315
  class: "yui-toolbar-dropdown-label",
2241
2316
  i18n: sub.name
2242
2317
  },
2243
- sub.name
2318
+ text_node(sub.name)
2244
2319
  ]);
2245
2320
  children.push([
2246
2321
  "span",
@@ -2428,6 +2503,7 @@ function push_overlay_history(gobj, close, opts) {
2428
2503
  }
2429
2504
  function push_overlay_marker(gobj, entry) {
2430
2505
  let priv = gobj.priv;
2506
+ entry.below_hash = window.location.hash;
2431
2507
  try {
2432
2508
  window.history.pushState({ __yui_overlay__: entry.id }, "");
2433
2509
  } catch (e) {
@@ -2438,6 +2514,13 @@ function push_overlay_marker(gobj, entry) {
2438
2514
  }
2439
2515
  return true;
2440
2516
  }
2517
+ function drop_expected_pops(gobj) {
2518
+ let priv = gobj.priv;
2519
+ if (!priv || priv.expected_pops === 0) return;
2520
+ 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`);
2521
+ priv.expected_pops = 0;
2522
+ priv.expected_pop_hash = "";
2523
+ }
2441
2524
  function push_pending_markers(gobj) {
2442
2525
  let priv = gobj.priv;
2443
2526
  let pending = priv.pending_markers.splice(0);
@@ -2459,6 +2542,7 @@ function overlay_dismissed(gobj, entry) {
2459
2542
  let st = window.history.state;
2460
2543
  if (st && st.__yui_overlay__ === entry.id) {
2461
2544
  priv.expected_pops++;
2545
+ priv.expected_pop_hash = typeof entry.below_hash === "string" ? entry.below_hash : window.location.hash;
2462
2546
  try {
2463
2547
  window.history.back();
2464
2548
  } catch (e) {
@@ -3051,45 +3135,6 @@ function yui_shell_close_dropdown(shell_gobj) {
3051
3135
  close_toolbar_dropdown(shell_gobj);
3052
3136
  }
3053
3137
  //#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
3138
  //#region src/shell_modals.js
3094
3139
  /***********************************************************************
3095
3140
  * shell_modals.js
@@ -3855,7 +3900,7 @@ function build_default_header(gobj) {
3855
3900
  if (icon.charAt(0) === "<") items.push([
3856
3901
  "span",
3857
3902
  { class: "icon" },
3858
- icon
3903
+ html_markup(icon)
3859
3904
  ]);
3860
3905
  else items.push([
3861
3906
  "span",
@@ -4860,7 +4905,7 @@ function chip_lead(icon) {
4860
4905
  if (icon.charAt(0) === "<") return [
4861
4906
  "span",
4862
4907
  { class: "yui-dock-icon" },
4863
- icon
4908
+ html_markup(icon)
4864
4909
  ];
4865
4910
  return [
4866
4911
  "span",
@@ -4869,9 +4914,6 @@ function chip_lead(icon) {
4869
4914
  ];
4870
4915
  }
4871
4916
  /************************************************************
4872
- * Find a registry entry by its window gobj.
4873
- ************************************************************/
4874
- /************************************************************
4875
4917
  * The window an event is about. A kw is plain json (the machine
4876
4918
  * trace dumps it), so the window travels in it as its FULL NAME,
4877
4919
  * which the trace can print, and the gobj is the event's src --
@@ -4886,6 +4928,10 @@ function window_of(gobj, event, kw, src) {
4886
4928
  warned_gobj_in_kw = true;
4887
4929
  log_warning(`${gobj_short_name(gobj)}: ${event} carries the window gobj in its kw: send {window: gobj_full_name(window)} from the window`);
4888
4930
  }
4931
+ if (w !== src) {
4932
+ 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)})`);
4933
+ return null;
4934
+ }
4889
4935
  return w;
4890
4936
  }
4891
4937
  if (!is_gobj(src) || gobj_full_name(src) !== w) {
@@ -4894,6 +4940,9 @@ function window_of(gobj, event, kw, src) {
4894
4940
  }
4895
4941
  return src;
4896
4942
  }
4943
+ /************************************************************
4944
+ * Find a registry entry by its window gobj.
4945
+ ************************************************************/
4897
4946
  function find_entry(priv, win) {
4898
4947
  for (let e of priv.windows) if (e.gobj === win) return e;
4899
4948
  return null;
@@ -10049,7 +10098,7 @@ function template2columns(gobj, columns, template, sub_elements) {
10049
10098
  break;
10050
10099
  case "enum":
10051
10100
  column.editor = "list";
10052
- column.editorParams = {};
10101
+ column.editorParams = { itemFormatter: text_list_item_formatter };
10053
10102
  switch (field_desc.real_type) {
10054
10103
  case "string":
10055
10104
  case "object":
@@ -15950,7 +15999,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows) {
15950
15999
  else if (err) children.push([
15951
16000
  "span",
15952
16001
  { class: "JSON_STUB_ERR has-text-danger is-size-7 ml-2" },
15953
- String(err.error)
16002
+ text_node(err.error)
15954
16003
  ]);
15955
16004
  let attrs = {
15956
16005
  class: "JSON_ROW JSON_COLLAPSED" + (is_pending ? " is-pending" : ""),
@@ -18935,7 +18984,7 @@ function render_raw(gobj) {
18935
18984
  if (dump.error) children.push([
18936
18985
  "div",
18937
18986
  { class: "GCLASS_RAW_ERROR has-text-danger is-size-7 p-2" },
18938
- dump.error
18987
+ text_node(dump.error)
18939
18988
  ]);
18940
18989
  let $body = createElement2([
18941
18990
  "div",
@@ -19018,7 +19067,7 @@ function build_head(gobj, model) {
19018
19067
  let items = [[
19019
19068
  "span",
19020
19069
  { class: "GCLASS_NAME" },
19021
- model.id || gobj_read_str_attr(gobj, "gclass_name") || "?"
19070
+ text_node(model.id || gobj_read_str_attr(gobj, "gclass_name") || "?")
19022
19071
  ]];
19023
19072
  if (model.instances !== null) items.push([
19024
19073
  "span",
@@ -19049,7 +19098,7 @@ function build_head(gobj, model) {
19049
19098
  title: t("current state"),
19050
19099
  "data-i18n-title": "current state"
19051
19100
  },
19052
- current
19101
+ text_node(current)
19053
19102
  ]);
19054
19103
  return [
19055
19104
  "div",
@@ -19392,7 +19441,7 @@ function build_methods(model) {
19392
19441
  model.methods.map((m) => [
19393
19442
  "span",
19394
19443
  row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
19395
- m
19444
+ text_node(m)
19396
19445
  ])
19397
19446
  ]);
19398
19447
  if (model.internal_methods.length) {
@@ -19410,7 +19459,7 @@ function build_methods(model) {
19410
19459
  model.internal_methods.map((m) => [
19411
19460
  "span",
19412
19461
  row_attrs(m, { class: "GCLASS_CHIP GCLASS_METHOD" }),
19413
- m
19462
+ text_node(m)
19414
19463
  ])
19415
19464
  ]);
19416
19465
  }
@@ -29190,7 +29239,10 @@ function create_tabulator(gobj) {
29190
29239
  break;
29191
29240
  case "enum":
29192
29241
  colDef.editor = "list";
29193
- colDef.editorParams = { values: field_desc.enum_list || [] };
29242
+ colDef.editorParams = {
29243
+ values: field_desc.enum_list || [],
29244
+ itemFormatter: text_list_item_formatter
29245
+ };
29194
29246
  break;
29195
29247
  case "integer":
29196
29248
  case "real":
@@ -29234,7 +29286,8 @@ function create_tabulator(gobj) {
29234
29286
  colDef.headerFilter = "list";
29235
29287
  colDef.headerFilterParams = {
29236
29288
  values: field_desc.enum_list || [],
29237
- clearable: true
29289
+ clearable: true,
29290
+ itemFormatter: text_list_item_formatter
29238
29291
  };
29239
29292
  break;
29240
29293
  case "fkey":
@@ -29644,7 +29697,7 @@ function icon_formatter(cell) {
29644
29697
  class: "ICON_CELL_UNKNOWN is-size-7 yui-text-quiet",
29645
29698
  title: name
29646
29699
  },
29647
- name
29700
+ text_node(name)
29648
29701
  ]);
29649
29702
  return createElement2(["span", {
29650
29703
  class: `ICON_CELL ${name}`,
@@ -60576,14 +60629,14 @@ var YuiToolbar = class extends Toolbar {
60576
60629
  async getDOMContent() {
60577
60630
  return (await this.options.getItems()).map((item) => {
60578
60631
  if (item.separator) return `<div class="g6-toolbar-sep" aria-hidden="true"></div>`;
60579
- const extra_class = item.className ? ` ${item.className}` : "";
60580
- const title = item.title ?? "";
60581
- if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${item.text ?? ""}</div>`;
60632
+ const extra_class = item.className ? ` ${escapeHtml(String(item.className))}` : "";
60633
+ const title = escapeHtml(String(item.title ?? ""));
60634
+ if (item.readout) return `<div class="g6-toolbar-readout${extra_class}" title="${title}" aria-label="${title}">${escapeHtml(String(item.text ?? ""))}</div>`;
60582
60635
  const disabled = item.disabled ? " disabled" : "";
60583
60636
  const is_text = item.text !== void 0;
60584
60637
  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>`;
60586
- return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${item.value}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60638
+ const body = is_text ? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>` : `<svg aria-hidden="true" focusable="false"><use xlink:href="#${escapeHtml(String(item.id))}"></use></svg>`;
60639
+ return `<div class="g6-toolbar-item${kind_class}${extra_class}" value="${escapeHtml(String(item.value))}" title="${title}" aria-label="${title}"${disabled}>${body}</div>`;
60587
60640
  }).join("");
60588
60641
  }
60589
60642
  };
@@ -61812,10 +61865,23 @@ function topic_defaults_of(gobj, topic_name) {
61812
61865
  * It is written into a card's html (see yui_data_color.js): a
61813
61866
  * refused value logs, and the node wears the topic's colour.
61814
61867
  ************************************************************/
61868
+ var refused_colors_logged = /* @__PURE__ */ new Set();
61869
+ var REFUSED_COLORS_LOG_MAX = 200;
61870
+ var refused_colors_capped = false;
61815
61871
  function data_color(gobj, value) {
61816
61872
  if (value === void 0 || value === null || value === "") return null;
61817
61873
  let color = css_color_or_null(value);
61818
- if (!color) log_warning(`${gobj_short_name(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
61874
+ if (!color) {
61875
+ let key = `${gobj_short_name(gobj)}\u0000${String(value)}`;
61876
+ if (refused_colors_logged.has(key)) return color;
61877
+ if (refused_colors_logged.size < REFUSED_COLORS_LOG_MAX) {
61878
+ refused_colors_logged.add(key);
61879
+ log_warning(`${gobj_short_name(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
61880
+ } else if (!refused_colors_capped) {
61881
+ refused_colors_capped = true;
61882
+ log_warning(`${gobj_short_name(gobj)}: ${REFUSED_COLORS_LOG_MAX} refused colours logged; further refused colours are not logged`);
61883
+ }
61884
+ }
61819
61885
  return color;
61820
61886
  }
61821
61887
  /************************************************************
@@ -66299,7 +66365,7 @@ function build_context_menu_items(gobj, e) {
66299
66365
  ************************************************************/
66300
66366
  function ctx_item(icon_id, label, value) {
66301
66367
  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}`,
66368
+ 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
66369
  value
66304
66370
  };
66305
66371
  }
@@ -70794,7 +70860,7 @@ function refresh_legend(gobj) {
70794
70860
  class: "GRAPH_LEGEND_NAME",
70795
70861
  style: (is_main ? LEGEND_MAIN_NAME_STYLE : LEGEND_NAME_STYLE) + (hidden ? " text-decoration:line-through; opacity:.6;" : "")
70796
70862
  },
70797
- topic_name
70863
+ text_node(topic_name)
70798
70864
  ], [
70799
70865
  "span",
70800
70866
  {
@@ -75762,7 +75828,7 @@ function select_input(name, value, options) {
75762
75828
  value: `${option}`,
75763
75829
  selected: `${option}` === `${value}` ? "selected" : void 0
75764
75830
  }),
75765
- `${option}`
75831
+ text_node(`${option}`)
75766
75832
  ];
75767
75833
  });
75768
75834
  return [
@@ -75784,7 +75850,7 @@ function textarea_input(name, value, rows, placeholder) {
75784
75850
  rows: `${rows || 3}`,
75785
75851
  placeholder: placeholder || ""
75786
75852
  },
75787
- value === void 0 || value === null ? "" : `${value}`
75853
+ text_node(value === void 0 || value === null ? "" : `${value}`)
75788
75854
  ];
75789
75855
  }
75790
75856
  /***************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.10",
3
+ "version": "7.26.12",
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": {