@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.
Files changed (48) hide show
  1. package/README.md +74 -25
  2. package/dist/gobj-ui.cjs.js +967 -377
  3. package/dist/gobj-ui.es.js +967 -377
  4. package/index.js +5 -1
  5. package/package.json +2 -2
  6. package/src/c_g6_nodes_tree.js +69 -24
  7. package/src/c_yui_form.js +331 -140
  8. package/src/c_yui_gclass.js +26 -21
  9. package/src/c_yui_gobj_tree_js.js +16 -5
  10. package/src/c_yui_json.js +7 -6
  11. package/src/c_yui_json_graph.js +42 -14
  12. package/src/c_yui_json_pad.js +2 -1
  13. package/src/c_yui_map.js +139 -75
  14. package/src/c_yui_nav.js +60 -20
  15. package/src/c_yui_pager.js +14 -9
  16. package/src/c_yui_period.js +16 -6
  17. package/src/c_yui_schema_editor.js +3 -2
  18. package/src/c_yui_shell.js +96 -31
  19. package/src/c_yui_treedb_topic_with_form.js +50 -56
  20. package/src/c_yui_treedb_topics.js +8 -7
  21. package/src/c_yui_uplot.js +1 -1
  22. package/src/c_yui_window.js +123 -36
  23. package/src/c_yui_window_manager.js +8 -3
  24. package/src/c_yui_wizard.js +23 -8
  25. package/src/delete_impact.js +5 -3
  26. package/src/form_json_field.js +123 -0
  27. package/src/form_json_field.test.js +49 -0
  28. package/src/form_json_field.wiring.test.js +137 -0
  29. package/src/form_table_rearm.wiring.test.js +158 -0
  30. package/src/g6_event_kw.js +36 -0
  31. package/src/nav_cards_helpers.js +2 -1
  32. package/src/nav_cards_helpers.test.js +7 -3
  33. package/src/schema_to_c.js +27 -1
  34. package/src/schema_to_c.test.js +15 -1
  35. package/src/shell_modals.js +5 -3
  36. package/src/shell_route_map.js +18 -13
  37. package/src/treedb_topics_transport.wiring.test.js +35 -1
  38. package/src/vite_plugin_yuneta_html.test.js +79 -0
  39. package/src/window_show.wiring.test.js +83 -0
  40. package/src/window_veto_back.wiring.test.js +136 -0
  41. package/src/wizard_chrome.wiring.test.js +87 -0
  42. package/src/yui_dev.js +23 -14
  43. package/src/yui_frontend_view.js +4 -4
  44. package/src/yui_gclass_view.js +3 -3
  45. package/src/yui_table_filter_clear.js +44 -44
  46. package/src/yui_text.js +31 -0
  47. package/src/yui_text.test.js +39 -0
  48. package/vite-plugin-yuneta-html.js +36 -9
package/src/c_yui_nav.js CHANGED
@@ -82,6 +82,7 @@ import {
82
82
  breakpoints_from_expr,
83
83
  bulma_hidden_class,
84
84
  } from "./shell_show_on.js";
85
+ import {text_node} from "./yui_text.js";
85
86
 
86
87
  /***************************************************************
87
88
  * Constants
@@ -108,7 +109,7 @@ const attrs_table = [
108
109
  SDATA(data_type_t.DTP_POINTER, "subscriber", 0, null, "Subscriber of output events"),
109
110
 
110
111
  SDATA(data_type_t.DTP_STRING, "menu_id", 0, "", "Id of the menu this nav renders"),
111
- SDATA(data_type_t.DTP_STRING, "nav_label", 0, "", "Human-readable label for aria/heading; falls back to menu_id"),
112
+ SDATA(data_type_t.DTP_STRING, "nav_label", 0, "", "i18n key of the label for aria/heading; falls back to 'navigation'"),
112
113
  SDATA(data_type_t.DTP_JSON, "menu_items", 0, null, "Array of menu items to render"),
113
114
  SDATA(data_type_t.DTP_STRING, "zone", 0, "", "Zone id where this nav lives"),
114
115
  SDATA(data_type_t.DTP_STRING, "layout", 0, "vertical", "vertical|icon-bar|tabs|drawer|submenu|accordion"),
@@ -128,7 +129,8 @@ SDATA_END()
128
129
  let __nav_aria_seq__ = 0;
129
130
 
130
131
  let PRIVATE_DATA = {
131
- click_handler: null
132
+ click_handler: null,
133
+ key_handler: null
132
134
  };
133
135
  let __gclass__ = null;
134
136
 
@@ -193,6 +195,9 @@ function mt_destroy(gobj)
193
195
  if($c && priv && priv.click_handler) {
194
196
  $c.removeEventListener("click", priv.click_handler);
195
197
  }
198
+ if($c && priv && priv.key_handler) {
199
+ $c.removeEventListener("keydown", priv.key_handler);
200
+ }
196
201
  if($c && $c.parentNode) {
197
202
  $c.parentNode.removeChild($c);
198
203
  }
@@ -261,8 +266,11 @@ function build_ui(gobj)
261
266
  if(layout !== "drawer") {
262
267
  $container.setAttribute("role", "navigation");
263
268
  if(!$container.hasAttribute("aria-label")) {
264
- let label = gobj_read_attr(gobj, "nav_label") || menu_id;
265
- $container.setAttribute("aria-label", label);
269
+ /* A key, translated by the shell's translator: the bare
270
+ * menu_id read out "secondary.main.system". */
271
+ let label = gobj_read_attr(gobj, "nav_label") || "navigation";
272
+ $container.setAttribute("aria-label", t(label));
273
+ $container.setAttribute("data-i18n-aria-label", label);
266
274
  }
267
275
  }
268
276
 
@@ -295,6 +303,9 @@ function rebuild(gobj)
295
303
  if($old && priv.click_handler) {
296
304
  $old.removeEventListener("click", priv.click_handler);
297
305
  }
306
+ if($old && priv.key_handler) {
307
+ $old.removeEventListener("keydown", priv.key_handler);
308
+ }
298
309
 
299
310
  build_ui(gobj); /* writes a fresh $container + wires new clicks */
300
311
 
@@ -401,24 +412,31 @@ function render_tabs(gobj, items)
401
412
  ["i", {class: it.icon, "aria-hidden":"true"}]]);
402
413
  }
403
414
  if(show_label && !empty_string(it.name)) {
404
- children.push(["span", {i18n: it.name}, it.name]);
415
+ children.push(["span", {i18n: it.name}, text_node(it.name)]);
405
416
  }
406
417
  /* Optional close affordance: a trailing ✕ that emits
407
418
  * EV_NAV_ITEM_CLOSE instead of navigating (caught first in
408
419
  * wire_clicks by its data-close-item marker). */
409
420
  if(it.closable) {
410
421
  children.push(["span", {class: "icon is-small yui-nav-close ml-2",
411
- "data-close-item": it.id, role: "button",
422
+ "data-close-item": it.id, role: "button", tabindex: "0",
412
423
  "aria-label": t("close"), "data-i18n-aria-label": "close",
413
424
  title: t("close"), "data-i18n-title": "close"},
414
425
  ["i", {class: "yi-xmark", "aria-hidden":"true"}]]);
415
426
  }
427
+ /* A tab with show_label:false is a bare icon: the label is
428
+ * its only name (same contract as item_li). */
429
+ let label = it.name || "";
416
430
  let a_attrs = {
417
431
  href: it.route ? "#" + it.route : "#",
418
432
  "data-item-id": it.id,
419
- "data-route": it.route || ""
433
+ "data-route": it.route || "",
434
+ "aria-label": label || it.id
420
435
  };
421
- let tip = it.tooltip || it.aria_label;
436
+ if(label) {
437
+ a_attrs["data-i18n-aria-label"] = label;
438
+ }
439
+ let tip = it.tooltip || it.aria_label || label;
422
440
  if(tip) {
423
441
  a_attrs.title = tip;
424
442
  a_attrs["data-i18n-title"] = tip;
@@ -478,7 +496,7 @@ function render_breadcrumb(gobj, items)
478
496
  }
479
497
  if(show_label !== false) {
480
498
  let label = it.name || it.id || "";
481
- children.push(["span", {class: "yui-nav-label", i18n: label}, label]);
499
+ children.push(["span", {class: "yui-nav-label", i18n: label}, text_node(label)]);
482
500
  }
483
501
  let a_attrs = {
484
502
  class: "yui-nav-item yui-nav-crumb",
@@ -524,7 +542,7 @@ function render_backbar(gobj)
524
542
  ["a", a_attrs, [
525
543
  ["span", {class: "icon is-small"},
526
544
  ["i", {class: "yi-arrow-left", "aria-hidden": "true"}]],
527
- ["span", label_attrs, label]
545
+ ["span", label_attrs, text_node(label)]
528
546
  ]]
529
547
  ]
530
548
  );
@@ -536,12 +554,13 @@ function render_drawer(gobj, items)
536
554
  * outer wrapper. Open/close is driven from the toolbar or from the
537
555
  * public yui_shell_{open,close,toggle}_drawer() helpers.
538
556
  */
539
- let menu_id = gobj_read_attr(gobj, "menu_id") || "drawer";
540
557
  let wrap = document.createElement("div");
541
558
  wrap.className = "yui-drawer";
542
559
  wrap.setAttribute("role", "dialog");
543
560
  wrap.setAttribute("aria-modal", "true");
544
- wrap.setAttribute("aria-label", menu_id);
561
+ let nav_label = gobj_read_attr(gobj, "nav_label") || "navigation";
562
+ wrap.setAttribute("aria-label", t(nav_label));
563
+ wrap.setAttribute("data-i18n-aria-label", nav_label);
545
564
 
546
565
  let back = document.createElement("div");
547
566
  back.className = "yui-drawer-backdrop";
@@ -551,7 +570,8 @@ function render_drawer(gobj, items)
551
570
  let panel = document.createElement("div");
552
571
  panel.className = "yui-drawer-panel";
553
572
  panel.setAttribute("role", "navigation");
554
- panel.setAttribute("aria-label", menu_id);
573
+ panel.setAttribute("aria-label", t(nav_label));
574
+ panel.setAttribute("data-i18n-aria-label", nav_label);
555
575
  panel.appendChild(render_vertical(gobj, items));
556
576
 
557
577
  wrap.appendChild(back);
@@ -614,6 +634,10 @@ function render_accordion(gobj, items)
614
634
  };
615
635
  if(!empty_string(head_text)) {
616
636
  head_attrs.i18n = head_text;
637
+ head_attrs.title = head_text;
638
+ head_attrs["data-i18n-title"] = head_text;
639
+ head_attrs["aria-label"] = head_text;
640
+ head_attrs["data-i18n-aria-label"] = head_text;
617
641
  }
618
642
  let $hdr = createElement2(["button", head_attrs, head_text]);
619
643
  $container.appendChild($hdr);
@@ -660,7 +684,7 @@ function item_li(gobj, it, opts)
660
684
  span_attrs.i18n = label;
661
685
  }
662
686
  return ["li", {class: "yui-nav-section-header", role: "presentation"},
663
- ["span", span_attrs, label]
687
+ ["span", span_attrs, text_node(label)]
664
688
  ];
665
689
  }
666
690
 
@@ -672,7 +696,7 @@ function item_li(gobj, it, opts)
672
696
  ? ["span", {class: "icon"}, ["i", {class: it.icon, "aria-hidden":"true"}]]
673
697
  : null;
674
698
  let label_el = (show_label && !empty_string(label))
675
- ? ["span", {class: "yui-nav-label", i18n: label}, label]
699
+ ? ["span", {class: "yui-nav-label", i18n: label}, text_node(label)]
676
700
  : null;
677
701
 
678
702
  let a_class = "yui-nav-item";
@@ -717,7 +741,7 @@ function item_li(gobj, it, opts)
717
741
  * Skip when both empty so we don't emit `title=""` noise.
718
742
  * Mirror the value in `data-i18n-title` so refresh_language()
719
743
  * can re-translate the tooltip on language switch. */
720
- let tip = it.tooltip || it.aria_label;
744
+ let tip = it.tooltip || it.aria_label || label;
721
745
  if(tip) {
722
746
  a_attrs.title = tip;
723
747
  a_attrs["data-i18n-title"] = tip;
@@ -741,7 +765,7 @@ function item_iconbar(gobj, it, opts)
741
765
  ["i", {class: it.icon, "aria-hidden":"true"}]]
742
766
  : null;
743
767
  let label_el = (show_label && !empty_string(label))
744
- ? ["span", {class: "yui-nav-label is-size-7", i18n: label}, label]
768
+ ? ["span", {class: "yui-nav-label is-size-7", i18n: label}, text_node(label)]
745
769
  : null;
746
770
 
747
771
  let children = [];
@@ -771,7 +795,7 @@ function item_iconbar(gobj, it, opts)
771
795
  if(label) {
772
796
  a_attrs["data-i18n-aria-label"] = label;
773
797
  }
774
- let tip = it.tooltip || it.aria_label;
798
+ let tip = it.tooltip || it.aria_label || label;
775
799
  if(tip) {
776
800
  a_attrs.title = tip;
777
801
  a_attrs["data-i18n-title"] = tip;
@@ -864,6 +888,21 @@ function wire_clicks(gobj, $container)
864
888
 
865
889
  $container.addEventListener("click", handler);
866
890
  priv.click_handler = handler;
891
+
892
+ /* The ✕ of a closable tab is a span (a button inside the tab's
893
+ * <a> is invalid): Enter/Space on it does what a click does. */
894
+ let key_handler = ev => {
895
+ if(ev.key !== "Enter" && ev.key !== " ") {
896
+ return;
897
+ }
898
+ let target = ev.target;
899
+ if(!target || !target.closest || !target.closest("[data-close-item]")) {
900
+ return;
901
+ }
902
+ handler(ev);
903
+ };
904
+ $container.addEventListener("keydown", key_handler);
905
+ priv.key_handler = key_handler;
867
906
  }
868
907
 
869
908
 
@@ -972,8 +1011,9 @@ function ac_route_changed(gobj, event, kw, src)
972
1011
 
973
1012
  function css_escape(s)
974
1013
  {
975
- /* Minimal escape for attribute selector */
976
- return String(s).replace(/"/g, '\\"');
1014
+ /* For a quoted attribute selector: a backslash too, or a route
1015
+ * carrying one makes querySelector throw. */
1016
+ return String(s).replace(/\\/g, "\\\\").replace(/"/g, '\\"');
977
1017
  }
978
1018
 
979
1019
  /***************************************************************
@@ -148,7 +148,9 @@ function build_ui(gobj)
148
148
  ['div', {class: 'C_YUI_PAGER', style: 'height:100%; display:flex; flex-direction:column;'}, [
149
149
  ['div', {class: 'yui-pager-header is-flex is-align-items-center is-flex-grow-0',
150
150
  style: 'gap:.25rem; padding:.25rem .25rem;'}, [
151
- ['button', {class: 'yui-pager-back button is-white is-hidden', 'aria-label': t('back'), 'data-i18n-aria-label': 'back'}, [
151
+ ['button', {class: 'yui-pager-back button is-white is-hidden',
152
+ title: t('back'), 'data-i18n-title': 'back',
153
+ 'aria-label': t('back'), 'data-i18n-aria-label': 'back'}, [
152
154
  ['span', {class: 'icon'}, ['i', {class: 'yi-arrow-left'}]]
153
155
  ], {
154
156
  click: function(evt) {
@@ -157,7 +159,9 @@ function build_ui(gobj)
157
159
  }
158
160
  }],
159
161
  ['span', {class: 'yui-pager-title is-flex-grow-1', style: 'font-weight:600;'}, ''],
160
- ['button', {class: 'yui-pager-discard button is-white is-hidden', 'aria-label': t('discard'), 'data-i18n-aria-label': 'discard'}, [
162
+ ['button', {class: 'yui-pager-discard button is-white is-hidden',
163
+ title: t('discard'), 'data-i18n-title': 'discard',
164
+ 'aria-label': t('discard'), 'data-i18n-aria-label': 'discard'}, [
161
165
  ['span', {class: 'icon'}, ['i', {class: 'yi-broom'}]],
162
166
  ['span', {class: 'is-hidden-mobile', i18n: 'discard'}, 'discard']
163
167
  ], {
@@ -233,13 +237,14 @@ function render_header(gobj)
233
237
  * deeper pages show a back arrow.
234
238
  */
235
239
  let $back_icon = $back.querySelector('i');
236
- if(model.back_kind === "close") {
237
- $back_icon.className = 'yi-xmark';
238
- $back.setAttribute('aria-label', 'close');
239
- } else {
240
- $back_icon.className = 'yi-arrow-left';
241
- $back.setAttribute('aria-label', 'back');
242
- }
240
+ let back_key = (model.back_kind === "close") ? 'close' : 'back';
241
+ $back_icon.className = (back_key === 'close') ? 'yi-xmark' : 'yi-arrow-left';
242
+ /* The key moves with the glyph: a key left on "back" made the ✕ of
243
+ * the root page announce itself as Back after a language switch. */
244
+ $back.setAttribute('title', t(back_key));
245
+ $back.setAttribute('data-i18n-title', back_key);
246
+ $back.setAttribute('aria-label', t(back_key));
247
+ $back.setAttribute('data-i18n-aria-label', back_key);
243
248
  $discard.classList.toggle('is-hidden', !model.show_discard);
244
249
  /* render_header runs on every push/pop/replace, AFTER the host's
245
250
  * one-time refresh_language($container,t), so the title must be
@@ -563,10 +563,13 @@ function build_ui(gobj)
563
563
 
564
564
  function build_mode_button(gobj, mode)
565
565
  {
566
+ /* The name is COMPOSED for a bucket (period_name), so it carries no
567
+ * key: ac_language_changed() rewrites the text and both names. */
568
+ let name = mode_name(mode);
566
569
  let $btn = createElement2(
567
570
  ["button", {class: `button YUI_PERIOD_MODE YUI_PERIOD_MODE_${mode.id.toUpperCase()}`,
568
- type: "button"},
569
- [["span", {class: "YUI_PERIOD_MODE_TEXT"}, mode_name(mode)]]
571
+ type: "button", title: name, "aria-label": name},
572
+ [["span", {class: "YUI_PERIOD_MODE_TEXT"}, name]]
570
573
  ]);
571
574
  $btn.addEventListener("click", () => {
572
575
  gobj_send_event(gobj, "EV_SET_MODE", {mode: mode.id}, gobj);
@@ -588,10 +591,12 @@ function build_more_menu(gobj)
588
591
  if(!mode.overflow) {
589
592
  continue;
590
593
  }
594
+ let name = mode_name(mode);
591
595
  let $item = createElement2(
592
596
  ["a", {class: `dropdown-item YUI_PERIOD_MODE ` +
593
- `YUI_PERIOD_MODE_${mode.id.toUpperCase()}`, href: "#"},
594
- [["span", {class: "YUI_PERIOD_MODE_TEXT"}, mode_name(mode)]]
597
+ `YUI_PERIOD_MODE_${mode.id.toUpperCase()}`, href: "#",
598
+ title: name, "aria-label": name},
599
+ [["span", {class: "YUI_PERIOD_MODE_TEXT"}, name]]
595
600
  ]);
596
601
  $item.addEventListener("click", (ev) => {
597
602
  ev.preventDefault();
@@ -996,7 +1001,9 @@ function render_calendar(gobj)
996
1001
  : build_years_grid(gobj, view);
997
1002
 
998
1003
  let $today = createElement2(
999
- ["button", {class: "button is-ghost mt-2 YUI_PERIOD_CAL_TODAY", type: "button"},
1004
+ ["button", {class: "button is-ghost mt-2 YUI_PERIOD_CAL_TODAY", type: "button",
1005
+ title: t("today"), "data-i18n-title": "today",
1006
+ "aria-label": t("today"), "data-i18n-aria-label": "today"},
1000
1007
  [["span", {"data-i18n": "today"}, t("today")]]
1001
1008
  ]);
1002
1009
  $today.addEventListener("click", () => {
@@ -1357,10 +1364,13 @@ function ac_language_changed(gobj, event, kw, src)
1357
1364
  if(!mode.$btn) {
1358
1365
  continue;
1359
1366
  }
1367
+ let name = mode_name(mode);
1360
1368
  let $text = mode.$btn.querySelector(".YUI_PERIOD_MODE_TEXT");
1361
1369
  if($text) {
1362
- $text.textContent = mode_name(mode);
1370
+ $text.textContent = name;
1363
1371
  }
1372
+ mode.$btn.setAttribute("title", name);
1373
+ mode.$btn.setAttribute("aria-label", name);
1364
1374
  }
1365
1375
  repaint(gobj);
1366
1376
  if(priv.$calendar) {
@@ -158,6 +158,7 @@ import {
158
158
  } from "./shell_modals.js";
159
159
 
160
160
  import {t} from "i18next";
161
+ import {text_node} from "./yui_text.js";
161
162
 
162
163
 
163
164
  /***************************************************************
@@ -1111,11 +1112,11 @@ function render_toolbar(gobj)
1111
1112
  ];
1112
1113
  if(priv.treedb_id) {
1113
1114
  $trail.push(["span", {class: "SCHEMA_CRUMB_SEP"}, "/"]);
1114
- $trail.push(["span", {class: "SCHEMA_CRUMB_TREEDB"}, priv.treedb_id]);
1115
+ $trail.push(["span", {class: "SCHEMA_CRUMB_TREEDB"}, text_node(priv.treedb_id)]);
1115
1116
  }
1116
1117
  if(priv.topic_name) {
1117
1118
  $trail.push(["span", {class: "SCHEMA_CRUMB_SEP"}, "/"]);
1118
- $trail.push(["span", {class: "SCHEMA_CRUMB_TOPIC"}, priv.topic_name]);
1119
+ $trail.push(["span", {class: "SCHEMA_CRUMB_TOPIC"}, text_node(priv.topic_name)]);
1119
1120
  }
1120
1121
  if(priv.diagram) {
1121
1122
  $trail.push(["span", {class: "SCHEMA_CRUMB_SEP"}, "/"]);
@@ -33,7 +33,7 @@ import {
33
33
  SDATA, SDATA_END, data_type_t, event_flag_t, gclass_flag_t,
34
34
  gclass_create, log_error, log_warning,
35
35
  gobj_create, gobj_destroy,
36
- gobj_start, gobj_stop,
36
+ gobj_start, gobj_stop, gobj_stop_children,
37
37
  gobj_parent,
38
38
  gobj_gclass_name,
39
39
  gobj_publish_event,
@@ -44,6 +44,7 @@ import {
44
44
  refresh_language,
45
45
  is_gobj,
46
46
  gobj_has_event,
47
+ gobj_short_name,
47
48
  gobj_is_destroying,
48
49
  } from "@yuneta/gobj-js";
49
50
 
@@ -419,6 +420,10 @@ function mt_stop(gobj)
419
420
  st.items = {};
420
421
  st.active_route = null;
421
422
  }
423
+
424
+ /* Whatever else the shell hosts — the site map window — stops
425
+ * with it, or destroying the shell destroys a RUNNING gobj. */
426
+ gobj_stop_children(gobj);
422
427
  }
423
428
 
424
429
  /***************************************************************
@@ -1795,12 +1800,13 @@ function build_toolbar_action_item(gobj, it)
1795
1800
  btn_attrs["aria-haspopup"] = "menu";
1796
1801
  btn_attrs["aria-expanded"] = "false";
1797
1802
  }
1798
- /* Hover tooltip: prefer explicit `tooltip`, fall back to
1799
- * `aria_label` (usually the same intent — e.g. "Search (Ctrl+F)").
1800
- * Skip when both empty so we don't emit `title=""` noise.
1803
+ /* Hover tooltip: prefer explicit `tooltip`, then `aria_label`
1804
+ * (usually the same intent — e.g. "Search (Ctrl+F)"), then the
1805
+ * name: every control carries a title. Skip only when all are
1806
+ * empty, so we don't emit `title=""` noise.
1801
1807
  * Mirror the value in `data-i18n-title` so refresh_language()
1802
1808
  * can re-translate the tooltip on language switch. */
1803
- let tip = it.tooltip || it.aria_label;
1809
+ let tip = it.tooltip || i18n_aria;
1804
1810
  if(tip) {
1805
1811
  btn_attrs.title = tip;
1806
1812
  btn_attrs["data-i18n-title"] = tip;
@@ -1866,6 +1872,11 @@ function build_toolbar_brand_item(gobj, it)
1866
1872
  } else {
1867
1873
  attrs.type = "button";
1868
1874
  }
1875
+ let tip = it.tooltip || i18n_aria;
1876
+ if(tag !== "div" && tip) {
1877
+ attrs.title = tip;
1878
+ attrs["data-i18n-title"] = tip;
1879
+ }
1869
1880
  let $item = createElement2([tag, attrs, [
1870
1881
  ["img", {class: "yui-toolbar-brand-logo",
1871
1882
  src: it.logo, alt: alt}],
@@ -1904,7 +1915,7 @@ function build_toolbar_avatar_item(gobj, it)
1904
1915
  attrs["aria-haspopup"] = "menu";
1905
1916
  attrs["aria-expanded"] = "false";
1906
1917
  }
1907
- let tip = it.tooltip || it.aria_label;
1918
+ let tip = it.tooltip || i18n_aria;
1908
1919
  if(tip) {
1909
1920
  attrs.title = tip;
1910
1921
  attrs["data-i18n-title"] = tip;
@@ -1991,7 +2002,7 @@ function build_toolbar_connection_item(gobj, it)
1991
2002
  "aria-label": aria_key,
1992
2003
  "data-i18n-aria-label": i18n_aria
1993
2004
  };
1994
- let tip = it.tooltip || it.aria_label;
2005
+ let tip = it.tooltip || i18n_aria;
1995
2006
  if(tip) {
1996
2007
  attrs.title = tip;
1997
2008
  attrs["data-i18n-title"] = tip;
@@ -2219,6 +2230,14 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
2219
2230
  $panel.style.right = "auto";
2220
2231
  $panel.style.left = `${Math.round(left)}px`;
2221
2232
  }
2233
+ /* And inside it vertically: on a short phone screen a long menu
2234
+ * (one row per language) ran off the bottom, out of reach. It
2235
+ * scrolls inside itself instead (see `dismiss` below). */
2236
+ let max_h = window.innerHeight - Math.max(0, pos.top) - margin;
2237
+ if(max_h > 0) {
2238
+ $panel.style.maxHeight = `${Math.round(max_h)}px`;
2239
+ $panel.style.overflowY = "auto";
2240
+ }
2222
2241
 
2223
2242
  /* Translate the lazily-built panel (see the note above). */
2224
2243
  yui_shell_translate(gobj, $panel);
@@ -2242,7 +2261,15 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
2242
2261
  * trigger. Match native <select> UX and dismiss on either.
2243
2262
  * Capture-phase + passive scroll so we hear all scrollers (any
2244
2263
  * ancestor, not just window) without blocking them. */
2245
- let dismiss = () => close_toolbar_dropdown(gobj);
2264
+ let dismiss = (ev) => {
2265
+ /* The panel's own scroll is the reader reaching its last rows,
2266
+ * not a layout shift. */
2267
+ if(ev && ev.type === "scroll" && ev.target && ev.target !== document &&
2268
+ $panel.contains(ev.target)) {
2269
+ return;
2270
+ }
2271
+ close_toolbar_dropdown(gobj);
2272
+ };
2246
2273
  document.addEventListener("scroll", dismiss, {capture: true, passive: true});
2247
2274
  window.addEventListener("resize", dismiss);
2248
2275
 
@@ -2359,6 +2386,8 @@ function build_dropdown_row(gobj, sub, idx)
2359
2386
  };
2360
2387
  if(i18n_aria) {
2361
2388
  attrs["data-i18n-aria-label"] = i18n_aria;
2389
+ attrs.title = i18n_aria;
2390
+ attrs["data-i18n-title"] = i18n_aria;
2362
2391
  }
2363
2392
  let $btn = createElement2(["button", attrs, children]);
2364
2393
  $btn.addEventListener("click", ev => {
@@ -2442,6 +2471,7 @@ function push_escape(gobj, layer, handler)
2442
2471
  {
2443
2472
  let priv = gobj.priv;
2444
2473
  if(!priv || !priv.escape_stack) {
2474
+ log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
2445
2475
  return;
2446
2476
  }
2447
2477
  priv.escape_stack.push({ layer: layer, handler: handler });
@@ -2451,7 +2481,7 @@ function pop_escape(gobj, handler)
2451
2481
  {
2452
2482
  let priv = gobj.priv;
2453
2483
  if(!priv || !priv.escape_stack) {
2454
- return;
2484
+ return; /* not an error: an overlay closing after its shell was torn down */
2455
2485
  }
2456
2486
  let idx = priv.escape_stack.findIndex(e => e.handler === handler);
2457
2487
  if(idx >= 0) {
@@ -2513,9 +2543,18 @@ function drain_overlays(gobj)
2513
2543
  /* Survivors keep their relative order: the stack is a LIFO and a
2514
2544
  * panel that outlives the drain must stay where it was, or Escape
2515
2545
  * would start closing overlays in an order the user never built. */
2546
+ /* The stack is taken whole BEFORE any close runs: an overlay that
2547
+ * vetoes its close registers again (C_YUI_WINDOW), and popping
2548
+ * the live stack would pop that new entry and close it again,
2549
+ * for ever. Such an entry is newer than every survivor, so it
2550
+ * goes above them. */
2551
+ let entries = priv.overlay_stack.splice(0);
2516
2552
  let kept = [];
2517
- while(priv.overlay_stack.length > 0) {
2518
- let entry = priv.overlay_stack.pop();
2553
+ while(entries.length > 0) {
2554
+ let entry = entries.pop();
2555
+ if(entry.dismissed) {
2556
+ continue; // its owner went with an earlier close of this drain
2557
+ }
2519
2558
  if(entry.keep_on_navigate) {
2520
2559
  kept.unshift(entry);
2521
2560
  continue;
@@ -2526,9 +2565,7 @@ function drain_overlays(gobj)
2526
2565
  log_warning(`C_YUI_SHELL: overlay close on navigation failed: ${e}`);
2527
2566
  }
2528
2567
  }
2529
- for(let entry of kept) {
2530
- priv.overlay_stack.push(entry);
2531
- }
2568
+ priv.overlay_stack.unshift(...kept);
2532
2569
  }
2533
2570
 
2534
2571
  /* A URL rewrite moved the entry `st` tags to `hash`. When `st` is a live
@@ -2584,6 +2621,10 @@ function overlay_dismissed(gobj, entry)
2584
2621
  if(!priv || !priv.overlay_stack || !entry) {
2585
2622
  return;
2586
2623
  }
2624
+ /* Marked even when it is no longer on the stack: drain_overlays()
2625
+ * works on a COPY, and an entry whose owner an earlier close of the
2626
+ * same drain already took down must not be closed a second time. */
2627
+ entry.dismissed = true;
2587
2628
  let idx = priv.overlay_stack.indexOf(entry);
2588
2629
  if(idx < 0) {
2589
2630
  /* Already removed by the popstate handler (closed via Back). */
@@ -2817,7 +2858,10 @@ function ac_nav_clicked(gobj, event, kw, src)
2817
2858
  {
2818
2859
  let route = (kw && kw.route) || "";
2819
2860
  if(empty_string(route)) {
2820
- return 0;
2861
+ /* C_YUI_NAV publishes no click for an item without a route:
2862
+ * whoever sent this one is broken. */
2863
+ log_warning(`C_YUI_SHELL: ${event} with no route, from ${gobj_short_name(src)}`);
2864
+ return -1;
2821
2865
  }
2822
2866
 
2823
2867
  /* A click on a section returns to where the user was inside it.
@@ -2947,8 +2991,9 @@ function prune_route(shell_gobj, route)
2947
2991
 
2948
2992
  function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
2949
2993
  {
2950
- let priv = shell_gobj.priv;
2994
+ let priv = shell_gobj && shell_gobj.priv;
2951
2995
  if(!priv) {
2996
+ log_error(`C_YUI_SHELL: yui_shell_set_submenu('${parent_item_id}') — no shell`);
2952
2997
  return -1;
2953
2998
  }
2954
2999
  let nav = find_secondary_nav(priv, parent_item_id);
@@ -3005,8 +3050,12 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
3005
3050
  }
3006
3051
  priv.dynamic_routes[parent_item_id] = new_routes;
3007
3052
 
3008
- /* Push the new items into the nav (rebuilds its DOM in place). */
3053
+ /* Push the new items into the nav (rebuilds its DOM in place), and
3054
+ * re-apply the translator: the rebuilt labels carry their keys as
3055
+ * raw text until somebody translates them (the same policy as the
3056
+ * index view below, and as C_YUI_NODE's projections). */
3009
3057
  gobj_send_event(nav, "EV_SET_ITEMS", {items: items}, shell_gobj);
3058
+ yui_shell_translate(shell_gobj, gobj_read_attr(nav, "$container"));
3010
3059
 
3011
3060
  /* Section-index landing (submenu.index): keep the synthesized
3012
3061
  * target and any mounted index view (a "cards" C_YUI_NAV in the
@@ -3040,18 +3089,21 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
3040
3089
  * Global methods table
3041
3090
  *---------------------------------------------*/
3042
3091
  /***************************************************************
3043
- * EV_CONNECTION_STATE is an OPTIONAL fact: a view that waits for a
3044
- * backend answer subscribes to it by name. An app that subscribed
3045
- * to EVERY event of its shell with one attr (`subscriber`) did not
3046
- * ask for it and does not declare it -- published to it anyway, the
3047
- * event would be an FSM error in the app on every connection edge,
3048
- * and adding it to the shell a breaking change for every such app.
3049
- * So it reaches only the subscribers that declare it. Every other
3050
- * event of the shell goes out as before.
3092
+ * EV_CONNECTION_STATE and EV_ICONS_CHANGED are OPTIONAL facts: a
3093
+ * view that needs one subscribes to it by name. An app that
3094
+ * subscribed to EVERY event of its shell with one attr
3095
+ * (`subscriber`) did not ask for them and does not declare them --
3096
+ * published to it anyway, each would be an FSM error in the app
3097
+ * every time it fires, and adding one to the shell a breaking
3098
+ * change for every such app (7.26.6 did exactly that with
3099
+ * EV_ICONS_CHANGED). So they reach only the subscribers that
3100
+ * declare them. Every other event of the shell goes out as before.
3051
3101
  ***************************************************************/
3102
+ const OPTIONAL_EVENTS = new Set(["EV_CONNECTION_STATE", "EV_ICONS_CHANGED"]);
3103
+
3052
3104
  function mt_publication_pre_filter(gobj, subs, event, kw)
3053
3105
  {
3054
- if(event !== "EV_CONNECTION_STATE") {
3106
+ if(!OPTIONAL_EVENTS.has(event)) {
3055
3107
  return 1;
3056
3108
  }
3057
3109
  let subscriber = subs && subs.subscriber;
@@ -3123,7 +3175,9 @@ function create_gclass(gclass_name)
3123
3175
  * it was written, and called yui_shell_icons_changed). A class name
3124
3176
  * picks its icon up by itself once the rule exists, but a view that
3125
3177
  * DECIDED, at render time, whether a name is an icon at all -- the
3126
- * icon cell of a table -- has to decide again. */
3178
+ * icon cell of a table -- has to decide again. Delivered only to
3179
+ * the subscribers that declare it: see
3180
+ * mt_publication_pre_filter(). */
3127
3181
  ["EV_ICONS_CHANGED", event_flag_t.EVF_OUTPUT_EVENT
3128
3182
  |event_flag_t.EVF_PUBLIC_EVENT
3129
3183
  |event_flag_t.EVF_NO_WARN_SUBS],
@@ -3484,9 +3538,20 @@ function yui_shell_register_event_handler(shell_gobj, event, gclass)
3484
3538
 
3485
3539
  /* Drawer helpers — toggle the off-canvas nav from the outside
3486
3540
  * (e.g. a hamburger button in the toolbar). menu_id is optional. */
3487
- function yui_shell_open_drawer(shell_gobj, menu_id) { open_drawer(shell_gobj, menu_id); }
3488
- function yui_shell_close_drawer(shell_gobj, menu_id) { close_drawer(shell_gobj, menu_id); }
3489
- function yui_shell_toggle_drawer(shell_gobj, menu_id) { toggle_drawer(shell_gobj, menu_id); }
3541
+ function yui_shell_open_drawer(shell_gobj, menu_id)
3542
+ {
3543
+ open_drawer(shell_gobj, menu_id);
3544
+ }
3545
+
3546
+ function yui_shell_close_drawer(shell_gobj, menu_id)
3547
+ {
3548
+ close_drawer(shell_gobj, menu_id);
3549
+ }
3550
+
3551
+ function yui_shell_toggle_drawer(shell_gobj, menu_id)
3552
+ {
3553
+ toggle_drawer(shell_gobj, menu_id);
3554
+ }
3490
3555
 
3491
3556
  /* Escape priority chain — public API used by overlays that the
3492
3557
  * shell does not own (modals from #4, future popups, custom
@@ -3612,7 +3677,7 @@ function yui_shell_set_translator(shell_gobj, t)
3612
3677
  *
3613
3678
  * The division of labour, unchanged: LIBRARY-built DOM is
3614
3679
  * translated through here; APP view gclasses translate their own
3615
- * DOM (they own a `t` — see mount_view).
3680
+ * DOM (they own a `t` — see build_view_gobj).
3616
3681
  *
3617
3682
  * Silent no-op with no shell or no translator: an app that never
3618
3683
  * registered one keeps the previous behaviour instead of losing