@yuneta/gobj-ui 7.26.41 → 7.26.43

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 (66) hide show
  1. package/README.md +510 -78
  2. package/dist/gobj-ui.cjs.js +1120 -326
  3. package/dist/gobj-ui.es.js +1120 -326
  4. package/package.json +1 -1
  5. package/scripts/validate-locales.mjs +971 -177
  6. package/src/c_g6_nodes_tree.js +3 -2
  7. package/src/c_yui_form.js +261 -154
  8. package/src/c_yui_fsm_graph.js +3 -2
  9. package/src/c_yui_gobj_tree_js.js +3 -2
  10. package/src/c_yui_json_graph.js +3 -2
  11. package/src/c_yui_nav.js +43 -28
  12. package/src/c_yui_node.js +51 -7
  13. package/src/c_yui_schema_editor.css +16 -0
  14. package/src/c_yui_schema_editor.js +110 -20
  15. package/src/c_yui_shell.css +4 -1
  16. package/src/c_yui_shell.js +227 -61
  17. package/src/c_yui_treedb_schema.js +3 -2
  18. package/src/c_yui_window.js +373 -62
  19. package/src/c_yui_window_manager.js +80 -8
  20. package/src/escape_taken.js +58 -0
  21. package/src/form_close_asks_for_edits.wiring.test.js +6 -3
  22. package/src/form_json_editor_names.js +3 -1
  23. package/src/form_json_editor_names.wiring.test.js +8 -4
  24. package/src/form_json_expand.wiring.test.js +6 -3
  25. package/src/form_json_field.wiring.test.js +8 -4
  26. package/src/form_label_i18n.wiring.test.js +10 -5
  27. package/src/form_table_edits_ask.wiring.test.js +18 -8
  28. package/src/form_table_rearm.wiring.test.js +13 -5
  29. package/src/form_table_rows.wiring.test.js +489 -0
  30. package/src/form_table_validator.wiring.test.js +8 -4
  31. package/src/form_template_field.wiring.test.js +6 -3
  32. package/src/g6_canvas_tab_order.css +29 -0
  33. package/src/g6_canvas_tab_order.js +41 -9
  34. package/src/g6_canvas_tab_order.wiring.test.js +107 -1
  35. package/src/g6_long_press_clock.test.js +8 -3
  36. package/src/i18n_key_functions.js +81 -27
  37. package/src/i18n_key_functions.test.js +402 -4
  38. package/src/modal_guard_back.wiring.test.js +188 -0
  39. package/src/named_controls.wiring.test.js +323 -19
  40. package/src/nav_cards_helpers.js +9 -4
  41. package/src/nav_item_badge.wiring.test.js +163 -15
  42. package/src/node_nav_events.wiring.test.js +93 -1
  43. package/src/route_map_model.js +59 -10
  44. package/src/route_map_model.test.js +90 -0
  45. package/src/schema_editor_diagram_click.wiring.test.js +277 -0
  46. package/src/schema_editor_openers.wiring.test.js +283 -0
  47. package/src/shell_dialog_names.wiring.test.js +149 -0
  48. package/src/shell_escape_taken.wiring.test.js +142 -0
  49. package/src/shell_focus_trap.js +30 -2
  50. package/src/shell_focus_trap.test.js +90 -6
  51. package/src/shell_modals.js +113 -22
  52. package/src/shell_route_map.js +15 -3
  53. package/src/shell_section_index.js +3 -1
  54. package/src/table_editor_name.wiring.test.js +10 -5
  55. package/src/treedb_column_title.wiring.test.js +8 -4
  56. package/src/treedb_graph_writes.wiring.test.js +6 -3
  57. package/src/treedb_json_drill.wiring.test.js +6 -3
  58. package/src/uplot_add_serie.test.js +6 -3
  59. package/src/uplot_ink.test.js +8 -4
  60. package/src/window_dialog.wiring.test.js +486 -0
  61. package/src/window_dock_band.wiring.test.js +189 -0
  62. package/src/window_layer.wiring.test.js +114 -0
  63. package/src/window_rect_rounding.wiring.test.js +121 -0
  64. package/src/yui_gclass_view.js +16 -1
  65. package/src/yui_tabulator_i18n.js +31 -1
  66. package/src/yui_tabulator_i18n.test.js +46 -0
@@ -126,6 +126,14 @@ function yui_tint(colour) {
126
126
  * - restores focus to whatever element had it before
127
127
  * activation when release() runs.
128
128
  *
129
+ * Only a control that is DRAWN counts: focus() on one that is
130
+ * not (display:none) does nothing. The adaptive dialog's back
131
+ * arrow is the first control of every dialog and is hidden on a
132
+ * laptop: up to 7.26.42 the trap gave it the focus on activation
133
+ * (so the focus stayed outside the dialog), and every Tab after
134
+ * that wrapped to it, did nothing and was prevented -- the
135
+ * keyboard never got into the dialog.
136
+ *
129
137
  * Pure module — no gobj / Yuneta dependencies. The optional
130
138
  * second argument lets callers inject a mock document object
131
139
  * for unit tests.
@@ -135,6 +143,14 @@ function yui_tint(colour) {
135
143
  ***********************************************************************/
136
144
  var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
137
145
  var __trap_stack__ = [];
146
+ function is_drawn(el) {
147
+ if (typeof el.checkVisibility === "function") return el.checkVisibility();
148
+ if (typeof el.getClientRects === "function") return el.getClientRects().length > 0;
149
+ return true;
150
+ }
151
+ function focusables_of($panel) {
152
+ return Array.from($panel.querySelectorAll(FOCUSABLE_SELECTOR)).filter(is_drawn);
153
+ }
138
154
  /***************************************************************
139
155
  * Activate the focus-trap on $panel.
140
156
  *
@@ -152,7 +168,7 @@ function activate_focus_trap_on($panel, doc) {
152
168
  let trap = function(ev) {
153
169
  if (ev.key !== "Tab" && ev.keyCode !== 9) return;
154
170
  if (__trap_stack__[__trap_stack__.length - 1] !== trap) return;
155
- let nodes = $panel.querySelectorAll(FOCUSABLE_SELECTOR);
171
+ let nodes = focusables_of($panel);
156
172
  if (nodes.length === 0) return;
157
173
  let first = nodes[0];
158
174
  let last = nodes[nodes.length - 1];
@@ -169,7 +185,7 @@ function activate_focus_trap_on($panel, doc) {
169
185
  };
170
186
  doc.addEventListener("keydown", trap, true);
171
187
  __trap_stack__.push(trap);
172
- let firstFocusable = $panel.querySelector(FOCUSABLE_SELECTOR);
188
+ let firstFocusable = focusables_of($panel)[0];
173
189
  if (firstFocusable && typeof firstFocusable.focus === "function") firstFocusable.focus();
174
190
  return function release_focus_trap() {
175
191
  if (released) return;
@@ -257,6 +273,51 @@ function bulma_hidden_class(bp) {
257
273
  return "";
258
274
  }
259
275
  //#endregion
276
+ //#region src/escape_taken.js
277
+ /***********************************************************************
278
+ * escape_taken.js
279
+ *
280
+ * Whose is an Escape? The overlay around the focus (a window, the
281
+ * shell's dialog on top) closes with it -- unless what the key was
282
+ * typed in took it first:
283
+ *
284
+ * - a handler used it and said so (`preventDefault()`): Tom
285
+ * Select closing its list, the json editor its search box;
286
+ * - an input method is composing (the key cancels the
287
+ * composition);
288
+ * - the element it was typed in is no longer in the document:
289
+ * an inline editor closed with it. Tabulator cancels a cell
290
+ * edit on Escape by removing the box, and says nothing else
291
+ * -- so this is the only trace the key leaves;
292
+ * - it was typed in a search box that holds text: the browser
293
+ * clears the box with it (a default action, not a
294
+ * preventDefault() anyone can see -- and taking the key would
295
+ * prevent it). An empty one gives it on;
296
+ * - it was typed in a text editor (a textarea, a
297
+ * contenteditable): what is being written there is not lost
298
+ * to a key that also means "stop" inside the editor. The
299
+ * overlay is one Tab away.
300
+ *
301
+ * Pure module: an event in, a boolean out.
302
+ *
303
+ * Copyright (c) 2026, ArtGins.
304
+ * All Rights Reserved.
305
+ ***********************************************************************/
306
+ /***************************************************************
307
+ * True when the Escape `evt` belongs to what it was typed in,
308
+ * and not to the overlay around it.
309
+ ***************************************************************/
310
+ function escape_is_taken(evt) {
311
+ if (!evt) return false;
312
+ if (evt.defaultPrevented || evt.isComposing) return true;
313
+ let target = evt.target;
314
+ if (!target || target.nodeType !== 1) return false;
315
+ if (target.isConnected === false) return true;
316
+ if (target.tagName === "INPUT" && target.type === "search" && target.value) return true;
317
+ if (target.tagName === "TEXTAREA" || target.isContentEditable === true) return true;
318
+ return false;
319
+ }
320
+ //#endregion
260
321
  //#region src/shell_toolbar_helpers.js
261
322
  var TOOLBAR_ACTION_TYPES = [
262
323
  "navigate",
@@ -704,12 +765,42 @@ function paint_badge($badge, value, tone) {
704
765
  * All Rights Reserved.
705
766
  ***********************************************************************/
706
767
  /************************************************************
768
+ * The label of a row is the name of its CONTROL: one rule names
769
+ * an item everywhere.
770
+ *
771
+ * - A menu entry, as the nav names it (c_yui_nav.js item_li):
772
+ * its `name`, else its `aria_label`, else its id.
773
+ * - A toolbar item and a row of its dropdown, as the toolbar
774
+ * names them (c_yui_shell.js build_toolbar_*): its
775
+ * `aria_label` first -- the visible `name` of a toolbar
776
+ * button is often a symbol ("ES/EN") --, then its `name`,
777
+ * then, for an avatar or a connection dot, the library's own
778
+ * key, else its id.
779
+ *
780
+ * A route is no key: it has its own column, and an item with
781
+ * none of these has no label. Up to 7.26.41 a row was labelled
782
+ * `name || wordmark || id || route` -- an entry that declares
783
+ * only an `aria_label` had its id here, the language button read
784
+ * "ES/EN" where its control says "toggle language", and a route
785
+ * was asked of the locales as a key.
786
+ ************************************************************/
787
+ function menu_item_label(it) {
788
+ return it.name || it.aria_label || it.id || "";
789
+ }
790
+ function toolbar_item_label(it) {
791
+ let fallback = it.id || "";
792
+ if (it.type === "avatar") fallback = "user menu";
793
+ else if (it.type === "connection") fallback = "backend connection";
794
+ return it.aria_label || it.name || fallback;
795
+ }
796
+ /************************************************************
707
797
  * One node of the nav map from a declared config item, in
708
798
  * DECLARATION ORDER (never sorted). Recurses into static submenus
709
799
  * and toolbar dropdowns, and merges the LIVE dynamic submenu tabs
710
800
  * (added at runtime via yui_shell_set_submenu) by parent id.
801
+ * `label_of` names it: menu_item_label() or toolbar_item_label().
711
802
  ************************************************************/
712
- function nav_node_from_item(it, index) {
803
+ function nav_node_from_item(it, index, label_of) {
713
804
  if (!it || it.type === "divider" || it.type === "header") return null;
714
805
  let action = it.action || {};
715
806
  let route = it.route || (action.type === "navigate" ? action.route : "") || "";
@@ -722,7 +813,7 @@ function nav_node_from_item(it, index) {
722
813
  }
723
814
  let node = {
724
815
  id: it.id || "",
725
- label: it.name || it.wordmark || it.id || route || "",
816
+ label: label_of(it),
726
817
  icon: it.icon || "",
727
818
  route,
728
819
  event,
@@ -732,14 +823,14 @@ function nav_node_from_item(it, index) {
732
823
  };
733
824
  let sub_items = it.submenu && Array.isArray(it.submenu.items) ? it.submenu.items : action.type === "dropdown" && Array.isArray(action.items) ? action.items : null;
734
825
  if (sub_items) for (let s of sub_items) {
735
- let n = nav_node_from_item(s, index);
826
+ let n = nav_node_from_item(s, index, label_of);
736
827
  if (n) node.children.push(n);
737
828
  }
738
829
  if (it.id && index) for (let r of Object.keys(index)) {
739
830
  let e = index[r];
740
831
  if (e && e.parent_item && e.parent_item.id === it.id && !node.children.some((c) => c.route === r)) node.children.push({
741
832
  id: e.item && e.item.id || "",
742
- label: e.item && e.item.name || r,
833
+ label: e.item ? menu_item_label(e.item) : "",
743
834
  icon: e.item && e.item.icon || "",
744
835
  route: r,
745
836
  event: "",
@@ -855,7 +946,10 @@ function mark_current(groups, current_route) {
855
946
  *
856
947
  * - `nav` walks EVERY declared menu in declaration order: the
857
948
  * `primary` menu contributes its items flat (the common case);
858
- * any other menu contributes a group node labelled by its key.
949
+ * any other menu contributes a group node labelled by its key,
950
+ * as data (`data_label: true`).
951
+ * - a node is labelled as its control is named (menu_item_label(),
952
+ * toolbar_item_label()); a node no item names has label "".
859
953
  * - `other` lists the routes declared only in the route table
860
954
  * (config.shell.routes) that no rendered node covers — root "/",
861
955
  * URL-only action routes, toolbar-less forms. Brand-covered
@@ -890,7 +984,7 @@ function build_nav_map(input) {
890
984
  };
891
985
  continue;
892
986
  }
893
- let n = nav_node_from_item(it, index);
987
+ let n = nav_node_from_item(it, index, toolbar_item_label);
894
988
  if (n) toolbar.push(n);
895
989
  }
896
990
  let nav = [];
@@ -900,13 +994,14 @@ function build_nav_map(input) {
900
994
  if (!m || !Array.isArray(m.items)) continue;
901
995
  let nodes = [];
902
996
  for (let it of m.items) {
903
- let n = nav_node_from_item(it, index);
997
+ let n = nav_node_from_item(it, index, menu_item_label);
904
998
  if (n) nodes.push(n);
905
999
  }
906
1000
  if (menu_id === "primary") nav = nav.concat(nodes);
907
1001
  else if (nodes.length) nav.push({
908
1002
  id: menu_id,
909
1003
  label: menu_id,
1004
+ data_label: true,
910
1005
  icon: "",
911
1006
  route: "",
912
1007
  event: "",
@@ -933,7 +1028,7 @@ function build_nav_map(input) {
933
1028
  let tgt = e && e.target || null;
934
1029
  other.push({
935
1030
  id: e && e.item && e.item.id || "",
936
- label: e && e.item && (e.item.name || e.item.id) || r,
1031
+ label: e && e.item ? menu_item_label(e.item) : "",
937
1032
  icon: e && e.item && e.item.icon || "",
938
1033
  route: r,
939
1034
  event: tgt && tgt.kind === "action" && tgt.event || "",
@@ -1013,7 +1108,7 @@ function section_index_target(menu_id, item) {
1013
1108
  gclass: "C_YUI_NAV",
1014
1109
  kw: {
1015
1110
  menu_id: `index.${menu_id}.${item.id}`,
1016
- nav_label: item.name || item.id || "",
1111
+ nav_label: item.name || item.aria_label || item.id || "",
1017
1112
  menu_items: sub.items,
1018
1113
  layout: "cards",
1019
1114
  level: "secondary"
@@ -1085,7 +1180,7 @@ function secondary_nav_renders(item, layout) {
1085
1180
  * Constants
1086
1181
  ***************************************************************/
1087
1182
  var GCLASS_NAME$22 = "C_YUI_SHELL";
1088
- var __last_shell__ = null;
1183
+ var __live_shells__ = [];
1089
1184
  var __shell_watchers__ = [];
1090
1185
  var __window_z__ = 10;
1091
1186
  var ZONE_IDS = [
@@ -1128,6 +1223,8 @@ var PRIVATE_DATA$22 = {
1128
1223
  item_index: {},
1129
1224
  nav_badges: {},
1130
1225
  badge_status: null,
1226
+ badge_news: [],
1227
+ badge_news_closing: false,
1131
1228
  dynamic_items: {},
1132
1229
  section_pos: {},
1133
1230
  route_mru: [],
@@ -1166,14 +1263,14 @@ var __gclass__$22 = null;
1166
1263
  function mt_create$22(gobj) {
1167
1264
  const subscriber = gobj_read_pointer_attr(gobj, "subscriber");
1168
1265
  if (subscriber) gobj_subscribe_event(gobj, null, {}, subscriber);
1169
- __last_shell__ = gobj;
1266
+ __live_shells__.push(gobj);
1170
1267
  build_ui$19(gobj);
1171
1268
  tell_shell_watchers(gobj);
1172
1269
  }
1173
1270
  /***************************************************************
1174
1271
  * Framework Method: Start
1175
1272
  ***************************************************************/
1176
- function mt_start$20(gobj) {
1273
+ function mt_start$21(gobj) {
1177
1274
  let config = gobj_read_attr(gobj, "config") || {};
1178
1275
  let priv = gobj.priv;
1179
1276
  if (!validate_config(config)) {
@@ -1277,6 +1374,7 @@ function mt_start$20(gobj) {
1277
1374
  priv.keydown_handler = (ev) => {
1278
1375
  if (ev.key !== "Escape" && ev.keyCode !== 27) return;
1279
1376
  if (priv.escape_stack.length === 0) return;
1377
+ if (escape_is_taken(ev)) return;
1280
1378
  let top = priv.escape_stack[priv.escape_stack.length - 1];
1281
1379
  ev.preventDefault();
1282
1380
  ev.stopPropagation();
@@ -1352,7 +1450,8 @@ function mt_stop$20(gobj) {
1352
1450
  ***************************************************************/
1353
1451
  function mt_destroy$22(gobj) {
1354
1452
  close_toolbar_dropdown(gobj);
1355
- if (__last_shell__ === gobj) __last_shell__ = null;
1453
+ let live_idx = __live_shells__.indexOf(gobj);
1454
+ if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
1356
1455
  let $container = gobj_read_attr(gobj, "$container");
1357
1456
  if ($container && $container.parentNode) $container.parentNode.removeChild($container);
1358
1457
  tell_shell_watchers(gobj);
@@ -1735,7 +1834,7 @@ function instantiate_menus(gobj, config) {
1735
1834
  let nav = instantiate_nav_in_zone(gobj, {
1736
1835
  items: sub.items,
1737
1836
  render: { [zone_id]: render_cfg }
1738
- }, sub_menu_id, zone_id, "secondary", item.name || "");
1837
+ }, sub_menu_id, zone_id, "secondary", item.name || item.aria_label || item.id || "");
1739
1838
  let $c = gobj_read_attr(nav, "$container");
1740
1839
  if ($c) $c.classList.add("is-hidden");
1741
1840
  }
@@ -2103,25 +2202,24 @@ function build_toolbar_action_item(gobj, it) {
2103
2202
  },
2104
2203
  text_node(it.name)
2105
2204
  ]);
2106
- let aria_key = it.aria_label || it.name || it.id || "";
2107
- let i18n_aria = it.aria_label || it.name;
2205
+ let name_key = it.aria_label || it.name || it.id || "";
2108
2206
  let btn_attrs = {
2109
2207
  class: "navbar-item yui-toolbar-item is-unselectable",
2110
2208
  type: "button",
2111
2209
  "data-toolbar-item-id": it.id || "",
2112
- "aria-label": aria_key
2210
+ "aria-label": name_key
2113
2211
  };
2114
- if (i18n_aria) btn_attrs["data-i18n-aria-label"] = i18n_aria;
2212
+ if (name_key) btn_attrs["data-i18n-aria-label"] = name_key;
2115
2213
  if ((it.action && it.action.type || "") === "dropdown") {
2116
2214
  btn_attrs["aria-haspopup"] = "menu";
2117
2215
  btn_attrs["aria-expanded"] = "false";
2118
2216
  }
2119
- let tip = it.tooltip || i18n_aria;
2217
+ let tip = it.tooltip || name_key;
2120
2218
  if (tip) {
2121
2219
  btn_attrs.title = tip;
2122
2220
  btn_attrs["data-i18n-title"] = tip;
2123
2221
  }
2124
- if (badge && !empty_string(aria_key)) name_control_with_badge(btn_attrs, badge);
2222
+ if (badge && !empty_string(name_key)) name_control_with_badge(btn_attrs, badge);
2125
2223
  let link = toolbar_link_attrs(it);
2126
2224
  if (link) {
2127
2225
  delete btn_attrs.type;
@@ -2205,21 +2303,20 @@ function build_toolbar_brand_item(gobj, it) {
2205
2303
  ************************************************************/
2206
2304
  function build_toolbar_avatar_item(gobj, it) {
2207
2305
  let priv = gobj.priv;
2208
- const aria_key = it.aria_label || it.name || it.id || "user menu";
2209
- const i18n_aria = it.aria_label || it.name || "user menu";
2306
+ const name_key = it.aria_label || it.name || "user menu";
2210
2307
  let action_type = it.action && it.action.type || "";
2211
2308
  let attrs = {
2212
2309
  class: "navbar-item yui-toolbar-item yui-toolbar-avatar is-unselectable",
2213
2310
  type: "button",
2214
2311
  "data-toolbar-item-id": it.id || "",
2215
- "aria-label": aria_key,
2216
- "data-i18n-aria-label": i18n_aria
2312
+ "aria-label": name_key,
2313
+ "data-i18n-aria-label": name_key
2217
2314
  };
2218
2315
  if (action_type === "dropdown") {
2219
2316
  attrs["aria-haspopup"] = "menu";
2220
2317
  attrs["aria-expanded"] = "false";
2221
2318
  }
2222
- let tip = it.tooltip || i18n_aria;
2319
+ let tip = it.tooltip || name_key;
2223
2320
  if (tip) {
2224
2321
  attrs.title = tip;
2225
2322
  attrs["data-i18n-title"] = tip;
@@ -2262,13 +2359,17 @@ function refresh_avatars(gobj) {
2262
2359
  * Wire an optional secondary (right-click) action on a
2263
2360
  * toolbar item. Same action shape as `action`; used e.g. by
2264
2361
  * the connection indicator to open a dev panel on right-click.
2362
+ * The item goes along whole, with the secondary action in place
2363
+ * of its own: a menu it opens is named as its trigger is (up to
2364
+ * 7.26.42 it went as `{id, action}`, and the menu was named by
2365
+ * the raw id whatever the item declared).
2265
2366
  ************************************************************/
2266
2367
  function attach_context_action(gobj, $item, it) {
2267
2368
  if (!it || !it.context_action) return;
2268
2369
  $item.addEventListener("contextmenu", (ev) => {
2269
2370
  ev.preventDefault();
2270
2371
  handle_toolbar_action(gobj, {
2271
- id: it.id,
2372
+ ...it,
2272
2373
  action: it.context_action
2273
2374
  }, $item);
2274
2375
  });
@@ -2282,16 +2383,15 @@ function attach_context_action(gobj, $item, it) {
2282
2383
  ************************************************************/
2283
2384
  function build_toolbar_connection_item(gobj, it) {
2284
2385
  let priv = gobj.priv;
2285
- const aria_key = it.aria_label || it.name || it.id || "backend connection";
2286
- const i18n_aria = it.aria_label || it.name || "backend connection";
2386
+ const name_key = it.aria_label || it.name || "backend connection";
2287
2387
  let attrs = {
2288
2388
  class: "navbar-item yui-toolbar-item yui-toolbar-conn is-unselectable is-disconnected",
2289
2389
  type: "button",
2290
2390
  "data-toolbar-item-id": it.id || "",
2291
- "aria-label": aria_key,
2292
- "data-i18n-aria-label": i18n_aria
2391
+ "aria-label": name_key,
2392
+ "data-i18n-aria-label": name_key
2293
2393
  };
2294
- let tip = it.tooltip || i18n_aria;
2394
+ let tip = it.tooltip || name_key;
2295
2395
  if (tip) {
2296
2396
  attrs.title = tip;
2297
2397
  attrs["data-i18n-title"] = tip;
@@ -2389,13 +2489,12 @@ function toggle_toolbar_dropdown(gobj, item, action, $trigger) {
2389
2489
  function open_toolbar_dropdown(gobj, item, action, $trigger) {
2390
2490
  let priv = gobj.priv;
2391
2491
  if (!priv || !priv.layers || !priv.layers.popup) return;
2392
- const aria_key = item && (item.aria_label || item.name || item.id) || "menu";
2393
- const i18n_aria = item && (item.aria_label || item.name) || "menu";
2492
+ const name_key = item && (item.aria_label || item.name || (classify_toolbar_item(item) === "avatar" ? "user menu" : item.id)) || "menu";
2394
2493
  let $panel = createElement2(["div", {
2395
2494
  class: "yui-toolbar-dropdown-panel",
2396
2495
  role: "menu",
2397
- "aria-label": aria_key,
2398
- "data-i18n-aria-label": i18n_aria,
2496
+ "aria-label": name_key,
2497
+ "data-i18n-aria-label": name_key,
2399
2498
  "data-toolbar-dropdown-for": item && item.id || ""
2400
2499
  }]);
2401
2500
  let raw_items = is_array(action.items) ? action.items : [];
@@ -2528,20 +2627,19 @@ function build_dropdown_row(gobj, sub, idx) {
2528
2627
  "aria-hidden": "true"
2529
2628
  }]
2530
2629
  ]);
2531
- let aria_key = sub.aria_label || sub.name || sub.id || "";
2532
- let i18n_aria = sub.aria_label || sub.name;
2630
+ let name_key = sub.aria_label || sub.name || sub.id || "";
2533
2631
  let attrs = {
2534
2632
  class: "yui-toolbar-dropdown-item" + (sub.selected ? " is-selected" : ""),
2535
2633
  type: "button",
2536
2634
  role: "menuitemradio",
2537
2635
  "aria-checked": sub.selected ? "true" : "false",
2538
2636
  "data-dropdown-item-id": sub.id || "",
2539
- "aria-label": aria_key
2637
+ "aria-label": name_key
2540
2638
  };
2541
- if (i18n_aria) {
2542
- attrs["data-i18n-aria-label"] = i18n_aria;
2543
- attrs.title = i18n_aria;
2544
- attrs["data-i18n-title"] = i18n_aria;
2639
+ if (name_key) {
2640
+ attrs["data-i18n-aria-label"] = name_key;
2641
+ attrs.title = name_key;
2642
+ attrs["data-i18n-title"] = name_key;
2545
2643
  }
2546
2644
  let $btn = createElement2([
2547
2645
  "button",
@@ -2963,11 +3061,23 @@ function shell_navs(gobj) {
2963
3061
  * `name_key` is the key of the control's name; the phrase is a
2964
3062
  * key of its own, so a language orders and punctuates it its
2965
3063
  * way. Said once: a live region needs no re-translation.
2966
- ************************************************************/
2967
- function announce_badge(gobj, name_key, text) {
2968
- let priv = gobj.priv;
2969
- let $status = priv.badge_status;
2970
- if (!$status) {
3064
+ *
3065
+ * `source` names the badge ("toolbar:<id>", "nav:<id>"). Every
3066
+ * change of ONE turn of the loop is said in ONE message, a line
3067
+ * of the region each, in the order they came; a badge that moves
3068
+ * twice in the turn says its last count. Up to 7.26.41 each
3069
+ * change replaced the region's text, and a reader hears the
3070
+ * region as it is when the turn is over: of two changes in one
3071
+ * action (a feed that updates the toolbar's count and the menu
3072
+ * entry's, which is what a count is for) only the second was
3073
+ * ever said. The turn is closed by EV_CLOSE_BADGE_NEWS, posted to
3074
+ * the shell by its first change: gobj_post_event() delivers it on
3075
+ * the next turn, through the machine -- a deferral, not a time.
3076
+ ************************************************************/
3077
+ function announce_badge(gobj, name_key, text, source) {
3078
+ let priv = gobj.priv;
3079
+ if (gobj_is_destroying(gobj)) return;
3080
+ if (!priv.badge_status) {
2971
3081
  log_error(`C_YUI_SHELL: no live region to say badge '${name_key}': ${text}`);
2972
3082
  return;
2973
3083
  }
@@ -2976,10 +3086,60 @@ function announce_badge(gobj, name_key, text) {
2976
3086
  const tr = priv.translator;
2977
3087
  message = tr("{{name}}, {{n}}", {
2978
3088
  name: tr(name_key),
2979
- n: text
3089
+ n: text,
3090
+ interpolation: { escapeValue: false }
2980
3091
  });
2981
3092
  } else message = `${name_key}, ${text}`;
2982
- $status.textContent = message;
3093
+ let news = priv.badge_news.find((n) => n.source === source);
3094
+ if (news) news.message = message;
3095
+ else priv.badge_news.push({
3096
+ source,
3097
+ message
3098
+ });
3099
+ write_badge_news(gobj);
3100
+ if (priv.badge_news_closing) return;
3101
+ if (gobj_post_event(gobj, "EV_CLOSE_BADGE_NEWS", {}, gobj) < 0) {
3102
+ priv.badge_news = [];
3103
+ return;
3104
+ }
3105
+ priv.badge_news_closing = true;
3106
+ }
3107
+ /************************************************************
3108
+ * A badge whose count went away in the turn it changed: what
3109
+ * this turn said of it is no news any more -- the badge shows
3110
+ * nothing -- and is taken out of the message.
3111
+ ************************************************************/
3112
+ function forget_badge_news(gobj, source) {
3113
+ let priv = gobj.priv;
3114
+ let idx = priv.badge_news.findIndex((n) => n.source === source);
3115
+ if (idx < 0) return;
3116
+ priv.badge_news.splice(idx, 1);
3117
+ write_badge_news(gobj);
3118
+ }
3119
+ /************************************************************
3120
+ * The live region holds the message of this turn: a line per
3121
+ * change, so a reader separates them without a punctuation of
3122
+ * ours, and two controls of one name with one count say it once.
3123
+ *
3124
+ * Written whole, and with new nodes, even when it reads the same:
3125
+ * the callers filter what is no news, and a count that went away
3126
+ * and came back IS news -- a new text node is a change a reader
3127
+ * announces.
3128
+ ************************************************************/
3129
+ function write_badge_news(gobj) {
3130
+ let priv = gobj.priv;
3131
+ let said = [];
3132
+ let $lines = [];
3133
+ for (let news of priv.badge_news) {
3134
+ if (said.includes(news.message)) continue;
3135
+ said.push(news.message);
3136
+ $lines.push(createElement2([
3137
+ "div",
3138
+ { class: "SHELL_BADGE_NEWS" },
3139
+ text_node(news.message)
3140
+ ]));
3141
+ }
3142
+ priv.badge_status.replaceChildren(...$lines);
2983
3143
  }
2984
3144
  /************************************************************
2985
3145
  * A shell was built (mt_create) or is being destroyed
@@ -3052,6 +3212,19 @@ function ac_back_wait_timeout(gobj, event, kw, src) {
3052
3212
  return 0;
3053
3213
  }
3054
3214
  /************************************************************
3215
+ * The turn in which badges changed is over (posted by the first
3216
+ * change, announce_badge()): the message in the live region is
3217
+ * complete, and a reader hears it as it stands. The next change
3218
+ * starts a message of its own -- added to this one, it would say
3219
+ * again what was already said.
3220
+ ************************************************************/
3221
+ function ac_close_badge_news(gobj, event, kw, src) {
3222
+ let priv = gobj.priv;
3223
+ priv.badge_news = [];
3224
+ priv.badge_news_closing = false;
3225
+ return 0;
3226
+ }
3227
+ /************************************************************
3055
3228
  * Drawer backdrop click on a C_YUI_NAV child: the nav publishes
3056
3229
  * this so the shell can close the drawer through the canonical
3057
3230
  * flow (DOM + focus-trap + escape-stack pop) instead of mutating
@@ -3099,7 +3272,7 @@ function mt_publication_pre_filter(gobj, subs, event, kw) {
3099
3272
  }
3100
3273
  var gmt$22 = {
3101
3274
  mt_create: mt_create$22,
3102
- mt_start: mt_start$20,
3275
+ mt_start: mt_start$21,
3103
3276
  mt_stop: mt_stop$20,
3104
3277
  mt_destroy: mt_destroy$22,
3105
3278
  mt_publication_pre_filter
@@ -3129,12 +3302,18 @@ function create_gclass$22(gclass_name) {
3129
3302
  "EV_BACK_WAIT_TIMEOUT",
3130
3303
  ac_back_wait_timeout,
3131
3304
  null
3305
+ ],
3306
+ [
3307
+ "EV_CLOSE_BADGE_NEWS",
3308
+ ac_close_badge_news,
3309
+ null
3132
3310
  ]
3133
3311
  ]]];
3134
3312
  const event_types = [
3135
3313
  ["EV_NAV_CLICKED", 0],
3136
3314
  ["EV_DRAWER_CLOSE_REQUESTED", 0],
3137
3315
  ["EV_BACK_WAIT_TIMEOUT", 0],
3316
+ ["EV_CLOSE_BADGE_NEWS", 0],
3138
3317
  ["EV_NAV_ITEM_CLOSE", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_PUBLIC_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
3139
3318
  ["EV_ROUTE_REQUESTED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_PUBLIC_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
3140
3319
  ["EV_ROUTE_CHANGED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_PUBLIC_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
@@ -3260,9 +3439,9 @@ function yui_shell_previous_route(shell_gobj) {
3260
3439
  /************************************************************
3261
3440
  * Resolve the shell that governs `gobj`: the nearest
3262
3441
  * C_YUI_SHELL ancestor, else the last shell created on the
3263
- * page (apps have exactly one). Null when no shell exists —
3264
- * callers must degrade loudly (shell_modals logs a warning
3265
- * and resolves the safe default).
3442
+ * page that is still alive (apps have exactly one). Null when
3443
+ * no shell exists — callers must degrade loudly (shell_modals
3444
+ * logs a warning and resolves the safe default).
3266
3445
  ************************************************************/
3267
3446
  function yui_shell_of(gobj) {
3268
3447
  let g = gobj;
@@ -3270,7 +3449,7 @@ function yui_shell_of(gobj) {
3270
3449
  if (gobj_gclass_name(g) === GCLASS_NAME$22) return g;
3271
3450
  g = gobj_parent(g);
3272
3451
  }
3273
- return __last_shell__;
3452
+ return __live_shells__.length > 0 ? __live_shells__[__live_shells__.length - 1] : null;
3274
3453
  }
3275
3454
  /************************************************************
3276
3455
  * The DOM where a C_YUI_WINDOW lives when its host names no
@@ -3286,6 +3465,16 @@ function yui_shell_window_layer(shell_gobj) {
3286
3465
  return priv.window_layer || priv.layers && priv.layers.overlay || null;
3287
3466
  }
3288
3467
  /************************************************************
3468
+ * The DOM where a MODAL C_YUI_WINDOW lives when its host names
3469
+ * no `$parent`: the shell's dialog layer, with the dialogs of
3470
+ * shell_modals.js -- above the drawer, the dock and every other
3471
+ * window, below the toasts. Null with no shell.
3472
+ ************************************************************/
3473
+ function yui_shell_modal_layer(shell_gobj) {
3474
+ if (!shell_gobj || !shell_gobj.priv || !shell_gobj.priv.layers) return null;
3475
+ return shell_gobj.priv.layers.modal || null;
3476
+ }
3477
+ /************************************************************
3289
3478
  * Put a window on top of the others: the next number of ONE
3290
3479
  * counter, the same for a window of the dock and for a floating
3291
3480
  * one.
@@ -3608,8 +3797,8 @@ function yui_shell_set_toolbar_item_badge(shell_gobj, item_id, value, tone) {
3608
3797
  let now = badge_text(value);
3609
3798
  if (now && now !== before) {
3610
3799
  let $item = $badge.closest("[data-toolbar-item-id]");
3611
- announce_badge(shell_gobj, $item && $item.getAttribute("data-i18n-aria-label") || item_id, now);
3612
- }
3800
+ announce_badge(shell_gobj, $item && $item.getAttribute("data-i18n-aria-label") || item_id, now, `toolbar:${item_id}`);
3801
+ } else if (!now) forget_badge_news(shell_gobj, `toolbar:${item_id}`);
3613
3802
  }
3614
3803
  /************************************************************
3615
3804
  * Set (or clear) the badge of a MENU item — the twin of
@@ -3658,7 +3847,8 @@ function yui_shell_set_nav_item_badge(shell_gobj, item_id, value, tone) {
3658
3847
  badge_tone: tone
3659
3848
  }, shell_gobj);
3660
3849
  let now = badge_text(badge);
3661
- if (now && now !== before) announce_badge(shell_gobj, item.name || item_id, now);
3850
+ if (now && now !== before) announce_badge(shell_gobj, item.name || item.aria_label || item_id, now, `nav:${item_id}`);
3851
+ else if (!now) forget_badge_news(shell_gobj, `nav:${item_id}`);
3662
3852
  }
3663
3853
  /************************************************************
3664
3854
  * Programmatic close of any open toolbar dropdown. Useful for
@@ -3709,6 +3899,14 @@ function modal_layer(shell) {
3709
3899
  let priv = shell.priv;
3710
3900
  return priv && priv.layers && priv.layers.modal;
3711
3901
  }
3902
+ var __opened_by_shell__ = /* @__PURE__ */ new WeakMap();
3903
+ function note_opened(shell) {
3904
+ __opened_by_shell__.set(shell, opened_count(shell) + 1);
3905
+ }
3906
+ function opened_count(shell) {
3907
+ return __opened_by_shell__.get(shell) || 0;
3908
+ }
3909
+ var __dialog_seq__ = 0;
3712
3910
  function yui_shell_popup_layer(shell) {
3713
3911
  if (!shell) return null;
3714
3912
  let priv = shell.priv;
@@ -3843,18 +4041,43 @@ function yui_shell_show_modal(shell, content, opts) {
3843
4041
  log_warning("yui_shell_show_modal: shell has no modal layer");
3844
4042
  return { close: () => {} };
3845
4043
  }
4044
+ let label_id = `yui-modal-${++__dialog_seq__}`;
3846
4045
  let inner = typeof content === "string" ? [
3847
4046
  "div",
3848
4047
  { class: "box" },
3849
4048
  [[
3850
4049
  "p",
3851
- { i18n: content },
4050
+ {
4051
+ class: "MODAL_MESSAGE",
4052
+ id: `${label_id}-msg`,
4053
+ i18n: content
4054
+ },
3852
4055
  content
3853
4056
  ]]
3854
4057
  ] : null;
3855
4058
  let dialog = !!(opts && opts.dialog);
3856
4059
  let title = opts && opts.title || "";
3857
4060
  let title_prefix = opts && opts.title_prefix || "";
4061
+ let title_halves = (title_prefix ? [[
4062
+ "span",
4063
+ {
4064
+ class: "MODAL_TITLE_PREFIX",
4065
+ id: `${label_id}-prefix`
4066
+ },
4067
+ text_node(title_prefix)
4068
+ ]] : []).concat(title ? [[
4069
+ "span",
4070
+ {
4071
+ class: "MODAL_TITLE_KIND",
4072
+ id: `${label_id}-kind`,
4073
+ i18n: title
4074
+ },
4075
+ text_node(title)
4076
+ ]] : []);
4077
+ let label_ids = [];
4078
+ if (title_prefix) label_ids.push(`${label_id}-prefix`);
4079
+ if (title) label_ids.push(`${label_id}-kind`);
4080
+ if (label_ids.length === 0 && inner) label_ids.push(`${label_id}-msg`);
3858
4081
  let with_close = !(opts && opts.with_close_button === false);
3859
4082
  let modal_children;
3860
4083
  if (dialog) {
@@ -3880,18 +4103,7 @@ function yui_shell_show_modal(shell, content, opts) {
3880
4103
  [
3881
4104
  "span",
3882
4105
  { class: "MODAL_TITLE yui-dialog-title" },
3883
- (title_prefix ? [[
3884
- "span",
3885
- { class: "MODAL_TITLE_PREFIX" },
3886
- text_node(title_prefix)
3887
- ]] : []).concat(title ? [[
3888
- "span",
3889
- {
3890
- class: "MODAL_TITLE_KIND",
3891
- i18n: title
3892
- },
3893
- text_node(title)
3894
- ]] : [])
4106
+ title_halves
3895
4107
  ],
3896
4108
  [
3897
4109
  "button",
@@ -3919,6 +4131,11 @@ function yui_shell_show_modal(shell, content, opts) {
3919
4131
  { class: "MODAL_CONTENT modal-content" },
3920
4132
  inner ? [inner] : []
3921
4133
  ]];
4134
+ if (title_halves.length > 0) modal_children.unshift([
4135
+ "span",
4136
+ { class: "MODAL_TITLE is-sr-only" },
4137
+ title_halves
4138
+ ]);
3922
4139
  if (with_close) modal_children.push(["button", {
3923
4140
  class: "MODAL_CLOSE modal-close is-large",
3924
4141
  title: t("close"),
@@ -3929,16 +4146,20 @@ function yui_shell_show_modal(shell, content, opts) {
3929
4146
  }
3930
4147
  let logical = opts && opts.logical_class || "";
3931
4148
  let wide = !!(opts && opts.wide);
4149
+ let modal_attrs = {
4150
+ class: "MODAL" + (logical ? " " + logical : "") + " modal yui-modal" + (dialog ? " yui-dialog" : "") + (dialog && wide ? " yui-dialog-wide" : "") + " is-active",
4151
+ role: "dialog",
4152
+ "aria-modal": "true"
4153
+ };
4154
+ if (label_ids.length > 0) modal_attrs["aria-labelledby"] = label_ids.join(" ");
4155
+ else log_warning(`yui_shell_show_modal: a dialog with no title and no message has no name for a reader` + (logical ? ` (${logical})` : "") + `: give it opts.title`);
3932
4156
  let $modal = createElement2([
3933
4157
  "div",
3934
- {
3935
- class: "MODAL" + (logical ? " " + logical : "") + " modal yui-modal" + (dialog ? " yui-dialog" : "") + (dialog && wide ? " yui-dialog-wide" : "") + " is-active",
3936
- role: "dialog",
3937
- "aria-modal": "true"
3938
- },
4158
+ modal_attrs,
3939
4159
  modal_children
3940
4160
  ]);
3941
4161
  $layer.appendChild($modal);
4162
+ note_opened(shell);
3942
4163
  if (!inner && content && typeof content.appendChild !== "undefined") (dialog ? $modal.querySelector(".yui-dialog-body") : $modal.querySelector(".modal-content")).appendChild(content);
3943
4164
  maybe_apply_translator($modal, opts);
3944
4165
  let closed = false;
@@ -3967,6 +4188,7 @@ function yui_shell_show_modal(shell, content, opts) {
3967
4188
  let guarded_close = function(on_veto) {
3968
4189
  if (closed) return;
3969
4190
  let allow = true;
4191
+ let opened_before = opened_count(shell);
3970
4192
  if (opts && typeof opts.before_close === "function") try {
3971
4193
  allow = opts.before_close();
3972
4194
  } catch (e) {
@@ -3974,7 +4196,20 @@ function yui_shell_show_modal(shell, content, opts) {
3974
4196
  allow = true;
3975
4197
  }
3976
4198
  if (allow && typeof allow.then === "function") {
3977
- if (typeof on_veto === "function") allow.then(on_veto, on_veto);
4199
+ let vetoed = function() {
4200
+ if (typeof on_veto === "function") on_veto();
4201
+ };
4202
+ allow.then(function(answer) {
4203
+ if (answer === true) {
4204
+ do_close();
4205
+ return;
4206
+ }
4207
+ if (answer === void 0 && !closed && opened_count(shell) === opened_before) log_warning("yui_shell_show_modal: before_close settled with undefined and asked nothing: the modal stays open (only true closes it)");
4208
+ vetoed();
4209
+ }, function(e) {
4210
+ log_warning(`yui_shell_show_modal: before_close rejected: ${e}`);
4211
+ vetoed();
4212
+ });
3978
4213
  return;
3979
4214
  }
3980
4215
  if (allow === false) {
@@ -4077,10 +4312,12 @@ function build_dialog(shell, message, buttons, opts) {
4077
4312
  "aria-hidden": "true"
4078
4313
  }]]
4079
4314
  ]];
4315
+ let label_id = `yui-confirm-${++__dialog_seq__}`;
4080
4316
  if (!empty_string(title)) $card_children.push([
4081
4317
  "p",
4082
4318
  {
4083
4319
  class: "CONFIRM_TITLE yui-confirm-title has-text-centered",
4320
+ id: `${label_id}-title`,
4084
4321
  i18n: title
4085
4322
  },
4086
4323
  text_node(title)
@@ -4093,21 +4330,28 @@ function build_dialog(shell, message, buttons, opts) {
4093
4330
  "data-i18n-aria-label": "close"
4094
4331
  }], [
4095
4332
  "section",
4096
- { class: "CONFIRM_BODY modal-card-body has-text-centered" },
4333
+ {
4334
+ class: "CONFIRM_BODY modal-card-body has-text-centered",
4335
+ id: `${label_id}-body`
4336
+ },
4097
4337
  $body_children
4098
4338
  ], [
4099
4339
  "footer",
4100
4340
  { class: "CONFIRM_FOOT modal-card-foot" },
4101
4341
  $footer_children
4102
4342
  ]);
4103
- let logical = opts && opts.logical_class ? " " + opts.logical_class : "";
4343
+ let confirm_attrs = {
4344
+ class: `CONFIRM${opts && opts.logical_class ? " " + opts.logical_class : ""} modal yui-modal yui-confirm is-active is-${type}`,
4345
+ role: "dialog",
4346
+ "aria-modal": "true"
4347
+ };
4348
+ if (!empty_string(title)) {
4349
+ confirm_attrs["aria-labelledby"] = `${label_id}-title`;
4350
+ confirm_attrs["aria-describedby"] = `${label_id}-body`;
4351
+ } else confirm_attrs["aria-labelledby"] = `${label_id}-body`;
4104
4352
  let $modal = createElement2([
4105
4353
  "div",
4106
- {
4107
- class: `CONFIRM${logical} modal yui-modal yui-confirm is-active is-${type}`,
4108
- role: "dialog",
4109
- "aria-modal": "true"
4110
- },
4354
+ confirm_attrs,
4111
4355
  [["div", { class: "CONFIRM_BACKDROP modal-background" }], [
4112
4356
  "div",
4113
4357
  { class: "CONFIRM_CARD modal-card" },
@@ -4115,6 +4359,7 @@ function build_dialog(shell, message, buttons, opts) {
4115
4359
  ]]
4116
4360
  ]);
4117
4361
  $layer.appendChild($modal);
4362
+ note_opened(shell);
4118
4363
  maybe_apply_translator($modal, opts);
4119
4364
  return new Promise((resolve) => {
4120
4365
  let resolved = false;
@@ -4249,6 +4494,30 @@ function yui_shell_confirm_yesnocancel(shell, message, opts) {
4249
4494
  *
4250
4495
  * Window - position fixed
4251
4496
  *
4497
+ * A window is a DIALOG for the keyboard and for a reader:
4498
+ *
4499
+ * - it says so (`role="dialog"`) and is named by its title
4500
+ * (`aria-labelledby` on its two halves, the kind half carrying
4501
+ * its key, so the name changes language with it);
4502
+ * - when it starts in answer to the reader (a press, a key) it
4503
+ * takes the focus (`focus`: an element, a selector, a number;
4504
+ * by default the window itself, which is focusable with
4505
+ * tabindex=-1) -- not one the app restores on its own at start
4506
+ * up -- and when it goes it gives the focus back to where it
4507
+ * came from, if the focus was in it;
4508
+ * - Escape closes it (`keyboard`) the way its ✕ does, through
4509
+ * EV_CLOSE_WINDOW, so EV_WINDOW_TO_CLOSE can still veto or
4510
+ * ask; not an Escape that what it was typed in took first
4511
+ * (escape_is_taken());
4512
+ * - a `modal` one blocks the rest of the app: it hangs over a
4513
+ * backdrop in the shell's dialog layer (above the dock, the
4514
+ * drawer, every other window), a press outside it does
4515
+ * nothing, Tab stays inside (activate_focus_trap_on(), the
4516
+ * trap of the shell's dialogs), and it never goes to the dock.
4517
+ *
4518
+ * Up to 7.26.42 `focus`, `modal` and `keyboard` were declared and
4519
+ * did nothing.
4520
+ *
4252
4521
  * Copyright (c) 2025-2026, ArtGins.
4253
4522
  * All Rights Reserved.
4254
4523
  ***********************************************************************/
@@ -4261,6 +4530,10 @@ var WC_MAX = "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><rect x=\"3.3\" y=
4261
4530
  var WC_RESTORE = "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><rect x=\"5.2\" y=\"3\" width=\"7.8\" height=\"7.8\" rx=\"1.3\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.4\"/><rect x=\"3\" y=\"5.2\" width=\"7.8\" height=\"7.8\" rx=\"1.3\" fill=\"var(--bulma-scheme-main)\" stroke=\"currentColor\" stroke-width=\"1.4\"/></svg>";
4262
4531
  var WC_CLOSE = "<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M4 4 L12 12 M12 4 L4 12\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/></svg>";
4263
4532
  var MOBILE_MAX = 768;
4533
+ var DOCK_INSET_TOP = "var(--yui-dock-inset-top, 0px)";
4534
+ var DOCK_INSET_BOTTOM = "var(--yui-dock-inset-bottom, 0px)";
4535
+ var MODAL_WINDOW_Z = 40;
4536
+ var __title_seq__ = 0;
4264
4537
  /***************************************************************
4265
4538
  * Data
4266
4539
  ***************************************************************/
@@ -4291,9 +4564,9 @@ var attrs_table$21 = [
4291
4564
  SDATA(data_type_t.DTP_STRING, "title_prefix", 0, "", "Optional DATA half of the title (a topic/service/marker name), shown before `title` and never translated. Use it instead of composing `${name} · ${t(key)}` into `title`, which cannot re-translate"),
4292
4565
  SDATA(data_type_t.DTP_STRING, "title", 0, "", "Window title, an i18n KEY: painted in the title bar (unless `header` overrides it) and on the dock chip. Pass the key, not t(key), or it cannot re-translate"),
4293
4566
  SDATA(data_type_t.DTP_STRING, "icon", 0, "", "Window icon (by window type), leading the title bar and the dock chip: a yi-* class name or inline SVG"),
4294
- SDATA(data_type_t.DTP_POINTER, "focus", 0, null, "NOT implemented yet: would bring focus to the element, a number or a selector"),
4295
- SDATA(data_type_t.DTP_BOOLEAN, "modal", 0, false, "NOT implemented yet: would enable modal mode"),
4296
- SDATA(data_type_t.DTP_BOOLEAN, "keyboard", 0, true, "NOT implemented yet: would close the window on ESC (Escape does nothing today)"),
4567
+ SDATA(data_type_t.DTP_POINTER, "focus", 0, null, "What takes the focus when the window starts in answer to the reader (a press, a key; a window the app restores on its own leaves the focus in the page, a modal one takes it always): an element of the window, a CSS selector looked up in it, or a number (the n-th control of the body, from 0). Null: the window itself. The focus goes back where it came from when the window goes, if it was in the window"),
4568
+ SDATA(data_type_t.DTP_BOOLEAN, "modal", 0, false, "Block the rest of the app while the window is open: a backdrop in the shell's dialog layer (above the dock, the drawer, every other window), a press outside does nothing, Tab stays inside, aria-modal. A modal window never goes to the dock: `manager` is ignored"),
4569
+ SDATA(data_type_t.DTP_BOOLEAN, "keyboard", 0, true, "Escape closes the window the way its ✕ does (EV_WINDOW_TO_CLOSE can veto or ask), when the focus is in it -- not an Escape that what it was typed in took first: a handler that used it, a cell editor that closed with it, a textarea or a contenteditable"),
4297
4570
  SDATA(data_type_t.DTP_BOOLEAN, "back_dismissable", 0, true, "Browser Back closes this window (floating overlays only; ignored when it has a `manager`)"),
4298
4571
  SDATA(data_type_t.DTP_BOOLEAN, "keep_on_navigate", 0, false, "This window is a navigation PANEL: a route change does not close it"),
4299
4572
  SDATA(data_type_t.DTP_POINTER, "back_overlay", 0, null, "Internal: overlay-history entry (Back-button integration)"),
@@ -4305,7 +4578,10 @@ var attrs_table$21 = [
4305
4578
  var PRIVATE_DATA$21 = {
4306
4579
  prevSize: 0,
4307
4580
  placed_by_shell: false,
4308
- back_shell: null
4581
+ back_shell: null,
4582
+ opener: null,
4583
+ $lock: null,
4584
+ release_focus: null
4309
4585
  };
4310
4586
  var __gclass__$21 = null;
4311
4587
  /******************************
@@ -4319,6 +4595,10 @@ function mt_create$21(gobj) {
4319
4595
  if (subscriber) gobj_subscribe_event(gobj, null, {}, subscriber);
4320
4596
  let window_id = "window-" + clean_name(gobj_short_name(gobj));
4321
4597
  gobj_write_attr(gobj, "window_id", window_id);
4598
+ if (gobj_read_bool_attr(gobj, "modal") && gobj_read_pointer_attr(gobj, "manager")) {
4599
+ log_warning(`${gobj_short_name(gobj)}: a modal window does not go to the dock: its manager is ignored`);
4600
+ gobj_write_attr(gobj, "manager", null);
4601
+ }
4322
4602
  let manager = resolve_manager(gobj);
4323
4603
  build_ui$18(gobj);
4324
4604
  yui_shell_watch_changes(gobj);
@@ -4354,13 +4634,41 @@ function mt_create$21(gobj) {
4354
4634
  window.addEventListener("resize", on_win_resize);
4355
4635
  }
4356
4636
  /***************************************************************
4637
+ * Framework Method: Start
4638
+ *
4639
+ * The window takes the focus when it STARTS, not when it is
4640
+ * created: a host fills the body between the two (the json pad,
4641
+ * the frontend view), and `focus` may name what it put there.
4642
+ *
4643
+ * Only a window the READER opened takes it (opened_by_the_reader()).
4644
+ * One the app opens on its own -- the Developer window restored at
4645
+ * start up from the last session -- leaves the focus in the page:
4646
+ * the first Tab of a keyboard reader landed in a window they had
4647
+ * not opened. A modal window takes it all the same: nothing else
4648
+ * can be used while it is up.
4649
+ ***************************************************************/
4650
+ function mt_start$20(gobj) {
4651
+ let priv = gobj.priv;
4652
+ let $container = gobj_read_attr(gobj, "$container");
4653
+ if (!$container) {
4654
+ log_error(`${gobj_short_name(gobj)}: started without a container`);
4655
+ return;
4656
+ }
4657
+ let active = document.activeElement;
4658
+ if (active && active !== document.body && !$container.contains(active)) priv.opener = active;
4659
+ let modal = gobj_read_bool_attr(gobj, "modal");
4660
+ if (modal && !priv.release_focus) priv.release_focus = activate_focus_trap_on($container);
4661
+ if (modal || opened_by_the_reader()) focus_target(gobj, $container).focus();
4662
+ }
4663
+ /***************************************************************
4357
4664
  * Framework Method: Destroy
4358
4665
  ***************************************************************/
4359
4666
  function mt_destroy$21(gobj) {
4360
4667
  let priv = gobj.priv;
4668
+ give_focus_back(gobj);
4361
4669
  yui_shell_unwatch_changes(gobj);
4362
4670
  let manager = gobj_read_pointer_attr(gobj, "manager");
4363
- if (manager) gobj_send_event(manager, "EV_UNREGISTER_WINDOW", { window: gobj_full_name(gobj) }, gobj);
4671
+ if (manager && !gobj_is_destroying(manager)) gobj_send_event(manager, "EV_UNREGISTER_WINDOW", { window: gobj_full_name(gobj) }, gobj);
4364
4672
  let back_overlay = gobj_read_attr(gobj, "back_overlay");
4365
4673
  if (back_overlay) {
4366
4674
  if (priv.back_shell) yui_shell_overlay_dismissed(priv.back_shell, back_overlay);
@@ -4395,9 +4703,12 @@ function ensure_window_style() {
4395
4703
  .yui-window-title .icon { flex: 0 0 auto; }
4396
4704
  .yui-window-title svg { width: 14px; height: 14px; display: block; }
4397
4705
  /* Separator between the data half and the translated kind half. CSS,
4398
- * not a text node: createElement2 trims text nodes and eats the spaces. */
4706
+ * not a text node: createElement2 trims text nodes and eats the spaces.
4707
+ * Decorative ("/ ''"): the halves NAME the window, and a reader read
4708
+ * the dot into the kind half ("#1 ·demo window"). */
4399
4709
  .WINDOW_TITLE_PREFIX + .WINDOW_TITLE_KIND::before {
4400
4710
  content: "·";
4711
+ content: "·" / "";
4401
4712
  padding: 0 0.4em;
4402
4713
  color: var(--bulma-text-weak);
4403
4714
  }
@@ -4411,6 +4722,13 @@ function ensure_window_style() {
4411
4722
  .yui-wc svg { width: 15px; height: 15px; display: block; }
4412
4723
  .yui-window-resize { color: var(--bulma-text-weak); opacity: 0.55; }
4413
4724
  .yui-window-resize:hover { opacity: 1; color: var(--bulma-text); }
4725
+ /* A modal window over its backdrop: the backdrop of a Bulma .modal,
4726
+ * which the shell's dialogs wear (its variable lives on .modal). */
4727
+ .yui-window-lock { position: fixed; inset: 0; }
4728
+ .yui-window-backdrop {
4729
+ position: absolute; inset: 0;
4730
+ background-color: hsla(var(--bulma-scheme-h), var(--bulma-scheme-s), var(--bulma-scheme-invert-l), 0.86);
4731
+ }
4414
4732
  @media (max-width: ${MOBILE_MAX}px) {
4415
4733
  .C_YUI_WINDOW.is-mobile-sheet { border-radius: 0 !important; box-shadow: none !important; }
4416
4734
  .C_YUI_WINDOW.is-mobile-sheet .yui-window-resize { display: none !important; }
@@ -4446,12 +4764,19 @@ function ensure_window_style() {
4446
4764
  * refresh_language() re-translates just that one. The separator is
4447
4765
  * CSS (::before), never a text node: createElement2 TRIMS text nodes
4448
4766
  * and would eat the spaces around it.
4767
+ *
4768
+ * The same halves NAME the window: aria-labelledby lists them
4769
+ * (`<id>-prefix`, `<id>-kind`), so a reader joins them with a space
4770
+ * and leaves out the CSS separator, and the kind half changes
4771
+ * language. Under a `header` of the caller's the node is still
4772
+ * built, `hidden` (is-sr-only, no icon): a header is a toolbar more
4773
+ * often than a title, and the name of a dialog is its title.
4449
4774
  ************************************************************/
4450
- function build_default_header(gobj) {
4775
+ function build_title_node(gobj, id, hidden) {
4451
4776
  let title = gobj_read_str_attr(gobj, "title");
4452
4777
  let prefix = gobj_read_str_attr(gobj, "title_prefix");
4453
4778
  if (empty_string(title) && empty_string(prefix)) return null;
4454
- let icon = gobj_read_str_attr(gobj, "icon");
4779
+ let icon = hidden ? "" : gobj_read_str_attr(gobj, "icon");
4455
4780
  let items = [];
4456
4781
  if (!empty_string(icon)) {
4457
4782
  if (icon.charAt(0) === "<") items.push([
@@ -4467,20 +4792,27 @@ function build_default_header(gobj) {
4467
4792
  }
4468
4793
  if (!empty_string(prefix)) items.push([
4469
4794
  "span",
4470
- { class: "WINDOW_TITLE_PREFIX has-text-weight-semibold" },
4795
+ {
4796
+ class: "WINDOW_TITLE_PREFIX has-text-weight-semibold",
4797
+ id: `${id}-prefix`
4798
+ },
4471
4799
  text_node(prefix)
4472
4800
  ]);
4473
4801
  if (!empty_string(title)) items.push([
4474
4802
  "span",
4475
4803
  {
4476
4804
  class: "WINDOW_TITLE_KIND has-text-weight-semibold",
4805
+ id: `${id}-kind`,
4477
4806
  i18n: title
4478
4807
  },
4479
4808
  text_node(title)
4480
4809
  ]);
4481
4810
  return createElement2([
4482
4811
  "span",
4483
- { class: "WINDOW_TITLE yui-window-title icon-text ml-1" },
4812
+ {
4813
+ id,
4814
+ class: hidden ? "WINDOW_TITLE is-sr-only" : "WINDOW_TITLE yui-window-title icon-text ml-1"
4815
+ },
4484
4816
  items
4485
4817
  ]);
4486
4818
  }
@@ -4497,6 +4829,106 @@ function composed_title(gobj) {
4497
4829
  return empty_string(prefix) ? kind : prefix;
4498
4830
  }
4499
4831
  /************************************************************
4832
+ * Is the window opening in answer to the reader -- a press, a
4833
+ * key (the browser's user activation)? Not one the app restores
4834
+ * at start up. A browser that cannot say is taken at its word
4835
+ * that the reader asked.
4836
+ ************************************************************/
4837
+ function opened_by_the_reader() {
4838
+ let ua = typeof navigator !== "undefined" ? navigator.userActivation : null;
4839
+ if (!ua) return true;
4840
+ return !!ua.isActive;
4841
+ }
4842
+ /************************************************************
4843
+ * What takes the focus when the window starts (`focus`): an
4844
+ * element of the window, a selector looked up in it, or the
4845
+ * n-th control of the body. Null, or one that names nothing
4846
+ * (said): the window itself.
4847
+ ************************************************************/
4848
+ function focus_target(gobj, $container) {
4849
+ let focus = gobj_read_attr(gobj, "focus");
4850
+ if (focus === null || focus === void 0) return $container;
4851
+ let $target = null;
4852
+ if (typeof focus === "number") {
4853
+ let $body = $container.querySelector(".WINDOW_BODY");
4854
+ $target = ($body ? $body.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])") : [])[focus] || null;
4855
+ } else if (typeof focus === "string") $target = $container.querySelector(focus);
4856
+ else if (focus && typeof focus.focus === "function" && $container.contains(focus)) $target = focus;
4857
+ if (!$target) {
4858
+ log_warning(`${gobj_short_name(gobj)}: focus '${String(focus)}' names nothing in the window: the window takes it`);
4859
+ return $container;
4860
+ }
4861
+ return $target;
4862
+ }
4863
+ /************************************************************
4864
+ * The window goes: the focus goes back where it came from --
4865
+ * if it was in the window, or lost with what the window held
4866
+ * (a child torn down first takes its focused element with
4867
+ * it). A focus the reader has put elsewhere stays there. A
4868
+ * modal window's trap gives it back itself.
4869
+ ************************************************************/
4870
+ function give_focus_back(gobj) {
4871
+ let priv = gobj.priv;
4872
+ let opener = priv.opener;
4873
+ priv.opener = null;
4874
+ if (priv.release_focus) {
4875
+ let release = priv.release_focus;
4876
+ priv.release_focus = null;
4877
+ release();
4878
+ return;
4879
+ }
4880
+ let $container = gobj_read_attr(gobj, "$container");
4881
+ let active = document.activeElement;
4882
+ if (!(!active || active === document.body) && !($container && $container.contains(active))) return;
4883
+ if (opener && opener.isConnected !== false && typeof opener.focus === "function") opener.focus();
4884
+ }
4885
+ /************************************************************
4886
+ * A window that fills the screen -- the sheet of a phone, a
4887
+ * maximized one -- fills it but for the band a floating dock
4888
+ * keeps (DOCK_INSET_*). CSS, so the band moves with the dock
4889
+ * and no one has to tell the window.
4890
+ ************************************************************/
4891
+ function fill_work_area($container) {
4892
+ let vw = window.innerWidth || document.documentElement.offsetWidth;
4893
+ let vh = window.innerHeight || document.documentElement.offsetHeight;
4894
+ $container.style.left = "0px";
4895
+ $container.style.top = DOCK_INSET_TOP;
4896
+ $container.style.width = vw + "px";
4897
+ $container.style.height = `calc(${vh}px - ${DOCK_INSET_TOP} - ${DOCK_INSET_BOTTOM})`;
4898
+ return {
4899
+ x: 0,
4900
+ y: 0,
4901
+ width: vw,
4902
+ height: vh
4903
+ };
4904
+ }
4905
+ /************************************************************
4906
+ * What is placed in the DOM, and removed from it: the window,
4907
+ * or the lock that holds a modal one over its backdrop.
4908
+ ************************************************************/
4909
+ function window_root(gobj) {
4910
+ return gobj.priv.$lock || gobj_read_attr(gobj, "$container");
4911
+ }
4912
+ /************************************************************
4913
+ * An Escape typed in the window. The callback only decides
4914
+ * whether the key is the window's -- not when `keyboard` is
4915
+ * off, nor one that what it was typed in took -- and sends
4916
+ * the event: the close is the ✕'s, in the action.
4917
+ ************************************************************/
4918
+ function on_escape_key(gobj, evt) {
4919
+ if (evt.key !== "Escape" && evt.keyCode !== 27) return;
4920
+ if (gobj_is_destroying(gobj) || !gobj_read_bool_attr(gobj, "keyboard")) return;
4921
+ if (escape_is_taken(evt)) {
4922
+ let $container = gobj_read_attr(gobj, "$container");
4923
+ let active = document.activeElement;
4924
+ if (evt.target && evt.target.isConnected === false && $container && (!active || active === document.body)) $container.focus();
4925
+ return;
4926
+ }
4927
+ evt.preventDefault();
4928
+ evt.stopPropagation();
4929
+ gobj_send_event(gobj, "EV_CLOSE_WINDOW", { key: "Escape" }, gobj);
4930
+ }
4931
+ /************************************************************
4500
4932
  * Below the mobile breakpoint the window is a full-screen
4501
4933
  * sheet (no float / drag / resize).
4502
4934
  ************************************************************/
@@ -4538,14 +4970,18 @@ function build_ui$18(gobj) {
4538
4970
  let mobile = is_mobile$4();
4539
4971
  let header = gobj_read_attr(gobj, "header");
4540
4972
  if (is_gobj(header)) header = gobj_read_attr(header, "$container");
4541
- if (!header) header = build_default_header(gobj);
4973
+ let title_id = `yui-window-title-${++__title_seq__}`;
4974
+ let $title = build_title_node(gobj, title_id, !!header);
4975
+ let $hidden_title = header ? $title : null;
4976
+ if (!header) header = $title;
4977
+ let modal = gobj_read_bool_attr(gobj, "modal");
4542
4978
  let body = gobj_read_attr(gobj, "body");
4543
4979
  if (is_gobj(body)) body = gobj_read_attr(body, "$container");
4544
4980
  let footer = gobj_read_attr(gobj, "footer");
4545
4981
  if (is_gobj(footer)) footer = gobj_read_attr(footer, "$container");
4546
4982
  if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
4547
4983
  if (gobj_is_service(gobj)) {
4548
- let rect = kw_get_local_storage_value(`${gobj_name(gobj)}-rect`);
4984
+ let rect = whole_rect(kw_get_local_storage_value(`${gobj_name(gobj)}-rect`));
4549
4985
  if (rect) {
4550
4986
  rect.x = rect.x < 0 ? 0 : rect.x;
4551
4987
  rect.y = rect.y < 0 ? 0 : rect.y;
@@ -4584,12 +5020,21 @@ function build_ui$18(gobj) {
4584
5020
  };
4585
5021
  Object.assign(window_style, gobj_read_attr(gobj, "window_style"));
4586
5022
  let logical = gobj_read_str_attr(gobj, "logical_class");
5023
+ let dialog_attrs = {
5024
+ role: "dialog",
5025
+ tabindex: "-1"
5026
+ };
5027
+ let label_ids = [];
5028
+ if (!empty_string(gobj_read_str_attr(gobj, "title_prefix"))) label_ids.push(`${title_id}-prefix`);
5029
+ if (!empty_string(gobj_read_str_attr(gobj, "title"))) label_ids.push(`${title_id}-kind`);
5030
+ if (label_ids.length > 0) dialog_attrs["aria-labelledby"] = label_ids.join(" ");
5031
+ if (modal) dialog_attrs["aria-modal"] = "true";
4587
5032
  let $container = createElement2([
4588
5033
  "div",
4589
- {
5034
+ Object.assign({
4590
5035
  class: "C_YUI_WINDOW" + (logical ? " " + logical : "") + " strong-shadow is-flex is-flex-direction-column" + (mobile ? " is-mobile-sheet" : ""),
4591
5036
  style: window_style
4592
- },
5037
+ }, dialog_attrs),
4593
5038
  [
4594
5039
  [
4595
5040
  "div",
@@ -4749,6 +5194,11 @@ function build_ui$18(gobj) {
4749
5194
  ]
4750
5195
  ]);
4751
5196
  gobj_write_attr(gobj, "$container", $container);
5197
+ if ($hidden_title) $container.insertBefore($hidden_title, $container.firstChild);
5198
+ $container.addEventListener("keydown", function(evt) {
5199
+ on_escape_key(gobj, evt);
5200
+ });
5201
+ if (mobile) fill_work_area($container);
4752
5202
  if (gobj_read_bool_attr(gobj, "resizable") && !gobj_read_bool_attr(gobj, "showFooter")) {
4753
5203
  let $resizable_btn = createElement2([
4754
5204
  "div",
@@ -4776,10 +5226,29 @@ function build_ui$18(gobj) {
4776
5226
  $container.appendChild($resizable_btn);
4777
5227
  }
4778
5228
  refresh_language($container, t);
5229
+ if (modal) {
5230
+ let $lock = createElement2([
5231
+ "div",
5232
+ {
5233
+ class: "WINDOW_MODAL_LOCK yui-window-lock",
5234
+ style: `z-index:${MODAL_WINDOW_Z};`
5235
+ },
5236
+ [[
5237
+ "div",
5238
+ { class: "WINDOW_MODAL_BACKDROP yui-window-backdrop" },
5239
+ [],
5240
+ { mousedown: (evt) => {
5241
+ evt.preventDefault();
5242
+ } }
5243
+ ]]
5244
+ ]);
5245
+ $lock.appendChild($container);
5246
+ gobj.priv.$lock = $lock;
5247
+ }
4779
5248
  let $parent = gobj_read_attr(gobj, "$parent");
4780
5249
  gobj.priv.placed_by_shell = !$parent;
4781
5250
  if (!$parent) $parent = window_place(gobj);
4782
- $parent.appendChild($container);
5251
+ $parent.appendChild(window_root(gobj));
4783
5252
  if (gobj_read_bool_attr(gobj, "openMaximized")) max$2(gobj);
4784
5253
  else if (!mobile) {
4785
5254
  if (gobj_read_bool_attr(gobj, "content_size")) $container.style.height = "auto";
@@ -4795,11 +5264,10 @@ function build_ui$18(gobj) {
4795
5264
  * Destroy UI
4796
5265
  ************************************************************/
4797
5266
  function destroy_ui$13(gobj) {
4798
- let $container = gobj_read_attr(gobj, "$container");
4799
- if ($container) {
4800
- if ($container.parentNode) $container.parentNode.removeChild($container);
4801
- gobj_write_attr(gobj, "$container", null);
4802
- }
5267
+ let $root = window_root(gobj);
5268
+ if ($root && $root.parentNode) $root.parentNode.removeChild($root);
5269
+ gobj.priv.$lock = null;
5270
+ gobj_write_attr(gobj, "$container", null);
4803
5271
  }
4804
5272
  /************************************************************
4805
5273
  * Register this floating window in the shell's overlay history,
@@ -4890,9 +5358,16 @@ function close_window(gobj) {
4890
5358
  * The place is the shell's, and a window parented to the app
4891
5359
  * outlives it: ac_shell_changed() moves it when a shell goes or
4892
5360
  * comes.
5361
+ *
5362
+ * A MODAL window lives in the shell's dialog layer instead, with
5363
+ * its backdrop: it blocks the drawer, the dock and every other
5364
+ * window, and a question it asks (a dialog of the same layer)
5365
+ * opens above it.
4893
5366
  ************************************************************/
4894
5367
  function window_place(gobj) {
4895
- return yui_shell_window_layer(yui_shell_of(gobj)) || document.body;
5368
+ let shell = yui_shell_of(gobj);
5369
+ if (gobj_read_bool_attr(gobj, "modal")) return yui_shell_modal_layer(shell) || document.body;
5370
+ return yui_shell_window_layer(shell) || document.body;
4896
5371
  }
4897
5372
  /************************************************************
4898
5373
  *
@@ -4908,12 +5383,7 @@ function max$2(gobj) {
4908
5383
  let priv = gobj.priv;
4909
5384
  let $container = gobj_read_attr(gobj, "$container");
4910
5385
  priv.prevSize = $container.getBoundingClientRect();
4911
- let rect = do_fix_dimension_to_screen(gobj, 0, 0, 1e4, 1e4);
4912
- if (gobj_read_bool_attr(gobj, "center")) rect = do_center(gobj, rect.x, rect.y, rect.width, rect.height);
4913
- $container.style.left = parseInt(rect.x) + "px";
4914
- $container.style.top = parseInt(rect.y) + "px";
4915
- $container.style.width = parseInt(rect.width) + "px";
4916
- $container.style.height = parseInt(rect.height) + "px";
5386
+ let rect = fill_work_area($container);
4917
5387
  gobj_write_bool_attr(gobj, "maximized", true);
4918
5388
  set_max_icon(gobj, true);
4919
5389
  return rect;
@@ -4951,6 +5421,27 @@ function min$1(gobj) {
4951
5421
  return rect;
4952
5422
  }
4953
5423
  /************************************************************
5424
+ * The rect of a window in whole pixels: x, y, width and height
5425
+ * are DTP_INTEGER, and getBoundingClientRect() answers fractions
5426
+ * under a zoom or a device pixel ratio (an integer attr refuses
5427
+ * 2.5, as in C). Also a rect saved with fractions before. null
5428
+ * when it is not a rect of four numbers.
5429
+ ************************************************************/
5430
+ function whole_rect(rect) {
5431
+ if (!rect || typeof rect !== "object") return null;
5432
+ let whole = {};
5433
+ for (const key of [
5434
+ "x",
5435
+ "y",
5436
+ "width",
5437
+ "height"
5438
+ ]) {
5439
+ if (typeof rect[key] !== "number" || !Number.isFinite(rect[key])) return null;
5440
+ whole[key] = Math.round(rect[key]);
5441
+ }
5442
+ return whole;
5443
+ }
5444
+ /************************************************************
4954
5445
  * handlers moving
4955
5446
  ************************************************************/
4956
5447
  function mvStart(gobj, evt) {
@@ -4985,17 +5476,13 @@ function mvStart(gobj, evt) {
4985
5476
  $container.style.transition = "none";
4986
5477
  $container.style.transform = "translate3d(0px, 0px, 0px)";
4987
5478
  let rect = $container.getBoundingClientRect();
4988
- gobj_write_integer_attr(gobj, "x", rect.x);
4989
- gobj_write_integer_attr(gobj, "y", rect.y);
4990
- gobj_write_integer_attr(gobj, "width", rect.width);
4991
- gobj_write_integer_attr(gobj, "height", rect.height);
5479
+ let whole = whole_rect(rect);
5480
+ gobj_write_integer_attr(gobj, "x", whole.x);
5481
+ gobj_write_integer_attr(gobj, "y", whole.y);
5482
+ gobj_write_integer_attr(gobj, "width", whole.width);
5483
+ gobj_write_integer_attr(gobj, "height", whole.height);
4992
5484
  if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
4993
- if (gobj_is_service(gobj)) kw_set_local_storage_value(`${gobj_name(gobj)}-rect`, {
4994
- x: rect.x,
4995
- y: rect.y,
4996
- width: rect.width,
4997
- height: rect.height
4998
- });
5485
+ if (gobj_is_service(gobj)) kw_set_local_storage_value(`${gobj_name(gobj)}-rect`, whole);
4999
5486
  }
5000
5487
  gobj_publish_event(gobj, "EV_WINDOW_MOVED", { rect });
5001
5488
  }
@@ -5038,17 +5525,13 @@ function rsStart(gobj, evt) {
5038
5525
  $container.style.width = rect.width + "px";
5039
5526
  $container.style.height = rect.height + "px";
5040
5527
  }
5041
- gobj_write_integer_attr(gobj, "x", rect.x);
5042
- gobj_write_integer_attr(gobj, "y", rect.y);
5043
- gobj_write_integer_attr(gobj, "width", rect.width);
5044
- gobj_write_integer_attr(gobj, "height", rect.height);
5528
+ let whole = whole_rect(rect);
5529
+ gobj_write_integer_attr(gobj, "x", whole.x);
5530
+ gobj_write_integer_attr(gobj, "y", whole.y);
5531
+ gobj_write_integer_attr(gobj, "width", whole.width);
5532
+ gobj_write_integer_attr(gobj, "height", whole.height);
5045
5533
  if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
5046
- if (gobj_is_service(gobj)) kw_set_local_storage_value(`${gobj_name(gobj)}-rect`, {
5047
- x: rect.x,
5048
- y: rect.y,
5049
- width: rect.width,
5050
- height: rect.height
5051
- });
5534
+ if (gobj_is_service(gobj)) kw_set_local_storage_value(`${gobj_name(gobj)}-rect`, whole);
5052
5535
  }
5053
5536
  gobj_publish_event(gobj, "EV_WINDOW_RESIZED", { rect });
5054
5537
  }
@@ -5115,22 +5598,12 @@ function handleResize(gobj) {
5115
5598
  if (!$container) return;
5116
5599
  if (is_mobile$4()) {
5117
5600
  $container.classList.add("is-mobile-sheet");
5118
- let vw = window.innerWidth || document.documentElement.offsetWidth;
5119
- let vh = window.innerHeight || document.documentElement.offsetHeight;
5120
- $container.style.left = "0px";
5121
- $container.style.top = "0px";
5122
- $container.style.width = vw + "px";
5123
- $container.style.height = vh + "px";
5601
+ fill_work_area($container);
5124
5602
  return;
5125
5603
  }
5126
5604
  $container.classList.remove("is-mobile-sheet");
5127
5605
  if (gobj_read_bool_attr(gobj, "maximized") === true) {
5128
- let r = do_fix_dimension_to_screen(gobj, 0, 0, 1e4, 1e4);
5129
- if (gobj_read_bool_attr(gobj, "center")) r = do_center(gobj, r.x, r.y, r.width, r.height);
5130
- $container.style.left = parseInt(r.x) + "px";
5131
- $container.style.top = parseInt(r.y) + "px";
5132
- $container.style.width = parseInt(r.width) + "px";
5133
- $container.style.height = parseInt(r.height) + "px";
5606
+ fill_work_area($container);
5134
5607
  return;
5135
5608
  }
5136
5609
  let rect = do_fix_dimension_to_screen(gobj, gobj_read_integer_attr(gobj, "x"), gobj_read_integer_attr(gobj, "y"), gobj_read_integer_attr(gobj, "width"), gobj_read_integer_attr(gobj, "height"));
@@ -5221,7 +5694,8 @@ function ac_shell_changed$1(gobj, event, kw, src) {
5221
5694
  priv.placed_by_shell = true;
5222
5695
  }
5223
5696
  let $place = window_place(gobj);
5224
- if ($container.parentNode !== $place) $place.appendChild($container);
5697
+ let $root = window_root(gobj);
5698
+ if ($root.parentNode !== $place) $place.appendChild($root);
5225
5699
  return 0;
5226
5700
  }
5227
5701
  /***************************
@@ -5229,6 +5703,7 @@ function ac_shell_changed$1(gobj, event, kw, src) {
5229
5703
  ***************************/
5230
5704
  var gmt$21 = {
5231
5705
  mt_create: mt_create$21,
5706
+ mt_start: mt_start$20,
5232
5707
  mt_destroy: mt_destroy$21
5233
5708
  };
5234
5709
  /***************************************************************
@@ -5316,6 +5791,15 @@ function register_c_yui_window() {
5316
5791
  * (`responsive_query`) — so on mobile it lives above
5317
5792
  * the bottom menu instead of covering it.
5318
5793
  *
5794
+ * A FLOATING dock that shows says the band it keeps at the top or
5795
+ * the foot of the viewport: `--yui-dock-inset-top` /
5796
+ * `--yui-dock-inset-bottom` on the root element (publish_dock_band).
5797
+ * A window that fills the screen -- the sheet of a phone, a
5798
+ * maximized one -- leaves that band free. It used to go under the
5799
+ * dock: at a bottom corner the dock covered its foot, at a top
5800
+ * corner its ✕ and its minimize (a 'responsive' dock with no
5801
+ * `inline_selector` floats on a phone too).
5802
+ *
5319
5803
  * Copyright (c) 2026, ArtGins.
5320
5804
  * All Rights Reserved.
5321
5805
  ***********************************************************************/
@@ -5385,6 +5869,7 @@ function mt_destroy$20(gobj) {
5385
5869
  priv.mql_handler = null;
5386
5870
  }
5387
5871
  destroy_dock(gobj);
5872
+ publish_dock_band(gobj);
5388
5873
  }
5389
5874
  /***************************
5390
5875
  * Local Methods
@@ -5489,8 +5974,10 @@ function ensure_dock_style() {
5489
5974
  .yui-dock-label { flex: 0 0 auto; }
5490
5975
  /* Split label halves (prefix = DATA, kind = translatable). The
5491
5976
  * separator is CSS, never a text node — same rule as the window
5492
- * title bar (createElement2 trims text nodes). */
5493
- .yui-dock-label .yui-dock-label-prefix + .yui-dock-label-kind::before { content: " \\00b7 "; }
5977
+ * title bar (createElement2 trims text nodes). Decorative ("/ ''"):
5978
+ * the halves NAME the toggle (aria-labelledby), and a reader read
5979
+ * the dot into the kind half ("#1 ·demo window"). */
5980
+ .yui-dock-label .yui-dock-label-prefix + .yui-dock-label-kind::before { content: " \\00b7 "; content: " \\00b7 " / ""; }
5494
5981
  .yui-dock-close {
5495
5982
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
5496
5983
  padding: 0; margin-left: 1px; border: 0; border-radius: 4px;
@@ -5562,6 +6049,32 @@ function apply_placement(gobj) {
5562
6049
  ]) $dock.classList.toggle(`yui-dock--${c}`, !inline && c === corner);
5563
6050
  let target = inline ? $inline : gobj_read_attr(gobj, "$parent") || dock_place(gobj);
5564
6051
  if ($dock.parentNode !== target) target.appendChild($dock);
6052
+ publish_dock_band(gobj);
6053
+ }
6054
+ /************************************************************
6055
+ * Say the band the dock keeps over the windows: a FLOATING
6056
+ * dock that shows takes the top or the foot of the viewport,
6057
+ * from its edge to its far side. A window that fills the
6058
+ * screen leaves it free (C_YUI_WINDOW's fill_work_area()). An
6059
+ * inline dock keeps none: it is in the layout. Nor does an
6060
+ * empty one, or one that is not drawn.
6061
+ ************************************************************/
6062
+ function publish_dock_band(gobj) {
6063
+ let $dock = gobj_read_attr(gobj, "$container");
6064
+ let top = 0;
6065
+ let bottom = 0;
6066
+ if ($dock && $dock.parentNode && $dock.classList.contains("yui-dock--floating") && !$dock.classList.contains("is-empty")) {
6067
+ let r = $dock.getBoundingClientRect();
6068
+ if (r.height > 0) {
6069
+ if ((gobj_read_attr(gobj, "dock_corner") || "bottom-left").indexOf("top") === 0) top = Math.ceil(r.bottom);
6070
+ else bottom = Math.ceil((window.innerHeight || 0) - r.top);
6071
+ }
6072
+ }
6073
+ let style = document.documentElement.style;
6074
+ if (top > 0) style.setProperty("--yui-dock-inset-top", `${top}px`);
6075
+ else style.removeProperty("--yui-dock-inset-top");
6076
+ if (bottom > 0) style.setProperty("--yui-dock-inset-bottom", `${bottom}px`);
6077
+ else style.removeProperty("--yui-dock-inset-bottom");
5565
6078
  }
5566
6079
  /************************************************************
5567
6080
  * Where the FLOATING dock lives when the app names no
@@ -5576,12 +6089,12 @@ function apply_placement(gobj) {
5576
6089
  * and it covered a toast where they met.
5577
6090
  *
5578
6091
  * The popup layer, not the window layer: the dock has to stay
5579
- * above EVERY window, and windows live in two layers -- the
5580
- * window layer (no `$parent`) and the popup layer, where the
5581
- * site map and the JSON windows of the treedb views put theirs.
5582
- * Above both; below the dialogs, the toasts and the loading
5583
- * cover. No shell (before the first, between a logout and the
5584
- * next login): the body.
6092
+ * above EVERY window, and the windows live in the window layer
6093
+ * -- since 7.26.35 the site map and the JSON windows of the
6094
+ * treedb views too, which put theirs in the popup layer until
6095
+ * then. The popup layer is above it; below the dialogs, the
6096
+ * toasts and the loading cover. No shell (before the first,
6097
+ * between a logout and the next login): the body.
5585
6098
  ************************************************************/
5586
6099
  function dock_place(gobj) {
5587
6100
  return yui_shell_popup_layer(yui_shell_of(gobj)) || document.body;
@@ -5651,6 +6164,7 @@ function sync_dock_visibility(gobj) {
5651
6164
  let priv = gobj.priv;
5652
6165
  let $dock = gobj_read_attr(gobj, "$container");
5653
6166
  if ($dock) $dock.classList.toggle("is-empty", priv.windows.length === 0);
6167
+ publish_dock_band(gobj);
5654
6168
  }
5655
6169
  /************************************************************
5656
6170
  * Mark one entry active (raised), the rest inactive.
@@ -5689,10 +6203,17 @@ function minimize_entry(gobj, entry) {
5689
6203
  /************************************************************
5690
6204
  * Dock chip click: taskbar toggle — restore+focus a
5691
6205
  * minimized/inactive window, minimize the active one.
6206
+ *
6207
+ * The window brought back takes the keyboard focus too: the
6208
+ * reader pressed its chip to go there, and a window is heard
6209
+ * (Escape, Tab) only with the focus in it.
5692
6210
  ************************************************************/
5693
6211
  function on_chip_click(gobj, entry) {
5694
- if (entry.minimized || !entry.$chip.classList.contains("is-active")) focus_entry(gobj, entry);
5695
- else minimize_entry(gobj, entry);
6212
+ if (entry.minimized || !entry.$chip.classList.contains("is-active")) {
6213
+ focus_entry(gobj, entry);
6214
+ let $win = gobj_read_attr(entry.gobj, "$container");
6215
+ if ($win) $win.focus();
6216
+ } else minimize_entry(gobj, entry);
5696
6217
  }
5697
6218
  /***************************
5698
6219
  * Actions
@@ -5821,7 +6342,13 @@ function ac_minimize_window(gobj, event, kw, src) {
5821
6342
  let win = window_of(gobj, event, kw, src);
5822
6343
  if (!win) return -1;
5823
6344
  let entry = find_entry(gobj.priv, win);
5824
- if (entry) minimize_entry(gobj, entry);
6345
+ if (entry) {
6346
+ let $win = gobj_read_attr(win, "$container");
6347
+ let had_focus = !!($win && $win.contains(document.activeElement));
6348
+ minimize_entry(gobj, entry);
6349
+ let $toggle = had_focus && entry.$chip ? entry.$chip.querySelector(".DOCK_CHIP_TOGGLE") : null;
6350
+ if ($toggle) $toggle.focus();
6351
+ }
5825
6352
  return 0;
5826
6353
  }
5827
6354
  /************************************************************
@@ -7115,6 +7642,10 @@ function register_c_yui_wizard() {
7115
7642
  *
7116
7643
  * yui_tabulator_relocalize(table, t, {device_id: t("device id")});
7117
7644
  *
7645
+ * A column GROUP is bound by field too, and Tabulator gives it none:
7646
+ * give it one (`{title, field: "sizes", columns: [...]}`, no row reads
7647
+ * it) and its title goes in the same object. One without is said.
7648
+ *
7118
7649
  * Every key carries an English `defaultValue`, so an app that does not
7119
7650
  * define it renders exactly what Tabulator rendered before — the
7120
7651
  * keys are an OPPORTUNITY to translate, never a requirement.
@@ -7274,6 +7805,22 @@ function yui_tabulator_name_editor(column_def, name_of) {
7274
7805
  };
7275
7806
  }
7276
7807
  /***************************************************************
7808
+ * A column GROUP whose title cannot change language, said.
7809
+ *
7810
+ * Tabulator binds a column's title to the locale by its `field`, and
7811
+ * a group has none: its title stays in the language the table was
7812
+ * built in. Given a `field` (no row reads a group's), a group is
7813
+ * bound like any other column, and its title goes in `titles`.
7814
+ ***************************************************************/
7815
+ function say_groups_without_field(columns) {
7816
+ for (let column of columns || []) {
7817
+ let def = column.getDefinition() || {};
7818
+ if (!Array.isArray(def.columns)) continue;
7819
+ if (!def.field) log_warning(`yui_tabulator_relocalize: column group '${def.title}' has no field: its title stays in the language it was built in`);
7820
+ say_groups_without_field(column.getSubColumns());
7821
+ }
7822
+ }
7823
+ /***************************************************************
7277
7824
  * yui_tabulator_relocalize() -- see "Put an EXISTING table in the
7278
7825
  * current language" above.
7279
7826
  *
@@ -7282,14 +7829,19 @@ function yui_tabulator_name_editor(column_def, name_of) {
7282
7829
  * (`columns`), where Tabulator binds each column's title: setLocale()
7283
7830
  * draws them again without rebuilding a column -- updateDefinition()
7284
7831
  * re-renders every row, and a row whose formatter builds something (a
7285
- * nested table) builds it anew. A field left out keeps its title.
7832
+ * nested table) builds it anew. A field left out keeps its title. A
7833
+ * column GROUP is bound only if it has a `field` of its own: one
7834
+ * without is said (say_groups_without_field).
7286
7835
  ***************************************************************/
7287
7836
  function yui_tabulator_relocalize(table, t, titles) {
7288
7837
  if (!table) return;
7289
7838
  try {
7290
7839
  let name = next_lang_name();
7291
7840
  let strings = tabulator_strings(t);
7292
- if (titles && typeof titles === "object") strings.columns = Object.assign({}, titles);
7841
+ if (titles && typeof titles === "object") {
7842
+ strings.columns = Object.assign({}, titles);
7843
+ say_groups_without_field(table.getColumns(true));
7844
+ }
7293
7845
  table.options.langs = table.options.langs || {};
7294
7846
  table.options.langs[name] = strings;
7295
7847
  let localize = table.modules && table.modules.localize;
@@ -9216,7 +9768,9 @@ function json_editor_value(content) {
9216
9768
  * Not reached, because the editor gives them no hook: its search
9217
9769
  * box, its repair messages, the tip at the foot of the context
9218
9770
  * menu, and its modals (sort, transform). They stay in its
9219
- * English.
9771
+ * English. vanilla-jsoneditor (3.13.0) has no i18n option: they
9772
+ * are literals inside its Svelte components, and the only way to
9773
+ * them would be rewriting its DOM by its English words.
9220
9774
  *
9221
9775
  * Copyright (c) 2026, ArtGins.
9222
9776
  * All Rights Reserved.
@@ -9858,11 +10412,11 @@ function cell_icon(icon_class, key) {
9858
10412
  }
9859
10413
  /************************************************************
9860
10414
  * The identity of a table element, for the kw of
9861
- * EV_ADD_TABLE_ROW: a kw is plain json, and an element (with its
9862
- * `.tabulator`, circular) broke the `machine` trace that dumps it.
9863
- * Given on first use and kept on the element; the registry holds
9864
- * it weakly, so a nested table re-built by its row formatter is
9865
- * not kept alive by it.
10415
+ * EV_ADD_TABLE_ROW and EV_LOAD_TABLE_ROWS: a kw is plain json,
10416
+ * and an element (with its `.tabulator`, circular) broke the
10417
+ * `machine` trace that dumps it. Given on first use and kept on
10418
+ * the element; the registry holds it weakly, so a nested table
10419
+ * whose row is gone is not kept alive by it.
9866
10420
  ************************************************************/
9867
10421
  function table_identity(gobj, $table) {
9868
10422
  if (!$table.yui_table_id) {
@@ -9888,6 +10442,53 @@ function find_table(gobj, table_id) {
9888
10442
  return $table;
9889
10443
  }
9890
10444
  /************************************************************
10445
+ * Destroy one third-party widget, saying why it could not be.
10446
+ ************************************************************/
10447
+ function destroy_widget(gobj, what, widget) {
10448
+ try {
10449
+ let r = widget.destroy();
10450
+ if (r && typeof r.then === "function") r.catch((e) => {
10451
+ log_warning(`${gobj_short_name(gobj)}: cannot destroy ${what}: ${e}`);
10452
+ });
10453
+ } catch (e) {
10454
+ log_warning(`${gobj_short_name(gobj)}: cannot destroy ${what}: ${e}`);
10455
+ }
10456
+ }
10457
+ /************************************************************
10458
+ * A table element that is gone: its identity is no table now,
10459
+ * and what was waiting to be loaded in it never will be.
10460
+ ************************************************************/
10461
+ function forget_table(gobj, $table) {
10462
+ $table.yui_pending_rows = null;
10463
+ if ($table.yui_table_id && gobj.priv && gobj.priv.tables) gobj.priv.tables.delete($table.yui_table_id);
10464
+ }
10465
+ /************************************************************
10466
+ * Destroy the nested tables a row of a table built (its row
10467
+ * formatter keeps them on the row's element), theirs first.
10468
+ * Tabulator takes the row's DOM away when the row goes -- a
10469
+ * reload, an undo, a deleted row -- and destroys nothing in it:
10470
+ * each nested table stayed in Tabulator's registry, with its
10471
+ * observers, for the life of the page.
10472
+ ************************************************************/
10473
+ function destroy_row_tables(gobj, $row) {
10474
+ let nested = $row.yui_nested || [];
10475
+ $row.yui_nested = null;
10476
+ for (let $nested of nested) {
10477
+ if ($nested.tabulator) {
10478
+ destroy_rows_tables(gobj, $nested.tabulator);
10479
+ destroy_widget(gobj, "nested table", $nested.tabulator);
10480
+ $nested.tabulator = null;
10481
+ }
10482
+ forget_table(gobj, $nested);
10483
+ }
10484
+ }
10485
+ /************************************************************
10486
+ * Destroy the nested tables of every row of a table.
10487
+ ************************************************************/
10488
+ function destroy_rows_tables(gobj, tabulator) {
10489
+ for (let row of tabulator.getRows()) destroy_row_tables(gobj, row.getElement());
10490
+ }
10491
+ /************************************************************
9891
10492
  * Destroy the third-party widgets the form built. Removing
9892
10493
  * their DOM is not enough: Tom Select keeps listeners on
9893
10494
  * `document` and `window`, the jsoneditor is a live Svelte app
@@ -9896,40 +10497,21 @@ function find_table(gobj, table_id) {
9896
10497
  * first: their parent's destroy drops the rows they hang from.
9897
10498
  ************************************************************/
9898
10499
  function destroy_widgets(gobj, $container) {
9899
- let destroy = (what, widget) => {
9900
- try {
9901
- let r = widget.destroy();
9902
- if (r && typeof r.then === "function") r.catch((e) => {
9903
- log_warning(`${gobj_short_name(gobj)}: cannot destroy ${what}: ${e}`);
9904
- });
9905
- } catch (e) {
9906
- log_warning(`${gobj_short_name(gobj)}: cannot destroy ${what}: ${e}`);
9907
- }
9908
- };
9909
- let forget = ($el) => {
9910
- if ($el.yui_table_id && gobj.priv && gobj.priv.tables) gobj.priv.tables.delete($el.yui_table_id);
9911
- };
9912
- $container.querySelectorAll(".yui-tabulator-table-nested").forEach(($el) => {
9913
- if ($el.tabulator) {
9914
- destroy("nested table", $el.tabulator);
9915
- $el.tabulator = null;
9916
- }
9917
- forget($el);
9918
- });
9919
10500
  $container.querySelectorAll(".yui-form-data-input").forEach(($el) => {
9920
10501
  if ($el.tom_select) {
9921
- destroy("select", $el.tom_select);
10502
+ destroy_widget(gobj, "select", $el.tom_select);
9922
10503
  $el.tom_select = null;
9923
10504
  }
9924
10505
  if ($el.jsoneditor) {
9925
- destroy("json editor", $el.jsoneditor);
10506
+ destroy_widget(gobj, "json editor", $el.jsoneditor);
9926
10507
  $el.jsoneditor = null;
9927
10508
  }
9928
10509
  if ($el.tabulator) {
9929
- destroy("table", $el.tabulator);
10510
+ destroy_rows_tables(gobj, $el.tabulator);
10511
+ destroy_widget(gobj, "table", $el.tabulator);
9930
10512
  $el.tabulator = null;
10513
+ forget_table(gobj, $el);
9931
10514
  }
9932
- forget($el);
9933
10515
  });
9934
10516
  }
9935
10517
  /******************************************************************
@@ -10609,8 +11191,7 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
10609
11191
  }
10610
11192
  gobj_send_event(gobj, "EV_ADD_TABLE_ROW", {
10611
11193
  table_id: table_identity(gobj, $add_table),
10612
- record: {},
10613
- loading: false
11194
+ record: {}
10614
11195
  }, gobj);
10615
11196
  } }
10616
11197
  ]]
@@ -11164,6 +11745,19 @@ function create_coordinates(gobj, attrs) {
11164
11745
  }
11165
11746
  /******************************************************************
11166
11747
  * Create tabulator
11748
+ *
11749
+ * A row builds its nested tables the first time it is drawn, each
11750
+ * loaded from the row's own data, and keeps them on its element
11751
+ * (`yui_nested`) until the row goes (destroy_row_tables). A row
11752
+ * drawn AGAIN -- a forced redraw, a column rebuilt -- has its
11753
+ * children taken off by Tabulator before its formatter runs: they
11754
+ * are put back as they are. Built anew, they came back empty, and
11755
+ * the old ones stayed alive in Tabulator's registry.
11756
+ *
11757
+ * A load that comes before the table is built waits for its
11758
+ * `tableBuilt`, ONE per table (`yui_pending_rows`): a later load
11759
+ * replaces it, a clear drops it. Each load used to hang a listener
11760
+ * of its own, so two loads before the build drew the rows twice.
11167
11761
  ******************************************************************/
11168
11762
  function create_tabulator$1(gobj, $extend, name, template) {
11169
11763
  function get_selectable_state(row) {
@@ -11183,6 +11777,13 @@ function create_tabulator$1(gobj, $extend, name, template) {
11183
11777
  let sub_elements = [];
11184
11778
  tabulator_settings.columns = template2columns(gobj, columns, template, sub_elements);
11185
11779
  if (sub_elements.length > 0) tabulator_settings.rowFormatter = function(row) {
11780
+ let $row = row.getElement();
11781
+ if ($row.yui_nested) {
11782
+ for (let $nested of $row.yui_nested) $row.appendChild($nested);
11783
+ return;
11784
+ }
11785
+ $row.yui_nested = [];
11786
+ let data = row.getData() || {};
11186
11787
  for (let sub_element of sub_elements) {
11187
11788
  let extend = ["div", {
11188
11789
  class: "yui-tabulator-table-nested pl-6 is-bordered is-striped",
@@ -11190,7 +11791,10 @@ function create_tabulator$1(gobj, $extend, name, template) {
11190
11791
  }];
11191
11792
  let $extend = createElement2(extend);
11192
11793
  $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template);
11193
- row.getElement().appendChild($extend);
11794
+ $row.appendChild($extend);
11795
+ $row.yui_nested.push($extend);
11796
+ let rows = data[sub_element.name];
11797
+ load_tabulator_data(gobj, $extend, is_array(rows) ? rows : []);
11194
11798
  }
11195
11799
  };
11196
11800
  if (gobj_read_bool_attr(gobj, "with_delete_row_btn")) columns.push({
@@ -11222,6 +11826,18 @@ function create_tabulator$1(gobj, $extend, name, template) {
11222
11826
  if (gobj.priv.loading_rows > 0) return;
11223
11827
  gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
11224
11828
  });
11829
+ $extend.yui_pending_rows = null;
11830
+ tabulator.on("tableBuilt", function() {
11831
+ let rows = $extend.yui_pending_rows;
11832
+ $extend.yui_pending_rows = null;
11833
+ if (rows && !gobj_is_destroying(gobj)) gobj_send_event(gobj, "EV_LOAD_TABLE_ROWS", {
11834
+ table_id: table_identity(gobj, $extend),
11835
+ rows
11836
+ }, gobj);
11837
+ });
11838
+ tabulator.on("rowDeleted", function(row) {
11839
+ destroy_row_tables(gobj, row.getElement());
11840
+ });
11225
11841
  tabulator.on("renderComplete", function() {
11226
11842
  yui_tabulator_name_row_selects(tabulator, t);
11227
11843
  });
@@ -11312,8 +11928,7 @@ function template2columns(gobj, columns, template, sub_elements) {
11312
11928
  }
11313
11929
  gobj_send_event(gobj, "EV_ADD_TABLE_ROW", {
11314
11930
  table_id: table_identity(gobj, $extend),
11315
- record: {},
11316
- loading: false
11931
+ record: {}
11317
11932
  }, gobj);
11318
11933
  }
11319
11934
  });
@@ -11541,6 +12156,21 @@ function getInputValue($input) {
11541
12156
  else return $input.value;
11542
12157
  }
11543
12158
  /************************************************************
12159
+ * The rows of a table as the form saves them: copies, each with
12160
+ * the rows of the nested tables its row holds. A row's
12161
+ * getData() is the row's OWN object: handed out in the save, a
12162
+ * later edit wrote into what the host had been given.
12163
+ ************************************************************/
12164
+ function table_values(tabulator) {
12165
+ let value = [];
12166
+ for (let row of tabulator.getRows()) {
12167
+ let d = json_deep_copy(row.getData());
12168
+ for (let $nested of row.getElement().yui_nested || []) if ($nested.tabulator) d[$nested.getAttribute("name")] = table_values($nested.tabulator);
12169
+ value.push(d);
12170
+ }
12171
+ return value;
12172
+ }
12173
+ /************************************************************
11544
12174
  * Function to get input value based on its type
11545
12175
  ************************************************************/
11546
12176
  function get_form_values(gobj, $form) {
@@ -11594,18 +12224,7 @@ function get_form_values(gobj, $form) {
11594
12224
  break;
11595
12225
  case "table":
11596
12226
  let template = gobj_read_attr(gobj, "template");
11597
- if (!empty_string(name) && kw_has_key(template, name)) {
11598
- value = [];
11599
- let rows = $input.tabulator.getRows();
11600
- for (let row of rows) {
11601
- let d = row.getData();
11602
- value.push(d);
11603
- row.getElement().querySelectorAll(".yui-tabulator-table-nested").forEach(($nested) => {
11604
- let name_n = $nested.getAttribute("name");
11605
- d[name_n] = $nested.tabulator.getData();
11606
- });
11607
- }
11608
- }
12227
+ if (!empty_string(name) && kw_has_key(template, name)) value = table_values($input.tabulator);
11609
12228
  break;
11610
12229
  case "coordinates":
11611
12230
  if ($input.tagName !== "INPUT") $input = $input.querySelector("input");
@@ -11622,7 +12241,10 @@ function get_form_values(gobj, $form) {
11622
12241
  return record;
11623
12242
  }
11624
12243
  /************************************************************
11625
- *
12244
+ * Empty the form. A table not built yet has no rows to clear
12245
+ * but may have a load waiting for its build: it is dropped too,
12246
+ * or the rows cleared here came back when the table was built.
12247
+ * The nested tables go with the rows that hold them.
11626
12248
  ************************************************************/
11627
12249
  function clear_data(gobj, $form) {
11628
12250
  let pkey = gobj_read_str_attr(gobj, "pkey");
@@ -11655,10 +12277,11 @@ function clear_data(gobj, $form) {
11655
12277
  if ($file.yui_file_render) $file.yui_file_render();
11656
12278
  });
11657
12279
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
11658
- if ($table.tabulator.initialized) $table.tabulator.clearData();
11659
- $table.querySelectorAll(".yui-tabulator-table-nested").forEach(($table_nested) => {
11660
- if ($table_nested.tabulator.initialized) $table_nested.tabulator.clearData();
11661
- });
12280
+ $table.yui_pending_rows = null;
12281
+ if ($table.tabulator.initialized) {
12282
+ destroy_rows_tables(gobj, $table.tabulator);
12283
+ $table.tabulator.clearData();
12284
+ }
11662
12285
  });
11663
12286
  }
11664
12287
  /************************************************************
@@ -11783,27 +12406,35 @@ function set_form_values(gobj, template, $form, record) {
11783
12406
  return modified;
11784
12407
  }
11785
12408
  /************************************************************
11786
- * loading data from backend to tabulator,
11787
- * check if the table is built
12409
+ * Load the rows of a record in a table: all of them at once
12410
+ * (EV_LOAD_TABLE_ROWS), now if the table is built, else when it
12411
+ * is (create_tabulator's `tableBuilt`).
11788
12412
  ************************************************************/
11789
12413
  function load_tabulator_data(gobj, $table, value) {
11790
- if (!value) {
12414
+ if (!is_array(value)) {
11791
12415
  log_error(sprintf("%s: no data to load_tabulator_data()", gobj_short_name(gobj)));
11792
12416
  return;
11793
12417
  }
11794
- let tabulator = $table.tabulator;
11795
- if (tabulator.initialized) for (let row of value) gobj_send_event(gobj, "EV_ADD_TABLE_ROW", {
12418
+ if (!$table.tabulator.initialized) {
12419
+ $table.yui_pending_rows = value.length > 0 ? value : null;
12420
+ return;
12421
+ }
12422
+ $table.yui_pending_rows = null;
12423
+ if (value.length === 0) return;
12424
+ gobj_send_event(gobj, "EV_LOAD_TABLE_ROWS", {
11796
12425
  table_id: table_identity(gobj, $table),
11797
- record: row,
11798
- loading: true
12426
+ rows: value
11799
12427
  }, gobj);
11800
- else tabulator.on("tableBuilt", function() {
11801
- for (let row of value) gobj_send_event(gobj, "EV_ADD_TABLE_ROW", {
11802
- table_id: table_identity(gobj, $table),
11803
- record: row,
11804
- loading: true
11805
- }, gobj);
11806
- });
12428
+ }
12429
+ /************************************************************
12430
+ * Redraw a table once what was added to it is drawn: the
12431
+ * "double scrollbar" Tabulator leaves when its rows grow.
12432
+ ************************************************************/
12433
+ function redraw_table_later(gobj, $table) {
12434
+ setTimeout(function() {
12435
+ if (gobj_is_destroying(gobj)) return;
12436
+ if ($table && $table.tabulator) $table.tabulator.redraw();
12437
+ }, 30);
11807
12438
  }
11808
12439
  /************************************************************
11809
12440
  * Convert a record column value from backend
@@ -12111,8 +12742,16 @@ function ac_set_file_preview(gobj, event, kw, src) {
12111
12742
  return 0;
12112
12743
  }
12113
12744
  /************************************************************
12114
- * From internal form button for new rows
12115
- * or from load_tabulator_data() to load data from backend
12745
+ * From the add button of a table, outer or nested: the
12746
+ * reader's new row. A change of the reader's (`dataChanged`).
12747
+ * Tabulator keeps the object it is given and writes the
12748
+ * reader's edits into it: it is given a copy. A row added to a
12749
+ * nested table makes the row it lives in grow: the outer table
12750
+ * is the one redrawn.
12751
+ * {
12752
+ * table_id: the table (table_identity())
12753
+ * record: the new row, {} from the button
12754
+ * }
12116
12755
  ************************************************************/
12117
12756
  function ac_add_table_row(gobj, event, kw, src) {
12118
12757
  let table_id = kw.table_id;
@@ -12122,34 +12761,59 @@ function ac_add_table_row(gobj, event, kw, src) {
12122
12761
  log_error(`${gobj_short_name(gobj)}: EV_ADD_TABLE_ROW to a table that is gone: '${table_id}'`);
12123
12762
  return -1;
12124
12763
  }
12125
- let record = kw.record;
12126
- let loading = kw.loading;
12764
+ tabulator.addRow(json_deep_copy(is_object(kw.record) ? kw.record : {})).catch(function(error) {
12765
+ log_error(`${gobj_short_name(gobj)}: cannot add a table row: ${error}`);
12766
+ });
12767
+ redraw_table_later(gobj, $table.closest(".yui-tabulator-table"));
12768
+ return 0;
12769
+ }
12770
+ /************************************************************
12771
+ * From load_tabulator_data(): the rows of the record a table
12772
+ * shows, all of them in ONE call and one redraw. A row at a time
12773
+ * redrew every row of the table after each one: 300 rows took
12774
+ * 20 s, 300 with a nested table each 39 s.
12775
+ *
12776
+ * Tabulator keeps the objects it is given (Row.setData() copies
12777
+ * nothing) and a cell edit writes into them: handed the
12778
+ * `record`'s own, an edit wrote into the record, and Undo --
12779
+ * which loads the record again -- loaded the edit. It is given
12780
+ * a copy.
12781
+ *
12782
+ * And it says `dataChanged` INSIDE addData(), synchronously,
12783
+ * once per row: rows the FORM loads are muted there, whenever
12784
+ * they land -- also from a `tableBuilt` that comes after the
12785
+ * load returned, which is why no timer can tell them from the
12786
+ * reader's.
12787
+ * {
12788
+ * table_id: the table (table_identity())
12789
+ * rows: [record, ...]
12790
+ * }
12791
+ ************************************************************/
12792
+ function ac_load_table_rows(gobj, event, kw, src) {
12793
+ let table_id = kw.table_id;
12794
+ let $table = find_table(gobj, table_id);
12795
+ let tabulator = $table ? $table.tabulator : null;
12796
+ if (!tabulator) {
12797
+ log_error(`${gobj_short_name(gobj)}: EV_LOAD_TABLE_ROWS to a table that is gone: '${table_id}'`);
12798
+ return -1;
12799
+ }
12800
+ if (!is_array(kw.rows)) {
12801
+ log_error(`${gobj_short_name(gobj)}: EV_LOAD_TABLE_ROWS without rows: '${table_id}'`);
12802
+ return -1;
12803
+ }
12804
+ if (kw.rows.length === 0) return 0;
12805
+ let rows = json_deep_copy(kw.rows);
12127
12806
  let added;
12128
- if (loading) gobj.priv.loading_rows++;
12807
+ gobj.priv.loading_rows++;
12129
12808
  try {
12130
- added = tabulator.addRow(record);
12809
+ added = tabulator.addData(rows);
12131
12810
  } finally {
12132
- if (loading) gobj.priv.loading_rows--;
12133
- }
12134
- added.then(function(row) {
12135
- if (loading) {
12136
- let template = $table.template;
12137
- Object.entries(template).forEach(([key, template_value]) => {
12138
- if (str_in_list(template_value.flag, "table")) {
12139
- let $table_nested = row.getElement().querySelector(`.yui-tabulator-table-nested[name="${key}"]`);
12140
- if ($table_nested) load_tabulator_data(gobj, $table_nested, record[key]);
12141
- else log_error(sprintf("%s: nested table not found '%s'", gobj_short_name(gobj), key));
12142
- }
12143
- });
12144
- }
12145
- }).catch(function(error) {
12146
- log_error(`${gobj_short_name(gobj)}: cannot add a table row: ${error}`);
12811
+ gobj.priv.loading_rows--;
12812
+ }
12813
+ added.catch(function(error) {
12814
+ log_error(`${gobj_short_name(gobj)}: cannot load the rows of a table: ${error}`);
12147
12815
  });
12148
- setTimeout(function() {
12149
- if (gobj_is_destroying(gobj)) return;
12150
- let $target = loading ? $table : $table.closest(".yui-tabulator-table");
12151
- if ($target && $target.tabulator) $target.tabulator.redraw();
12152
- }, 30);
12816
+ redraw_table_later(gobj, $table);
12153
12817
  return 0;
12154
12818
  }
12155
12819
  /************************************************************
@@ -12339,6 +13003,11 @@ function create_gclass$17(gclass_name) {
12339
13003
  ac_add_table_row,
12340
13004
  null
12341
13005
  ],
13006
+ [
13007
+ "EV_LOAD_TABLE_ROWS",
13008
+ ac_load_table_rows,
13009
+ null
13010
+ ],
12342
13011
  [
12343
13012
  "EV_RECORD_CHANGED",
12344
13013
  ac_record_changed,
@@ -12411,6 +13080,7 @@ function create_gclass$17(gclass_name) {
12411
13080
  ["EV_UNDO_RECORD", 0],
12412
13081
  ["EV_CLEAR_RECORD", 0],
12413
13082
  ["EV_ADD_TABLE_ROW", 0],
13083
+ ["EV_LOAD_TABLE_ROWS", 0],
12414
13084
  ["EV_RECORD_CHANGED", 0],
12415
13085
  ["EV_COPY_RECORD", 0],
12416
13086
  ["EV_PASTE_RECORD", 0],
@@ -15021,7 +15691,7 @@ function g6_event_kw(evt) {
15021
15691
  * g6_canvas_tab_order.js
15022
15692
  *
15023
15693
  * The canvases of a G6 graph in the page's Tab order: the main
15024
- * one in its place, the other layers out of it.
15694
+ * one in its place, and NAMED; the other layers out of it.
15025
15695
  *
15026
15696
  * G6 stacks four canvases (background, main, label, transient)
15027
15697
  * and gives each of them `tabIndex = 1` (configCanvasDom, when it
@@ -15034,6 +15704,24 @@ function g6_event_kw(evt) {
15034
15704
  * to the graph's toolbars and buttons in DOM order; the other
15035
15705
  * layers receive nothing (`pointer-events: none`) and take -1.
15036
15706
  *
15707
+ * A canvas in the Tab order is a control, and a control has a
15708
+ * name: the main canvas carries a `title` and an `aria-label`,
15709
+ * through t() and each with its key, that say WHICH graph it is
15710
+ * -- the key is the view's, one per gclass ("json graph",
15711
+ * "schema graph"...). From 7.26.28 to 7.26.41 Tab landed on it
15712
+ * and a reader announced nothing. The keys are what a language
15713
+ * switch reaches (refresh_language()), as on any control. It is
15714
+ * a `region`, as maplibre makes its own canvas: a name on an
15715
+ * element with no role is one ARIA forbids, and a reader is not
15716
+ * bound to say it.
15717
+ *
15718
+ * And it can be SEEN when it has the focus: G6 writes `outline:
15719
+ * none` on its canvases, inline, so a keyboard that Tabbed onto
15720
+ * the graph had no sign of where it was. The main canvas takes
15721
+ * the `G6_MAIN_CANVAS` class, and g6_canvas_tab_order.css --
15722
+ * imported here, so it comes with the module to every view --
15723
+ * draws a ring on it at `:focus-visible`.
15724
+ *
15037
15725
  * Every view that creates a G6 Graph calls
15038
15726
  * keep_canvas_tab_order() right after `new Graph()`: the order is
15039
15727
  * put right each time G6 writes the 1 -- once the canvas is built
@@ -15046,10 +15734,11 @@ function g6_event_kw(evt) {
15046
15734
  * All Rights Reserved.
15047
15735
  ***********************************************************************/
15048
15736
  /************************************************************
15049
- * Main canvas 0, every other layer -1. Returns 0, or -1 with
15050
- * the cause logged.
15737
+ * Main canvas 0, named by `name_key`, and marked for its
15738
+ * focus ring; every other layer -1. Returns 0, or -1 with the
15739
+ * cause logged.
15051
15740
  ************************************************************/
15052
- function set_canvas_tab_order(gobj, graph) {
15741
+ function set_canvas_tab_order(gobj, graph, name_key) {
15053
15742
  let canvas = graph ? graph.getCanvas() : null;
15054
15743
  if (!canvas || typeof canvas.getLayers !== "function") {
15055
15744
  log_error(`${gobj_short_name(gobj)}: no canvas to set the Tab order of`);
@@ -15069,17 +15758,27 @@ function set_canvas_tab_order(gobj, graph) {
15069
15758
  ret = -1;
15070
15759
  continue;
15071
15760
  }
15072
- $el.tabIndex = name === "main" ? 0 : -1;
15761
+ if (name !== "main") {
15762
+ $el.tabIndex = -1;
15763
+ continue;
15764
+ }
15765
+ $el.tabIndex = 0;
15766
+ $el.classList.add("G6_MAIN_CANVAS");
15767
+ $el.setAttribute("role", "region");
15768
+ $el.setAttribute("title", t(name_key));
15769
+ $el.setAttribute("data-i18n-title", name_key);
15770
+ $el.setAttribute("aria-label", t(name_key));
15771
+ $el.setAttribute("data-i18n-aria-label", name_key);
15073
15772
  }
15074
15773
  return ret;
15075
15774
  }
15076
15775
  /************************************************************
15077
- * Keep the order for the life of `graph`: on every moment G6
15078
- * writes its own.
15776
+ * Keep the order, and the name, for the life of `graph`: on
15777
+ * every moment G6 writes its own.
15079
15778
  ************************************************************/
15080
- function keep_canvas_tab_order(gobj, graph) {
15779
+ function keep_canvas_tab_order(gobj, graph, name_key) {
15081
15780
  for (let ev of [GraphEvent.AFTER_CANVAS_INIT, GraphEvent.AFTER_RENDERER_CHANGE]) graph.on(ev, () => {
15082
- set_canvas_tab_order(gobj, graph);
15781
+ set_canvas_tab_order(gobj, graph, name_key);
15083
15782
  });
15084
15783
  }
15085
15784
  //#endregion
@@ -15588,7 +16287,7 @@ function build_graph$4(gobj) {
15588
16287
  behaviors: BEHAVIORS_READING$1.slice()
15589
16288
  });
15590
16289
  if (priv.theme) graph.setTheme(priv.theme);
15591
- keep_canvas_tab_order(gobj, graph);
16290
+ keep_canvas_tab_order(gobj, graph, "json graph");
15592
16291
  graph.on(NodeEvent.CLICK, (evt) => {
15593
16292
  gobj_send_event(gobj, "EV_NODE_CLICK", g6_event_kw(evt), gobj);
15594
16293
  });
@@ -19508,7 +20207,7 @@ function build_graph$3(gobj) {
19508
20207
  } catch (e) {
19509
20208
  log_error(`${gobj_short_name(gobj)}: the theme was refused: ${e}`);
19510
20209
  }
19511
- keep_canvas_tab_order(gobj, priv.graph);
20210
+ keep_canvas_tab_order(gobj, priv.graph, "fsm graph");
19512
20211
  priv.graph.on("aftertransform", () => {
19513
20212
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
19514
20213
  });
@@ -22151,6 +22850,17 @@ function close_gclass_view(handle) {
22151
22850
  * lands BEHIND its opener whatever number it is given, and
22152
22851
  * the button reads as one that did nothing.
22153
22852
  *
22853
+ * An opener in the place the shell gives every window -- its
22854
+ * window layer, the body while there is none -- gives the
22855
+ * viewer no `$parent` at all: the viewer takes that place too,
22856
+ * and FOLLOWS the shell with its opener (C_YUI_WINDOW's
22857
+ * ac_shell_changed). Up to 7.26.41 it was handed that element
22858
+ * by name, and a name is a choice its host made: a viewer
22859
+ * opened from the developer window between a logout and the
22860
+ * next login was told "the body", and stayed there after the
22861
+ * login -- above the new shell's dialogs -- while its opener
22862
+ * moved into the shell.
22863
+ *
22154
22864
  * Opened from no window: null -- the window layer of the
22155
22865
  * shell, where every window lives (the legacy '#top-layer'
22156
22866
  * when a page has one). It was the shell's popup layer: above
@@ -22160,7 +22870,11 @@ function window_layer_of(host) {
22160
22870
  let $c = gobj_read_pointer_attr(host, "$container");
22161
22871
  if ($c && typeof $c.closest === "function") {
22162
22872
  let $win = $c.closest(".C_YUI_WINDOW");
22163
- if ($win && $win.parentNode) return $win.parentNode;
22873
+ if ($win && $win.parentNode) {
22874
+ let $shell_place = yui_shell_window_layer(yui_shell_of(host)) || document.body;
22875
+ if ($win.parentNode === $shell_place) return null;
22876
+ return $win.parentNode;
22877
+ }
22164
22878
  }
22165
22879
  return typeof document !== "undefined" && document.getElementById("top-layer") || null;
22166
22880
  }
@@ -23021,7 +23735,7 @@ function build_graph$2(gobj) {
23021
23735
  behaviors: BEHAVIORS_READING.slice()
23022
23736
  });
23023
23737
  if (priv.theme) graph.setTheme(priv.theme);
23024
- keep_canvas_tab_order(gobj, graph);
23738
+ keep_canvas_tab_order(gobj, graph, "gobj tree graph");
23025
23739
  graph.on("aftertransform", () => {
23026
23740
  yui_graph_update_zoom(gobj_read_attr(gobj, "$container"), priv.graph);
23027
23741
  let z = priv.last_zoom;
@@ -24609,16 +25323,17 @@ function card_descriptor(it, show_label, badge_of) {
24609
25323
  text_node(label)
24610
25324
  ]);
24611
25325
  if (badge && !pinned) children.push(badge);
25326
+ let name_key = label || it.aria_label || it.id || "";
24612
25327
  let a_attrs = {
24613
25328
  class: "yui-nav-item yui-nav-card",
24614
25329
  href: it.route ? "#" + it.route : "#",
24615
25330
  "data-item-id": it.id,
24616
25331
  "data-route": it.route || "",
24617
25332
  "data-disabled": it.disabled ? "1" : "0",
24618
- "aria-label": label || it.id
25333
+ "aria-label": name_key
24619
25334
  };
24620
- if (label) a_attrs["data-i18n-aria-label"] = label;
24621
- let tip = it.tooltip || it.aria_label || label;
25335
+ if (name_key) a_attrs["data-i18n-aria-label"] = name_key;
25336
+ let tip = it.tooltip || it.aria_label || name_key;
24622
25337
  if (tip) {
24623
25338
  a_attrs.title = tip;
24624
25339
  a_attrs["data-i18n-title"] = tip;
@@ -25017,15 +25732,15 @@ function render_tabs(gobj, items) {
25017
25732
  "aria-hidden": "true"
25018
25733
  }]
25019
25734
  ]);
25020
- let label = it.name || "";
25735
+ let name_key = it.name || it.aria_label || it.id || "";
25021
25736
  let a_attrs = {
25022
25737
  href: it.route ? "#" + it.route : "#",
25023
25738
  "data-item-id": it.id,
25024
25739
  "data-route": it.route || "",
25025
- "aria-label": label || it.id
25740
+ "aria-label": name_key
25026
25741
  };
25027
- if (label) a_attrs["data-i18n-aria-label"] = label;
25028
- let tip = it.tooltip || it.aria_label || label;
25742
+ if (name_key) a_attrs["data-i18n-aria-label"] = name_key;
25743
+ let tip = it.tooltip || it.aria_label || name_key;
25029
25744
  if (tip) {
25030
25745
  a_attrs.title = tip;
25031
25746
  a_attrs["data-i18n-title"] = tip;
@@ -25105,16 +25820,17 @@ function render_breadcrumb(gobj, items) {
25105
25820
  text_node(label)
25106
25821
  ]);
25107
25822
  }
25823
+ let name_key = it.name || it.aria_label || it.id || "";
25108
25824
  let a_attrs = {
25109
25825
  class: "yui-nav-item yui-nav-crumb",
25110
25826
  href: it.route ? "#" + it.route : "#",
25111
25827
  "data-item-id": it.id,
25112
25828
  "data-route": it.route || "",
25113
25829
  "data-disabled": it.disabled ? "1" : "0",
25114
- "aria-label": it.name || it.id
25830
+ "aria-label": name_key
25115
25831
  };
25116
- if (it.name) a_attrs["data-i18n-aria-label"] = it.name;
25117
- let tip = it.tooltip || it.aria_label || it.name;
25832
+ if (name_key) a_attrs["data-i18n-aria-label"] = name_key;
25833
+ let tip = it.tooltip || it.aria_label || name_key;
25118
25834
  if (tip) {
25119
25835
  a_attrs.title = tip;
25120
25836
  a_attrs["data-i18n-title"] = tip;
@@ -25251,12 +25967,14 @@ function render_accordion(gobj, items) {
25251
25967
  "aria-controls": body_id
25252
25968
  };
25253
25969
  let head_badge = item_badge_node(gobj, it, false);
25254
- if (!empty_string(head_text)) {
25255
- head_attrs.i18n = head_text;
25256
- head_attrs.title = head_text;
25257
- head_attrs["data-i18n-title"] = head_text;
25258
- head_attrs["aria-label"] = head_text;
25259
- head_attrs["data-i18n-aria-label"] = head_text;
25970
+ if (!empty_string(head_text)) head_attrs.i18n = head_text;
25971
+ let name_key = it.name || it.aria_label || it.id || "";
25972
+ if (!empty_string(name_key)) {
25973
+ let tip = it.tooltip || it.aria_label || name_key;
25974
+ head_attrs.title = tip;
25975
+ head_attrs["data-i18n-title"] = tip;
25976
+ head_attrs["aria-label"] = name_key;
25977
+ head_attrs["data-i18n-aria-label"] = name_key;
25260
25978
  name_control_with_badge(head_attrs, head_badge);
25261
25979
  }
25262
25980
  let $hdr = createElement2([
@@ -25332,17 +26050,17 @@ function item_li(gobj, it, opts) {
25332
26050
  if (label_el) children.push(label_el);
25333
26051
  if (!pinned) children.push(badge_el);
25334
26052
  }
25335
- let aria_key = label || it.id;
26053
+ let name_key = it.name || it.aria_label || it.id || "";
25336
26054
  let a_attrs = {
25337
26055
  class: a_class,
25338
26056
  href: it.route ? "#" + it.route : "#",
25339
26057
  "data-item-id": it.id,
25340
26058
  "data-route": it.route || "",
25341
26059
  "data-disabled": it.disabled ? "1" : "0",
25342
- "aria-label": aria_key
26060
+ "aria-label": name_key
25343
26061
  };
25344
- if (label) a_attrs["data-i18n-aria-label"] = label;
25345
- let tip = it.tooltip || it.aria_label || label;
26062
+ if (name_key) a_attrs["data-i18n-aria-label"] = name_key;
26063
+ let tip = it.tooltip || it.aria_label || name_key;
25346
26064
  if (tip) {
25347
26065
  a_attrs.title = tip;
25348
26066
  a_attrs["data-i18n-title"] = tip;
@@ -25385,15 +26103,16 @@ function item_iconbar(gobj, it, opts) {
25385
26103
  if (label_el) children.push(label_el);
25386
26104
  }
25387
26105
  if (!pinned) children.push(badge_el);
26106
+ let name_key = it.name || it.aria_label || it.id || "";
25388
26107
  let a_attrs = {
25389
26108
  class: "yui-nav-item yui-nav-stacked",
25390
26109
  href: it.route ? "#" + it.route : "#",
25391
26110
  "data-item-id": it.id,
25392
26111
  "data-route": it.route || "",
25393
- "aria-label": label || it.id
26112
+ "aria-label": name_key
25394
26113
  };
25395
- if (label) a_attrs["data-i18n-aria-label"] = label;
25396
- let tip = it.tooltip || it.aria_label || label;
26114
+ if (name_key) a_attrs["data-i18n-aria-label"] = name_key;
26115
+ let tip = it.tooltip || it.aria_label || name_key;
25397
26116
  if (tip) {
25398
26117
  a_attrs.title = tip;
25399
26118
  a_attrs["data-i18n-title"] = tip;
@@ -25661,7 +26380,12 @@ function render_node(node) {
25661
26380
  "aria-hidden": "true"
25662
26381
  }]]
25663
26382
  ]);
25664
- row.push([
26383
+ if (node.label && node.data_label) row.push([
26384
+ "span",
26385
+ { class: "ROUTEMAP_NAME" },
26386
+ text_node(node.label)
26387
+ ]);
26388
+ else if (node.label) row.push([
25665
26389
  "span",
25666
26390
  {
25667
26391
  class: "ROUTEMAP_NAME",
@@ -25714,10 +26438,10 @@ function render_node(node) {
25714
26438
  href: "#" + node.route,
25715
26439
  title: node.route
25716
26440
  };
25717
- if (node.label) {
26441
+ if (node.label && !node.data_label) {
25718
26442
  a_attrs["aria-label"] = node.label;
25719
26443
  a_attrs["data-i18n-aria-label"] = node.label;
25720
- }
26444
+ } else a_attrs["aria-label"] = node.label || node.route;
25721
26445
  if (node.current) a_attrs["aria-current"] = "page";
25722
26446
  $row = createElement2([
25723
26447
  "a",
@@ -62878,7 +63602,7 @@ function build_graph$1(gobj) {
62878
63602
  plugins: []
62879
63603
  });
62880
63604
  graph.setTheme(priv.theme);
62881
- keep_canvas_tab_order(gobj, graph);
63605
+ keep_canvas_tab_order(gobj, graph, "treedb graph");
62882
63606
  priv._unforward_wheel = yui_graph_forward_wheel(graph, priv.$container, { selector: ".TREEDB_CARD, .TREEDB_PILLS" });
62883
63607
  graph.setLayout(layout);
62884
63608
  priv.graph_rendered = false;
@@ -74567,7 +75291,7 @@ function build_graph(gobj) {
74567
75291
  }
74568
75292
  priv.graph = graph;
74569
75293
  graph.setTheme(dark ? "dark" : "light");
74570
- keep_canvas_tab_order(gobj, graph);
75294
+ keep_canvas_tab_order(gobj, graph, "schema graph");
74571
75295
  graph.on("aftertransform", () => {
74572
75296
  yui_graph_update_zoom($container, priv.graph);
74573
75297
  });
@@ -76660,6 +77384,7 @@ var PRIVATE_DATA$1 = {
76660
77384
  host_ids: null,
76661
77385
  order_undo: null,
76662
77386
  diagram_gobj: null,
77387
+ retired_diagrams: null,
76663
77388
  dialog: null,
76664
77389
  dialog_gen: 0,
76665
77390
  dialog_kind: "",
@@ -76682,6 +77407,7 @@ var PRIVATE_DATA$1 = {
76682
77407
  export_view: null
76683
77408
  };
76684
77409
  var __gclass__$1 = null;
77410
+ var __described_seq__ = 0;
76685
77411
  /******************************
76686
77412
  * Framework Methods
76687
77413
  ******************************/
@@ -76695,6 +77421,7 @@ function mt_create$1(gobj) {
76695
77421
  priv.host_drafts = {};
76696
77422
  priv.host_ids = {};
76697
77423
  priv.save_queue = [];
77424
+ priv.retired_diagrams = [];
76698
77425
  build_ui$1(gobj);
76699
77426
  let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
76700
77427
  if (!subscriber) subscriber = gobj_parent(gobj);
@@ -76716,6 +77443,7 @@ function mt_stop$1(gobj) {
76716
77443
  if (shell) gobj_unsubscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
76717
77444
  close_dialog(gobj);
76718
77445
  destroy_diagram(gobj);
77446
+ destroy_retired_diagrams(gobj);
76719
77447
  }
76720
77448
  /***************************************************************
76721
77449
  * Framework Method: Destroy
@@ -77482,6 +78210,15 @@ function render(gobj) {
77482
78210
  * A card that opens something, with its own logical name. The
77483
78211
  * cards grid is the shell's, so a schema card and a nav card
77484
78212
  * look alike on purpose.
78213
+ *
78214
+ * `title` is the card's name: `{i18n: key}`, or `{text: data}` for
78215
+ * a name no locale holds (a treedb's id). The card is a control --
78216
+ * a role=button that Enter and Space press -- and a control is
78217
+ * NAMED: a title and an aria-label, with their keys when the name
78218
+ * is one, and its tags (the counts) as its description, which an
78219
+ * aria-label alone would hide from a reader. Up to 7.26.41 it had
78220
+ * neither, and the orphans card was handed its name translated,
78221
+ * in the language it was drawn in for good.
77485
78222
  ***************************************************************/
77486
78223
  function open_card(gobj, logical, title, icon, tags, event, kw) {
77487
78224
  let $tags = tags.map((tag) => {
@@ -77499,13 +78236,36 @@ function open_card(gobj, logical, title, icon, tags, event, kw) {
77499
78236
  ]] : `${tag.text}`
77500
78237
  ];
77501
78238
  });
78239
+ let tags_id = `yui-schema-described-${++__described_seq__}`;
78240
+ let card_attrs = {
78241
+ class: `${logical} yui-nav-card card`,
78242
+ role: "button",
78243
+ tabindex: "0",
78244
+ "aria-describedby": tags_id
78245
+ };
78246
+ let $name;
78247
+ if (title.i18n) {
78248
+ Object.assign(card_attrs, name_attrs(title.i18n, {}));
78249
+ $name = [
78250
+ "span",
78251
+ {
78252
+ class: `${logical}_NAME has-text-weight-semibold`,
78253
+ i18n: title.i18n
78254
+ },
78255
+ t(title.i18n)
78256
+ ];
78257
+ } else {
78258
+ card_attrs.title = String(title.text);
78259
+ card_attrs["aria-label"] = String(title.text);
78260
+ $name = [
78261
+ "span",
78262
+ { class: `${logical}_NAME has-text-weight-semibold` },
78263
+ text_node(title.text)
78264
+ ];
78265
+ }
77502
78266
  return [
77503
78267
  "div",
77504
- {
77505
- class: `${logical} yui-nav-card card`,
77506
- role: "button",
77507
- tabindex: "0"
77508
- },
78268
+ card_attrs,
77509
78269
  [[
77510
78270
  "div",
77511
78271
  { class: `${logical}_BODY card-content p-3` },
@@ -77518,16 +78278,16 @@ function open_card(gobj, logical, title, icon, tags, event, kw) {
77518
78278
  [[
77519
78279
  "span",
77520
78280
  { class: "icon" },
77521
- [["i", { class: icon }]]
77522
- ], [
77523
- "span",
77524
- { class: `${logical}_NAME has-text-weight-semibold` },
77525
- text_node(title)
77526
- ]]
78281
+ [["i", {
78282
+ class: icon,
78283
+ "aria-hidden": "true"
78284
+ }]]
78285
+ ], $name]
77527
78286
  ], [
77528
78287
  "div",
77529
78288
  {
77530
78289
  class: `${logical}_TAGS tags mt-2`,
78290
+ id: tags_id,
77531
78291
  style: "gap:.25rem;"
77532
78292
  },
77533
78293
  $tags
@@ -77575,9 +78335,9 @@ function render_treedbs(gobj, $body) {
77575
78335
  style: "is-warning is-light"
77576
78336
  }] : []
77577
78337
  ];
77578
- $cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", treedb.id, "yi-database", tags, "EV_SELECT_TREEDB", { treedb: treedb.id }));
78338
+ $cards.push(open_card(gobj, "SCHEMA_TREEDB_CARD", { text: treedb.id }, "yi-database", tags, "EV_SELECT_TREEDB", { treedb: treedb.id }));
77579
78339
  }
77580
- if (priv.model.orphan_topics.length > 0 || priv.model.orphan_cols.length > 0) $cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD", t("orphans"), "yi-triangle-exclamation", [{
78340
+ if (priv.model.orphan_topics.length > 0 || priv.model.orphan_cols.length > 0) $cards.push(open_card(gobj, "SCHEMA_ORPHAN_CARD", { i18n: "orphans" }, "yi-triangle-exclamation", [{
77581
78341
  i18n: "topics",
77582
78342
  text: priv.model.orphan_topics.length
77583
78343
  }, {
@@ -77618,22 +78378,33 @@ function render_topics(gobj, $body) {
77618
78378
  $actions.push(row_icon(gobj, "SCHEMA_TOPIC_EDIT", "yi-pen", "edit topic", "EV_EDIT_TOPIC", { topic: address }));
77619
78379
  $actions.push(row_icon(gobj, "SCHEMA_TOPIC_DELETE", "yi-trash", "delete topic", "EV_DELETE_TOPIC", { topic: address }));
77620
78380
  }
78381
+ let open_attrs = {
78382
+ class: "SCHEMA_TOPIC_OPEN has-text-weight-semibold",
78383
+ type: "button",
78384
+ title: topic.name,
78385
+ "aria-label": topic.name
78386
+ };
78387
+ let id_attrs = { class: "SCHEMA_TOPIC_ID is-size-7 yui-text-quiet" };
78388
+ if (ambiguous) {
78389
+ id_attrs.id = `yui-schema-described-${++__described_seq__}`;
78390
+ open_attrs["aria-describedby"] = id_attrs.id;
78391
+ }
77621
78392
  $rows.push([
77622
78393
  "tr",
77623
- {
77624
- class: "SCHEMA_TOPIC_ROW",
77625
- role: "button",
77626
- tabindex: "0"
77627
- },
78394
+ { class: "SCHEMA_TOPIC_ROW" },
77628
78395
  [
77629
78396
  [
77630
78397
  "td",
77631
78398
  { class: "SCHEMA_TOPIC_NAME" },
77632
78399
  [
77633
78400
  [
77634
- "span",
77635
- { class: "has-text-weight-semibold" },
77636
- text_node(topic.name)
78401
+ "button",
78402
+ open_attrs,
78403
+ text_node(topic.name),
78404
+ { click: (evt) => {
78405
+ evt.stopPropagation();
78406
+ gobj_send_event(gobj, "EV_SELECT_TOPIC", { topic: address }, gobj);
78407
+ } }
77637
78408
  ],
77638
78409
  topic.system_topic ? [
77639
78410
  "span",
@@ -77663,7 +78434,7 @@ function render_topics(gobj, $body) {
77663
78434
  ],
77664
78435
  ambiguous ? [
77665
78436
  "div",
77666
- { class: "SCHEMA_TOPIC_ID is-size-7 yui-text-quiet" },
78437
+ id_attrs,
77667
78438
  [[
77668
78439
  "code",
77669
78440
  {},
@@ -77705,17 +78476,10 @@ function render_topics(gobj, $body) {
77705
78476
  $actions
77706
78477
  ]
77707
78478
  ],
77708
- {
77709
- click: (evt) => {
77710
- if (evt.target.closest(".SCHEMA_TOPIC_ACTIONS")) return;
77711
- gobj_send_event(gobj, "EV_SELECT_TOPIC", { topic: address }, gobj);
77712
- },
77713
- keydown: (evt) => {
77714
- if (evt.key !== "Enter" && evt.key !== " ") return;
77715
- evt.preventDefault();
77716
- gobj_send_event(gobj, "EV_SELECT_TOPIC", { topic: address }, gobj);
77717
- }
77718
- }
78479
+ { click: (evt) => {
78480
+ if (evt.target.closest(".SCHEMA_TOPIC_ACTIONS")) return;
78481
+ gobj_send_event(gobj, "EV_SELECT_TOPIC", { topic: address }, gobj);
78482
+ } }
77719
78483
  ]);
77720
78484
  }
77721
78485
  let $table = createElement2([
@@ -78195,12 +78959,29 @@ function render_diagram(gobj) {
78195
78959
  gobj_start(diagram);
78196
78960
  gobj_send_event(diagram, "EV_SHOW", {}, gobj);
78197
78961
  }
78962
+ /***************************************************************
78963
+ * The drawing leaves the screen at once and is destroyed on the
78964
+ * next turn (EV_DESTROY_DIAGRAMS). It can be leaving because of
78965
+ * its own node click, which it publishes from inside G6's dispatch
78966
+ * of that click: stopped there, the gobj went from under its own
78967
+ * publication and the G6 graph from under its own event.
78968
+ ***************************************************************/
78198
78969
  function destroy_diagram(gobj) {
78199
78970
  let priv = gobj.priv;
78200
78971
  if (!priv.diagram_gobj) return;
78201
- gobj_stop(priv.diagram_gobj);
78202
- gobj_destroy(priv.diagram_gobj);
78972
+ let diagram = priv.diagram_gobj;
78203
78973
  priv.diagram_gobj = null;
78974
+ let $d = gobj_read_attr(diagram, "$container");
78975
+ if ($d && $d.parentNode) $d.parentNode.removeChild($d);
78976
+ priv.retired_diagrams.push(diagram);
78977
+ if (priv.retired_diagrams.length === 1) gobj_post_event(gobj, "EV_DESTROY_DIAGRAMS", {}, gobj);
78978
+ }
78979
+ function destroy_retired_diagrams(gobj) {
78980
+ let priv = gobj.priv;
78981
+ for (let diagram of priv.retired_diagrams.splice(0)) {
78982
+ if (gobj_is_running(diagram)) gobj_stop(diagram);
78983
+ gobj_destroy(diagram);
78984
+ }
78204
78985
  }
78205
78986
  /***************************
78206
78987
  * The forms
@@ -80189,6 +80970,13 @@ function ac_node_click(gobj, event, kw, src) {
80189
80970
  go(gobj, gobj.priv.treedb_id, topic, false, true);
80190
80971
  return reload_after_move(gobj);
80191
80972
  }
80973
+ /***************************************************************
80974
+ * The drawings left on the previous turn (destroy_diagram()).
80975
+ ***************************************************************/
80976
+ function ac_destroy_diagrams(gobj, event, kw, src) {
80977
+ destroy_retired_diagrams(gobj);
80978
+ return 0;
80979
+ }
80192
80980
  function ac_show_orphans(gobj, event, kw, src) {
80193
80981
  if (reload_first(gobj, event)) return -1;
80194
80982
  open_orphans(gobj);
@@ -80833,6 +81621,11 @@ function create_gclass$1(gclass_name) {
80833
81621
  "EV_EXPORT_VIEW",
80834
81622
  ac_export_view,
80835
81623
  null
81624
+ ],
81625
+ [
81626
+ "EV_DESTROY_DIAGRAMS",
81627
+ ac_destroy_diagrams,
81628
+ null
80836
81629
  ]
80837
81630
  ];
80838
81631
  const TREEDB_WIDE = [
@@ -81050,6 +81843,7 @@ function create_gclass$1(gclass_name) {
81050
81843
  ["EV_APPLY_IMPORT", 0],
81051
81844
  ["EV_CONFIRMED", 0],
81052
81845
  ["EV_NODE_CLICK", 0],
81846
+ ["EV_DESTROY_DIAGRAMS", 0],
81053
81847
  ["EV_POSITION_CHANGED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
81054
81848
  ["EV_RECORD_WRITTEN", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
81055
81849
  ["EV_SCHEMA_CHECKED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS]