@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.
- package/README.md +510 -78
- package/dist/gobj-ui.cjs.js +1120 -326
- package/dist/gobj-ui.es.js +1120 -326
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +971 -177
- package/src/c_g6_nodes_tree.js +3 -2
- package/src/c_yui_form.js +261 -154
- package/src/c_yui_fsm_graph.js +3 -2
- package/src/c_yui_gobj_tree_js.js +3 -2
- package/src/c_yui_json_graph.js +3 -2
- package/src/c_yui_nav.js +43 -28
- package/src/c_yui_node.js +51 -7
- package/src/c_yui_schema_editor.css +16 -0
- package/src/c_yui_schema_editor.js +110 -20
- package/src/c_yui_shell.css +4 -1
- package/src/c_yui_shell.js +227 -61
- package/src/c_yui_treedb_schema.js +3 -2
- package/src/c_yui_window.js +373 -62
- package/src/c_yui_window_manager.js +80 -8
- package/src/escape_taken.js +58 -0
- package/src/form_close_asks_for_edits.wiring.test.js +6 -3
- package/src/form_json_editor_names.js +3 -1
- package/src/form_json_editor_names.wiring.test.js +8 -4
- package/src/form_json_expand.wiring.test.js +6 -3
- package/src/form_json_field.wiring.test.js +8 -4
- package/src/form_label_i18n.wiring.test.js +10 -5
- package/src/form_table_edits_ask.wiring.test.js +18 -8
- package/src/form_table_rearm.wiring.test.js +13 -5
- package/src/form_table_rows.wiring.test.js +489 -0
- package/src/form_table_validator.wiring.test.js +8 -4
- package/src/form_template_field.wiring.test.js +6 -3
- package/src/g6_canvas_tab_order.css +29 -0
- package/src/g6_canvas_tab_order.js +41 -9
- package/src/g6_canvas_tab_order.wiring.test.js +107 -1
- package/src/g6_long_press_clock.test.js +8 -3
- package/src/i18n_key_functions.js +81 -27
- package/src/i18n_key_functions.test.js +402 -4
- package/src/modal_guard_back.wiring.test.js +188 -0
- package/src/named_controls.wiring.test.js +323 -19
- package/src/nav_cards_helpers.js +9 -4
- package/src/nav_item_badge.wiring.test.js +163 -15
- package/src/node_nav_events.wiring.test.js +93 -1
- package/src/route_map_model.js +59 -10
- package/src/route_map_model.test.js +90 -0
- package/src/schema_editor_diagram_click.wiring.test.js +277 -0
- package/src/schema_editor_openers.wiring.test.js +283 -0
- package/src/shell_dialog_names.wiring.test.js +149 -0
- package/src/shell_escape_taken.wiring.test.js +142 -0
- package/src/shell_focus_trap.js +30 -2
- package/src/shell_focus_trap.test.js +90 -6
- package/src/shell_modals.js +113 -22
- package/src/shell_route_map.js +15 -3
- package/src/shell_section_index.js +3 -1
- package/src/table_editor_name.wiring.test.js +10 -5
- package/src/treedb_column_title.wiring.test.js +8 -4
- package/src/treedb_graph_writes.wiring.test.js +6 -3
- package/src/treedb_json_drill.wiring.test.js +6 -3
- package/src/uplot_add_serie.test.js +6 -3
- package/src/uplot_ink.test.js +8 -4
- package/src/window_dialog.wiring.test.js +486 -0
- package/src/window_dock_band.wiring.test.js +189 -0
- package/src/window_layer.wiring.test.js +114 -0
- package/src/window_rect_rounding.wiring.test.js +121 -0
- package/src/yui_gclass_view.js +16 -1
- package/src/yui_tabulator_i18n.js +31 -1
- package/src/yui_tabulator_i18n.test.js +46 -0
package/src/c_yui_shell.js
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
gobj_has_event,
|
|
49
49
|
gobj_short_name,
|
|
50
50
|
gobj_is_destroying,
|
|
51
|
+
gobj_post_event,
|
|
51
52
|
} from "@yuneta/gobj-js";
|
|
52
53
|
|
|
53
54
|
import {
|
|
@@ -59,6 +60,7 @@ import {
|
|
|
59
60
|
import {
|
|
60
61
|
activate_focus_trap_on,
|
|
61
62
|
} from "./shell_focus_trap.js";
|
|
63
|
+
import {escape_is_taken} from "./escape_taken.js";
|
|
62
64
|
|
|
63
65
|
import {
|
|
64
66
|
classify_toolbar_item,
|
|
@@ -81,11 +83,15 @@ import {
|
|
|
81
83
|
***************************************************************/
|
|
82
84
|
const GCLASS_NAME = "C_YUI_SHELL";
|
|
83
85
|
|
|
84
|
-
/*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* one shell; tests that create
|
|
88
|
-
|
|
86
|
+
/* The shells alive on the page, in the order they were built. The
|
|
87
|
+
* LAST one is the fallback of yui_shell_of() when the caller is not
|
|
88
|
+
* a shell descendant (e.g. a floating C_YUI_WINDOW parented to the
|
|
89
|
+
* app gobj). Real apps have exactly one shell; tests that create
|
|
90
|
+
* several get the most recent. A list, not one pointer: with two
|
|
91
|
+
* alive, destroying the last left the fallback EMPTY, and the
|
|
92
|
+
* windows it held went to the body -- above the dialogs of the shell
|
|
93
|
+
* that remained -- up to 7.26.41. They go to that shell now. */
|
|
94
|
+
let __live_shells__ = [];
|
|
89
95
|
|
|
90
96
|
/* The gobjs that keep DOM in a shell's layers without being its
|
|
91
97
|
* children: a C_YUI_WINDOW parented to the app, the dock of
|
|
@@ -146,6 +152,11 @@ let PRIVATE_DATA = {
|
|
|
146
152
|
nav_badges: {},
|
|
147
153
|
/* The live region a changed badge is said in (announce_badge()). */
|
|
148
154
|
badge_status: null,
|
|
155
|
+
/* What this turn of the loop said in it: [{source, message}], in
|
|
156
|
+
* the order the changes came, and whether the EV_CLOSE_BADGE_NEWS
|
|
157
|
+
* that ends the turn is posted (announce_badge()). */
|
|
158
|
+
badge_news: [],
|
|
159
|
+
badge_news_closing: false,
|
|
149
160
|
/* Parent item id -> the items yui_shell_set_submenu() put in place:
|
|
150
161
|
* menu items as much as the declared ones (nav_item_of). */
|
|
151
162
|
dynamic_items: {},
|
|
@@ -274,7 +285,7 @@ function mt_create(gobj)
|
|
|
274
285
|
gobj_subscribe_event(gobj, null, {}, subscriber);
|
|
275
286
|
}
|
|
276
287
|
|
|
277
|
-
|
|
288
|
+
__live_shells__.push(gobj);
|
|
278
289
|
|
|
279
290
|
build_ui(gobj);
|
|
280
291
|
|
|
@@ -509,7 +520,10 @@ function mt_start(gobj)
|
|
|
509
520
|
/* Global Escape: route to the top handler of the escape stack,
|
|
510
521
|
* not to a hardcoded "close all drawers". Modals and popups
|
|
511
522
|
* push themselves on top of drawers, so Escape closes them
|
|
512
|
-
* first; second Escape closes the drawer underneath; etc.
|
|
523
|
+
* first; second Escape closes the drawer underneath; etc.
|
|
524
|
+
* An Escape that what it was typed in took first is not the
|
|
525
|
+
* overlay's (escape_is_taken()): up to 7.26.42 one typed in a
|
|
526
|
+
* table cell being edited closed the whole dialog. */
|
|
513
527
|
priv.keydown_handler = ev => {
|
|
514
528
|
if(ev.key !== "Escape" && ev.keyCode !== 27) {
|
|
515
529
|
return;
|
|
@@ -517,6 +531,9 @@ function mt_start(gobj)
|
|
|
517
531
|
if(priv.escape_stack.length === 0) {
|
|
518
532
|
return;
|
|
519
533
|
}
|
|
534
|
+
if(escape_is_taken(ev)) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
520
537
|
let top = priv.escape_stack[priv.escape_stack.length - 1];
|
|
521
538
|
ev.preventDefault();
|
|
522
539
|
ev.stopPropagation();
|
|
@@ -634,8 +651,9 @@ function mt_destroy(gobj)
|
|
|
634
651
|
* when stop is skipped. */
|
|
635
652
|
close_toolbar_dropdown(gobj);
|
|
636
653
|
|
|
637
|
-
|
|
638
|
-
|
|
654
|
+
let live_idx = __live_shells__.indexOf(gobj);
|
|
655
|
+
if(live_idx >= 0) {
|
|
656
|
+
__live_shells__.splice(live_idx, 1);
|
|
639
657
|
}
|
|
640
658
|
|
|
641
659
|
let $container = gobj_read_attr(gobj, "$container");
|
|
@@ -649,9 +667,10 @@ function mt_destroy(gobj)
|
|
|
649
667
|
* shell, so a logout that destroyed the shell left such a window
|
|
650
668
|
* alive with its DOM detached, and the next shell never placed it
|
|
651
669
|
* again -- invisible, and the first click on its menu entry closed
|
|
652
|
-
* the invisible one. Told now -- with
|
|
653
|
-
* the place they find is the
|
|
654
|
-
*
|
|
670
|
+
* the invisible one. Told now -- with this shell out of
|
|
671
|
+
* `__live_shells__`, so the place they find is the shell that
|
|
672
|
+
* remains (the body when none does), and with the $container
|
|
673
|
+
* still readable, so each can tell whether it was inside. */
|
|
655
674
|
tell_shell_watchers(gobj);
|
|
656
675
|
|
|
657
676
|
gobj_write_attr(gobj, "$container", null);
|
|
@@ -1260,9 +1279,13 @@ function instantiate_menus(gobj, config)
|
|
|
1260
1279
|
items: sub.items,
|
|
1261
1280
|
render: { [zone_id]: render_cfg }
|
|
1262
1281
|
};
|
|
1282
|
+
/* Named by the entry that opens it, as the nav names
|
|
1283
|
+
* the entry (`name`, else `aria_label`, else id): a
|
|
1284
|
+
* parent with only an `aria_label` gave a navigation
|
|
1285
|
+
* called "navigation" up to 7.26.41. */
|
|
1263
1286
|
let nav = instantiate_nav_in_zone(
|
|
1264
1287
|
gobj, submenu_def, sub_menu_id, zone_id, "secondary",
|
|
1265
|
-
item.name || ""
|
|
1288
|
+
item.name || item.aria_label || item.id || ""
|
|
1266
1289
|
);
|
|
1267
1290
|
/* Hidden until owning primary is active. */
|
|
1268
1291
|
let $c = gobj_read_attr(nav, "$container");
|
|
@@ -1983,16 +2006,21 @@ function build_toolbar_action_item(gobj, it)
|
|
|
1983
2006
|
text_node(it.name)]);
|
|
1984
2007
|
}
|
|
1985
2008
|
|
|
1986
|
-
|
|
1987
|
-
|
|
2009
|
+
/* The name of an item: its `aria_label` -- the toolbar's explicit
|
|
2010
|
+
* name, which wins over a visible `name` that is often a symbol
|
|
2011
|
+
* ("ES/EN") --, else its `name`, else its id: a KEY in every case,
|
|
2012
|
+
* translated by the pass that translates the labels and reached by
|
|
2013
|
+
* a language switch, with a title. Up to 7.26.41 an item with
|
|
2014
|
+
* neither was named by its raw id, with no key and no title. */
|
|
2015
|
+
let name_key = it.aria_label || it.name || it.id || "";
|
|
1988
2016
|
let btn_attrs = {
|
|
1989
2017
|
class: "navbar-item yui-toolbar-item is-unselectable",
|
|
1990
2018
|
type: "button",
|
|
1991
2019
|
"data-toolbar-item-id": it.id || "",
|
|
1992
|
-
"aria-label":
|
|
2020
|
+
"aria-label": name_key
|
|
1993
2021
|
};
|
|
1994
|
-
if(
|
|
1995
|
-
btn_attrs["data-i18n-aria-label"] =
|
|
2022
|
+
if(name_key) {
|
|
2023
|
+
btn_attrs["data-i18n-aria-label"] = name_key;
|
|
1996
2024
|
}
|
|
1997
2025
|
let action_type = (it.action && it.action.type) || "";
|
|
1998
2026
|
if(action_type === "dropdown") {
|
|
@@ -2001,16 +2029,16 @@ function build_toolbar_action_item(gobj, it)
|
|
|
2001
2029
|
}
|
|
2002
2030
|
/* Hover tooltip: prefer explicit `tooltip`, then `aria_label`
|
|
2003
2031
|
* (usually the same intent — e.g. "Search (Ctrl+F)"), then the
|
|
2004
|
-
* name: every control carries a title. Skip only
|
|
2005
|
-
* empty, so we don't emit `title=""` noise.
|
|
2032
|
+
* name, then the id: every control carries a title. Skip only
|
|
2033
|
+
* when all are empty, so we don't emit `title=""` noise.
|
|
2006
2034
|
* Mirror the value in `data-i18n-title` so refresh_language()
|
|
2007
2035
|
* can re-translate the tooltip on language switch. */
|
|
2008
|
-
let tip = it.tooltip ||
|
|
2036
|
+
let tip = it.tooltip || name_key;
|
|
2009
2037
|
if(tip) {
|
|
2010
2038
|
btn_attrs.title = tip;
|
|
2011
2039
|
btn_attrs["data-i18n-title"] = tip;
|
|
2012
2040
|
}
|
|
2013
|
-
if(badge && !empty_string(
|
|
2041
|
+
if(badge && !empty_string(name_key)) {
|
|
2014
2042
|
/* The count is part of its name: inside a <button> the badge is
|
|
2015
2043
|
* no node of its own for a reader (yui_badge.js). */
|
|
2016
2044
|
name_control_with_badge(btn_attrs, badge);
|
|
@@ -2105,21 +2133,24 @@ function build_toolbar_brand_item(gobj, it)
|
|
|
2105
2133
|
function build_toolbar_avatar_item(gobj, it)
|
|
2106
2134
|
{
|
|
2107
2135
|
let priv = gobj.priv;
|
|
2108
|
-
|
|
2109
|
-
|
|
2136
|
+
/* Named by its `aria_label`, else its `name`, else the library's
|
|
2137
|
+
* own "user menu" -- the KEY its aria-label shows from the start.
|
|
2138
|
+
* Up to 7.26.41 an avatar with neither showed its raw id until a
|
|
2139
|
+
* pass of translation replaced it with that key. */
|
|
2140
|
+
const name_key = it.aria_label || it.name || "user menu";
|
|
2110
2141
|
let action_type = (it.action && it.action.type) || "";
|
|
2111
2142
|
let attrs = {
|
|
2112
2143
|
class: "navbar-item yui-toolbar-item yui-toolbar-avatar is-unselectable",
|
|
2113
2144
|
type: "button",
|
|
2114
2145
|
"data-toolbar-item-id": it.id || "",
|
|
2115
|
-
"aria-label":
|
|
2116
|
-
"data-i18n-aria-label":
|
|
2146
|
+
"aria-label": name_key,
|
|
2147
|
+
"data-i18n-aria-label": name_key
|
|
2117
2148
|
};
|
|
2118
2149
|
if(action_type === "dropdown") {
|
|
2119
2150
|
attrs["aria-haspopup"] = "menu";
|
|
2120
2151
|
attrs["aria-expanded"] = "false";
|
|
2121
2152
|
}
|
|
2122
|
-
let tip = it.tooltip ||
|
|
2153
|
+
let tip = it.tooltip || name_key;
|
|
2123
2154
|
if(tip) {
|
|
2124
2155
|
attrs.title = tip;
|
|
2125
2156
|
attrs["data-i18n-title"] = tip;
|
|
@@ -2172,6 +2203,10 @@ function refresh_avatars(gobj)
|
|
|
2172
2203
|
* Wire an optional secondary (right-click) action on a
|
|
2173
2204
|
* toolbar item. Same action shape as `action`; used e.g. by
|
|
2174
2205
|
* the connection indicator to open a dev panel on right-click.
|
|
2206
|
+
* The item goes along whole, with the secondary action in place
|
|
2207
|
+
* of its own: a menu it opens is named as its trigger is (up to
|
|
2208
|
+
* 7.26.42 it went as `{id, action}`, and the menu was named by
|
|
2209
|
+
* the raw id whatever the item declared).
|
|
2175
2210
|
************************************************************/
|
|
2176
2211
|
function attach_context_action(gobj, $item, it)
|
|
2177
2212
|
{
|
|
@@ -2181,7 +2216,7 @@ function attach_context_action(gobj, $item, it)
|
|
|
2181
2216
|
$item.addEventListener("contextmenu", ev => {
|
|
2182
2217
|
ev.preventDefault();
|
|
2183
2218
|
handle_toolbar_action(
|
|
2184
|
-
gobj, {
|
|
2219
|
+
gobj, {...it, action: it.context_action}, $item
|
|
2185
2220
|
);
|
|
2186
2221
|
});
|
|
2187
2222
|
}
|
|
@@ -2196,17 +2231,19 @@ function attach_context_action(gobj, $item, it)
|
|
|
2196
2231
|
function build_toolbar_connection_item(gobj, it)
|
|
2197
2232
|
{
|
|
2198
2233
|
let priv = gobj.priv;
|
|
2199
|
-
|
|
2200
|
-
|
|
2234
|
+
/* Named as the avatar is: its `aria_label`, else its `name`, else
|
|
2235
|
+
* the library's own "backend connection", the key its aria-label
|
|
2236
|
+
* shows from the start (it was the raw id until a pass). */
|
|
2237
|
+
const name_key = it.aria_label || it.name || "backend connection";
|
|
2201
2238
|
let attrs = {
|
|
2202
2239
|
class: "navbar-item yui-toolbar-item yui-toolbar-conn " +
|
|
2203
2240
|
"is-unselectable is-disconnected",
|
|
2204
2241
|
type: "button",
|
|
2205
2242
|
"data-toolbar-item-id": it.id || "",
|
|
2206
|
-
"aria-label":
|
|
2207
|
-
"data-i18n-aria-label":
|
|
2243
|
+
"aria-label": name_key,
|
|
2244
|
+
"data-i18n-aria-label": name_key
|
|
2208
2245
|
};
|
|
2209
|
-
let tip = it.tooltip ||
|
|
2246
|
+
let tip = it.tooltip || name_key;
|
|
2210
2247
|
if(tip) {
|
|
2211
2248
|
attrs.title = tip;
|
|
2212
2249
|
attrs["data-i18n-title"] = tip;
|
|
@@ -2372,14 +2409,22 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2372
2409
|
* The fix is below: when the host has registered a translator
|
|
2373
2410
|
* (yui_shell_set_translator), re-apply it to the freshly built
|
|
2374
2411
|
* $panel. Rebuilt per open ⇒ a later language switch is picked
|
|
2375
|
-
* up the next time the dropdown opens.
|
|
2376
|
-
|
|
2377
|
-
|
|
2412
|
+
* up the next time the dropdown opens.
|
|
2413
|
+
*
|
|
2414
|
+
* The menu is named as its trigger is (build_toolbar_*): its
|
|
2415
|
+
* `aria_label`, else its `name`, else -- an avatar -- the library's
|
|
2416
|
+
* "user menu", else its id; a KEY in every case. Up to 7.26.41 a
|
|
2417
|
+
* menu whose trigger had neither `aria_label` nor `name` was named
|
|
2418
|
+
* by the raw id, and an avatar's said "user" where its button said
|
|
2419
|
+
* "user menu". (A brand that opens a menu, which no app has, names
|
|
2420
|
+
* it by its `aria_label` or its id, not by its wordmark.) */
|
|
2421
|
+
const name_key = (item && (item.aria_label || item.name ||
|
|
2422
|
+
(classify_toolbar_item(item) === "avatar" ? "user menu" : item.id))) || "menu";
|
|
2378
2423
|
let $panel = createElement2(["div", {
|
|
2379
2424
|
class: "yui-toolbar-dropdown-panel",
|
|
2380
2425
|
role: "menu",
|
|
2381
|
-
"aria-label":
|
|
2382
|
-
"data-i18n-aria-label":
|
|
2426
|
+
"aria-label": name_key,
|
|
2427
|
+
"data-i18n-aria-label": name_key,
|
|
2383
2428
|
"data-toolbar-dropdown-for": (item && item.id) || ""
|
|
2384
2429
|
}]);
|
|
2385
2430
|
|
|
@@ -2578,20 +2623,22 @@ function build_dropdown_row(gobj, sub, idx)
|
|
|
2578
2623
|
children.push(["span", {class: "yui-toolbar-dropdown-check"},
|
|
2579
2624
|
["i", {class: "yi-check", "aria-hidden": "true"}]]);
|
|
2580
2625
|
|
|
2581
|
-
|
|
2582
|
-
|
|
2626
|
+
/* Named as a toolbar item is: its `aria_label`, else its `name`,
|
|
2627
|
+
* else its id -- a KEY in every case, with a title (an icon row
|
|
2628
|
+
* without a name was named by its raw id up to 7.26.41). */
|
|
2629
|
+
let name_key = sub.aria_label || sub.name || sub.id || "";
|
|
2583
2630
|
let attrs = {
|
|
2584
2631
|
class: "yui-toolbar-dropdown-item" + (sub.selected ? " is-selected" : ""),
|
|
2585
2632
|
type: "button",
|
|
2586
2633
|
role: "menuitemradio",
|
|
2587
2634
|
"aria-checked": sub.selected ? "true" : "false",
|
|
2588
2635
|
"data-dropdown-item-id": sub.id || "",
|
|
2589
|
-
"aria-label":
|
|
2636
|
+
"aria-label": name_key
|
|
2590
2637
|
};
|
|
2591
|
-
if(
|
|
2592
|
-
attrs["data-i18n-aria-label"] =
|
|
2593
|
-
attrs.title =
|
|
2594
|
-
attrs["data-i18n-title"] =
|
|
2638
|
+
if(name_key) {
|
|
2639
|
+
attrs["data-i18n-aria-label"] = name_key;
|
|
2640
|
+
attrs.title = name_key;
|
|
2641
|
+
attrs["data-i18n-title"] = name_key;
|
|
2595
2642
|
}
|
|
2596
2643
|
let $btn = createElement2(["button", attrs, children]);
|
|
2597
2644
|
$btn.addEventListener("click", ev => {
|
|
@@ -3338,26 +3385,103 @@ function shell_navs(gobj)
|
|
|
3338
3385
|
* `name_key` is the key of the control's name; the phrase is a
|
|
3339
3386
|
* key of its own, so a language orders and punctuates it its
|
|
3340
3387
|
* way. Said once: a live region needs no re-translation.
|
|
3388
|
+
*
|
|
3389
|
+
* `source` names the badge ("toolbar:<id>", "nav:<id>"). Every
|
|
3390
|
+
* change of ONE turn of the loop is said in ONE message, a line
|
|
3391
|
+
* of the region each, in the order they came; a badge that moves
|
|
3392
|
+
* twice in the turn says its last count. Up to 7.26.41 each
|
|
3393
|
+
* change replaced the region's text, and a reader hears the
|
|
3394
|
+
* region as it is when the turn is over: of two changes in one
|
|
3395
|
+
* action (a feed that updates the toolbar's count and the menu
|
|
3396
|
+
* entry's, which is what a count is for) only the second was
|
|
3397
|
+
* ever said. The turn is closed by EV_CLOSE_BADGE_NEWS, posted to
|
|
3398
|
+
* the shell by its first change: gobj_post_event() delivers it on
|
|
3399
|
+
* the next turn, through the machine -- a deferral, not a time.
|
|
3341
3400
|
************************************************************/
|
|
3342
|
-
function announce_badge(gobj, name_key, text)
|
|
3401
|
+
function announce_badge(gobj, name_key, text, source)
|
|
3343
3402
|
{
|
|
3344
3403
|
let priv = gobj.priv;
|
|
3345
|
-
|
|
3346
|
-
|
|
3404
|
+
if(gobj_is_destroying(gobj)) {
|
|
3405
|
+
return; /* its live region goes with it: nobody is left to tell */
|
|
3406
|
+
}
|
|
3407
|
+
if(!priv.badge_status) {
|
|
3347
3408
|
log_error(`C_YUI_SHELL: no live region to say badge '${name_key}': ${text}`);
|
|
3348
3409
|
return;
|
|
3349
3410
|
}
|
|
3350
3411
|
let message;
|
|
3351
3412
|
if(typeof priv.translator === "function") {
|
|
3352
3413
|
const tr = priv.translator;
|
|
3353
|
-
|
|
3414
|
+
/* Not escaped: i18next escapes an interpolated value for HTML
|
|
3415
|
+
* by default, and the message is a text node -- a name such as
|
|
3416
|
+
* "Événements d'alarme" was read "d'alarme". */
|
|
3417
|
+
message = tr("{{name}}, {{n}}", {
|
|
3418
|
+
name: tr(name_key), n: text, interpolation: {escapeValue: false}
|
|
3419
|
+
});
|
|
3354
3420
|
} else {
|
|
3355
3421
|
message = `${name_key}, ${text}`;
|
|
3356
3422
|
}
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3423
|
+
|
|
3424
|
+
let news = priv.badge_news.find((n) => n.source === source);
|
|
3425
|
+
if(news) {
|
|
3426
|
+
news.message = message;
|
|
3427
|
+
} else {
|
|
3428
|
+
priv.badge_news.push({source: source, message: message});
|
|
3429
|
+
}
|
|
3430
|
+
write_badge_news(gobj);
|
|
3431
|
+
|
|
3432
|
+
if(priv.badge_news_closing) {
|
|
3433
|
+
return;
|
|
3434
|
+
}
|
|
3435
|
+
if(gobj_post_event(gobj, "EV_CLOSE_BADGE_NEWS", {}, gobj) < 0) {
|
|
3436
|
+
/* Error already logged. Nothing will close this turn's message:
|
|
3437
|
+
* it is closed now, and the next change is said on its own. */
|
|
3438
|
+
priv.badge_news = [];
|
|
3439
|
+
return;
|
|
3440
|
+
}
|
|
3441
|
+
priv.badge_news_closing = true;
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3444
|
+
/************************************************************
|
|
3445
|
+
* A badge whose count went away in the turn it changed: what
|
|
3446
|
+
* this turn said of it is no news any more -- the badge shows
|
|
3447
|
+
* nothing -- and is taken out of the message.
|
|
3448
|
+
************************************************************/
|
|
3449
|
+
function forget_badge_news(gobj, source)
|
|
3450
|
+
{
|
|
3451
|
+
let priv = gobj.priv;
|
|
3452
|
+
let idx = priv.badge_news.findIndex((n) => n.source === source);
|
|
3453
|
+
if(idx < 0) {
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
priv.badge_news.splice(idx, 1);
|
|
3457
|
+
write_badge_news(gobj);
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
/************************************************************
|
|
3461
|
+
* The live region holds the message of this turn: a line per
|
|
3462
|
+
* change, so a reader separates them without a punctuation of
|
|
3463
|
+
* ours, and two controls of one name with one count say it once.
|
|
3464
|
+
*
|
|
3465
|
+
* Written whole, and with new nodes, even when it reads the same:
|
|
3466
|
+
* the callers filter what is no news, and a count that went away
|
|
3467
|
+
* and came back IS news -- a new text node is a change a reader
|
|
3468
|
+
* announces.
|
|
3469
|
+
************************************************************/
|
|
3470
|
+
function write_badge_news(gobj)
|
|
3471
|
+
{
|
|
3472
|
+
let priv = gobj.priv;
|
|
3473
|
+
let said = [];
|
|
3474
|
+
let $lines = [];
|
|
3475
|
+
for(let news of priv.badge_news) {
|
|
3476
|
+
if(said.includes(news.message)) {
|
|
3477
|
+
continue;
|
|
3478
|
+
}
|
|
3479
|
+
said.push(news.message);
|
|
3480
|
+
$lines.push(createElement2(
|
|
3481
|
+
["div", {class: "SHELL_BADGE_NEWS"}, text_node(news.message)]
|
|
3482
|
+
));
|
|
3483
|
+
}
|
|
3484
|
+
priv.badge_status.replaceChildren(...$lines);
|
|
3361
3485
|
}
|
|
3362
3486
|
|
|
3363
3487
|
/************************************************************
|
|
@@ -3479,6 +3603,21 @@ function ac_back_wait_timeout(gobj, event, kw, src)
|
|
|
3479
3603
|
return 0;
|
|
3480
3604
|
}
|
|
3481
3605
|
|
|
3606
|
+
/************************************************************
|
|
3607
|
+
* The turn in which badges changed is over (posted by the first
|
|
3608
|
+
* change, announce_badge()): the message in the live region is
|
|
3609
|
+
* complete, and a reader hears it as it stands. The next change
|
|
3610
|
+
* starts a message of its own -- added to this one, it would say
|
|
3611
|
+
* again what was already said.
|
|
3612
|
+
************************************************************/
|
|
3613
|
+
function ac_close_badge_news(gobj, event, kw, src)
|
|
3614
|
+
{
|
|
3615
|
+
let priv = gobj.priv;
|
|
3616
|
+
priv.badge_news = [];
|
|
3617
|
+
priv.badge_news_closing = false;
|
|
3618
|
+
return 0;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3482
3621
|
/************************************************************
|
|
3483
3622
|
* Drawer backdrop click on a C_YUI_NAV child: the nav publishes
|
|
3484
3623
|
* this so the shell can close the drawer through the canonical
|
|
@@ -3737,7 +3876,10 @@ function create_gclass(gclass_name)
|
|
|
3737
3876
|
["EV_NAV_ITEM_CLOSE", ac_nav_item_close, null],
|
|
3738
3877
|
/* The wait for a history.back() of the shell is over: the
|
|
3739
3878
|
* timer of defer_route() says so. */
|
|
3740
|
-
["EV_BACK_WAIT_TIMEOUT", ac_back_wait_timeout, null]
|
|
3879
|
+
["EV_BACK_WAIT_TIMEOUT", ac_back_wait_timeout, null],
|
|
3880
|
+
/* The turn in which badges changed is over: posted to itself
|
|
3881
|
+
* by announce_badge(). */
|
|
3882
|
+
["EV_CLOSE_BADGE_NEWS", ac_close_badge_news, null]
|
|
3741
3883
|
]]
|
|
3742
3884
|
];
|
|
3743
3885
|
|
|
@@ -3745,6 +3887,7 @@ function create_gclass(gclass_name)
|
|
|
3745
3887
|
["EV_NAV_CLICKED", 0],
|
|
3746
3888
|
["EV_DRAWER_CLOSE_REQUESTED", 0],
|
|
3747
3889
|
["EV_BACK_WAIT_TIMEOUT", 0],
|
|
3890
|
+
["EV_CLOSE_BADGE_NEWS", 0],
|
|
3748
3891
|
["EV_NAV_ITEM_CLOSE", event_flag_t.EVF_OUTPUT_EVENT
|
|
3749
3892
|
|event_flag_t.EVF_PUBLIC_EVENT
|
|
3750
3893
|
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
@@ -4005,9 +4148,9 @@ function yui_shell_previous_route(shell_gobj)
|
|
|
4005
4148
|
/************************************************************
|
|
4006
4149
|
* Resolve the shell that governs `gobj`: the nearest
|
|
4007
4150
|
* C_YUI_SHELL ancestor, else the last shell created on the
|
|
4008
|
-
* page (apps have exactly one). Null when
|
|
4009
|
-
* callers must degrade loudly (shell_modals
|
|
4010
|
-
* and resolves the safe default).
|
|
4151
|
+
* page that is still alive (apps have exactly one). Null when
|
|
4152
|
+
* no shell exists — callers must degrade loudly (shell_modals
|
|
4153
|
+
* logs a warning and resolves the safe default).
|
|
4011
4154
|
************************************************************/
|
|
4012
4155
|
function yui_shell_of(gobj)
|
|
4013
4156
|
{
|
|
@@ -4018,7 +4161,7 @@ function yui_shell_of(gobj)
|
|
|
4018
4161
|
}
|
|
4019
4162
|
g = gobj_parent(g);
|
|
4020
4163
|
}
|
|
4021
|
-
return
|
|
4164
|
+
return __live_shells__.length > 0 ? __live_shells__[__live_shells__.length - 1] : null;
|
|
4022
4165
|
}
|
|
4023
4166
|
|
|
4024
4167
|
/************************************************************
|
|
@@ -4061,6 +4204,20 @@ function yui_shell_window_layer(shell_gobj)
|
|
|
4061
4204
|
return priv.window_layer || (priv.layers && priv.layers.overlay) || null;
|
|
4062
4205
|
}
|
|
4063
4206
|
|
|
4207
|
+
/************************************************************
|
|
4208
|
+
* The DOM where a MODAL C_YUI_WINDOW lives when its host names
|
|
4209
|
+
* no `$parent`: the shell's dialog layer, with the dialogs of
|
|
4210
|
+
* shell_modals.js -- above the drawer, the dock and every other
|
|
4211
|
+
* window, below the toasts. Null with no shell.
|
|
4212
|
+
************************************************************/
|
|
4213
|
+
function yui_shell_modal_layer(shell_gobj)
|
|
4214
|
+
{
|
|
4215
|
+
if(!shell_gobj || !shell_gobj.priv || !shell_gobj.priv.layers) {
|
|
4216
|
+
return null;
|
|
4217
|
+
}
|
|
4218
|
+
return shell_gobj.priv.layers.modal || null;
|
|
4219
|
+
}
|
|
4220
|
+
|
|
4064
4221
|
/************************************************************
|
|
4065
4222
|
* Put a window on top of the others: the next number of ONE
|
|
4066
4223
|
* counter, the same for a window of the dock and for a floating
|
|
@@ -4542,7 +4699,9 @@ function yui_shell_set_toolbar_item_badge(shell_gobj, item_id, value, tone)
|
|
|
4542
4699
|
if(now && now !== before) {
|
|
4543
4700
|
let $item = $badge.closest("[data-toolbar-item-id]");
|
|
4544
4701
|
const name_key = ($item && $item.getAttribute("data-i18n-aria-label")) || item_id;
|
|
4545
|
-
announce_badge(shell_gobj, /* i18n: data */ name_key, now);
|
|
4702
|
+
announce_badge(shell_gobj, /* i18n: data */ name_key, now, `toolbar:${item_id}`);
|
|
4703
|
+
} else if(!now) {
|
|
4704
|
+
forget_badge_news(shell_gobj, `toolbar:${item_id}`);
|
|
4546
4705
|
}
|
|
4547
4706
|
}
|
|
4548
4707
|
|
|
@@ -4603,10 +4762,16 @@ function yui_shell_set_nav_item_badge(shell_gobj, item_id, value, tone)
|
|
|
4603
4762
|
}
|
|
4604
4763
|
|
|
4605
4764
|
/* Said ONCE, here, with the item's name -- not by each nav that
|
|
4606
|
-
* draws the item (a rail, an icon bar, a drawer)
|
|
4765
|
+
* draws the item (a rail, an icon bar, a drawer) -- and by the name
|
|
4766
|
+
* the nav gives it: its `name`, else its `aria_label`, else its id
|
|
4767
|
+
* (c_yui_nav.js item_li). Up to 7.26.41 an entry that declares only
|
|
4768
|
+
* an `aria_label` was said by its id. */
|
|
4607
4769
|
let now = badge_text(badge);
|
|
4608
4770
|
if(now && now !== before) {
|
|
4609
|
-
announce_badge(shell_gobj, /* i18n: data */ item.name || item_id,
|
|
4771
|
+
announce_badge(shell_gobj, /* i18n: data */ item.name || item.aria_label || item_id,
|
|
4772
|
+
now, `nav:${item_id}`);
|
|
4773
|
+
} else if(!now) {
|
|
4774
|
+
forget_badge_news(shell_gobj, `nav:${item_id}`);
|
|
4610
4775
|
}
|
|
4611
4776
|
}
|
|
4612
4777
|
|
|
@@ -4638,6 +4803,7 @@ export {
|
|
|
4638
4803
|
yui_shell_of,
|
|
4639
4804
|
yui_shell_zone,
|
|
4640
4805
|
yui_shell_window_layer,
|
|
4806
|
+
yui_shell_modal_layer,
|
|
4641
4807
|
yui_shell_raise_window,
|
|
4642
4808
|
yui_shell_watch_changes,
|
|
4643
4809
|
yui_shell_unwatch_changes,
|
|
@@ -661,8 +661,9 @@ function build_graph(gobj)
|
|
|
661
661
|
graph.setTheme(dark ? "dark" : "light");
|
|
662
662
|
|
|
663
663
|
/* Tab goes from the graph to its own buttons: the main canvas in
|
|
664
|
-
* the Tab order, the other layers out
|
|
665
|
-
|
|
664
|
+
* the Tab order, named for what it draws, the other layers out
|
|
665
|
+
* (g6_canvas_tab_order.js). */
|
|
666
|
+
keep_canvas_tab_order(gobj, graph, "schema graph");
|
|
666
667
|
|
|
667
668
|
/* The readout follows ANY camera change, the wheel included -- a
|
|
668
669
|
* wheel notch passes through no action of ours. */
|