@yuneta/gobj-ui 7.26.6 → 7.26.7
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 +74 -25
- package/dist/gobj-ui.cjs.js +635 -242
- package/dist/gobj-ui.es.js +635 -242
- package/index.js +5 -1
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +41 -0
- package/src/c_yui_form.js +140 -83
- package/src/c_yui_gclass.js +6 -2
- package/src/c_yui_gobj_tree_js.js +15 -4
- package/src/c_yui_json_graph.js +40 -13
- package/src/c_yui_map.js +115 -75
- package/src/c_yui_nav.js +53 -14
- package/src/c_yui_pager.js +14 -9
- package/src/c_yui_period.js +16 -6
- package/src/c_yui_shell.js +89 -31
- package/src/c_yui_treedb_topic_with_form.js +33 -44
- package/src/c_yui_uplot.js +1 -1
- package/src/c_yui_window.js +70 -24
- package/src/c_yui_window_manager.js +7 -3
- package/src/c_yui_wizard.js +23 -8
- package/src/delete_impact.js +5 -3
- package/src/form_json_field.js +116 -0
- package/src/form_json_field.test.js +43 -0
- package/src/form_json_field.wiring.test.js +137 -0
- package/src/schema_to_c.js +17 -1
- package/src/schema_to_c.test.js +7 -0
- package/src/shell_route_map.js +6 -0
- package/src/treedb_topics_transport.wiring.test.js +9 -1
- package/src/window_veto_back.wiring.test.js +101 -0
- package/src/wizard_chrome.wiring.test.js +87 -0
- package/src/yui_dev.js +10 -3
- package/src/yui_table_filter_clear.js +44 -44
- package/vite-plugin-yuneta-html.js +28 -6
package/src/c_yui_shell.js
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
SDATA, SDATA_END, data_type_t, event_flag_t, gclass_flag_t,
|
|
34
34
|
gclass_create, log_error, log_warning,
|
|
35
35
|
gobj_create, gobj_destroy,
|
|
36
|
-
gobj_start, gobj_stop,
|
|
36
|
+
gobj_start, gobj_stop, gobj_stop_children,
|
|
37
37
|
gobj_parent,
|
|
38
38
|
gobj_gclass_name,
|
|
39
39
|
gobj_publish_event,
|
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
refresh_language,
|
|
45
45
|
is_gobj,
|
|
46
46
|
gobj_has_event,
|
|
47
|
+
gobj_short_name,
|
|
47
48
|
gobj_is_destroying,
|
|
48
49
|
} from "@yuneta/gobj-js";
|
|
49
50
|
|
|
@@ -419,6 +420,10 @@ function mt_stop(gobj)
|
|
|
419
420
|
st.items = {};
|
|
420
421
|
st.active_route = null;
|
|
421
422
|
}
|
|
423
|
+
|
|
424
|
+
/* Whatever else the shell hosts — the site map window — stops
|
|
425
|
+
* with it, or destroying the shell destroys a RUNNING gobj. */
|
|
426
|
+
gobj_stop_children(gobj);
|
|
422
427
|
}
|
|
423
428
|
|
|
424
429
|
/***************************************************************
|
|
@@ -1795,12 +1800,13 @@ function build_toolbar_action_item(gobj, it)
|
|
|
1795
1800
|
btn_attrs["aria-haspopup"] = "menu";
|
|
1796
1801
|
btn_attrs["aria-expanded"] = "false";
|
|
1797
1802
|
}
|
|
1798
|
-
/* Hover tooltip: prefer explicit `tooltip`,
|
|
1799
|
-
*
|
|
1800
|
-
*
|
|
1803
|
+
/* Hover tooltip: prefer explicit `tooltip`, then `aria_label`
|
|
1804
|
+
* (usually the same intent — e.g. "Search (Ctrl+F)"), then the
|
|
1805
|
+
* name: every control carries a title. Skip only when all are
|
|
1806
|
+
* empty, so we don't emit `title=""` noise.
|
|
1801
1807
|
* Mirror the value in `data-i18n-title` so refresh_language()
|
|
1802
1808
|
* can re-translate the tooltip on language switch. */
|
|
1803
|
-
let tip = it.tooltip ||
|
|
1809
|
+
let tip = it.tooltip || i18n_aria;
|
|
1804
1810
|
if(tip) {
|
|
1805
1811
|
btn_attrs.title = tip;
|
|
1806
1812
|
btn_attrs["data-i18n-title"] = tip;
|
|
@@ -1866,6 +1872,11 @@ function build_toolbar_brand_item(gobj, it)
|
|
|
1866
1872
|
} else {
|
|
1867
1873
|
attrs.type = "button";
|
|
1868
1874
|
}
|
|
1875
|
+
let tip = it.tooltip || i18n_aria;
|
|
1876
|
+
if(tag !== "div" && tip) {
|
|
1877
|
+
attrs.title = tip;
|
|
1878
|
+
attrs["data-i18n-title"] = tip;
|
|
1879
|
+
}
|
|
1869
1880
|
let $item = createElement2([tag, attrs, [
|
|
1870
1881
|
["img", {class: "yui-toolbar-brand-logo",
|
|
1871
1882
|
src: it.logo, alt: alt}],
|
|
@@ -1904,7 +1915,7 @@ function build_toolbar_avatar_item(gobj, it)
|
|
|
1904
1915
|
attrs["aria-haspopup"] = "menu";
|
|
1905
1916
|
attrs["aria-expanded"] = "false";
|
|
1906
1917
|
}
|
|
1907
|
-
let tip = it.tooltip ||
|
|
1918
|
+
let tip = it.tooltip || i18n_aria;
|
|
1908
1919
|
if(tip) {
|
|
1909
1920
|
attrs.title = tip;
|
|
1910
1921
|
attrs["data-i18n-title"] = tip;
|
|
@@ -1991,7 +2002,7 @@ function build_toolbar_connection_item(gobj, it)
|
|
|
1991
2002
|
"aria-label": aria_key,
|
|
1992
2003
|
"data-i18n-aria-label": i18n_aria
|
|
1993
2004
|
};
|
|
1994
|
-
let tip = it.tooltip ||
|
|
2005
|
+
let tip = it.tooltip || i18n_aria;
|
|
1995
2006
|
if(tip) {
|
|
1996
2007
|
attrs.title = tip;
|
|
1997
2008
|
attrs["data-i18n-title"] = tip;
|
|
@@ -2219,6 +2230,14 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2219
2230
|
$panel.style.right = "auto";
|
|
2220
2231
|
$panel.style.left = `${Math.round(left)}px`;
|
|
2221
2232
|
}
|
|
2233
|
+
/* And inside it vertically: on a short phone screen a long menu
|
|
2234
|
+
* (one row per language) ran off the bottom, out of reach. It
|
|
2235
|
+
* scrolls inside itself instead (see `dismiss` below). */
|
|
2236
|
+
let max_h = window.innerHeight - Math.max(0, pos.top) - margin;
|
|
2237
|
+
if(max_h > 0) {
|
|
2238
|
+
$panel.style.maxHeight = `${Math.round(max_h)}px`;
|
|
2239
|
+
$panel.style.overflowY = "auto";
|
|
2240
|
+
}
|
|
2222
2241
|
|
|
2223
2242
|
/* Translate the lazily-built panel (see the note above). */
|
|
2224
2243
|
yui_shell_translate(gobj, $panel);
|
|
@@ -2242,7 +2261,15 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2242
2261
|
* trigger. Match native <select> UX and dismiss on either.
|
|
2243
2262
|
* Capture-phase + passive scroll so we hear all scrollers (any
|
|
2244
2263
|
* ancestor, not just window) without blocking them. */
|
|
2245
|
-
let dismiss = () =>
|
|
2264
|
+
let dismiss = (ev) => {
|
|
2265
|
+
/* The panel's own scroll is the reader reaching its last rows,
|
|
2266
|
+
* not a layout shift. */
|
|
2267
|
+
if(ev && ev.type === "scroll" && ev.target && ev.target !== document &&
|
|
2268
|
+
$panel.contains(ev.target)) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
close_toolbar_dropdown(gobj);
|
|
2272
|
+
};
|
|
2246
2273
|
document.addEventListener("scroll", dismiss, {capture: true, passive: true});
|
|
2247
2274
|
window.addEventListener("resize", dismiss);
|
|
2248
2275
|
|
|
@@ -2359,6 +2386,8 @@ function build_dropdown_row(gobj, sub, idx)
|
|
|
2359
2386
|
};
|
|
2360
2387
|
if(i18n_aria) {
|
|
2361
2388
|
attrs["data-i18n-aria-label"] = i18n_aria;
|
|
2389
|
+
attrs.title = i18n_aria;
|
|
2390
|
+
attrs["data-i18n-title"] = i18n_aria;
|
|
2362
2391
|
}
|
|
2363
2392
|
let $btn = createElement2(["button", attrs, children]);
|
|
2364
2393
|
$btn.addEventListener("click", ev => {
|
|
@@ -2442,6 +2471,7 @@ function push_escape(gobj, layer, handler)
|
|
|
2442
2471
|
{
|
|
2443
2472
|
let priv = gobj.priv;
|
|
2444
2473
|
if(!priv || !priv.escape_stack) {
|
|
2474
|
+
log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
|
|
2445
2475
|
return;
|
|
2446
2476
|
}
|
|
2447
2477
|
priv.escape_stack.push({ layer: layer, handler: handler });
|
|
@@ -2451,7 +2481,7 @@ function pop_escape(gobj, handler)
|
|
|
2451
2481
|
{
|
|
2452
2482
|
let priv = gobj.priv;
|
|
2453
2483
|
if(!priv || !priv.escape_stack) {
|
|
2454
|
-
return;
|
|
2484
|
+
return; /* not an error: an overlay closing after its shell was torn down */
|
|
2455
2485
|
}
|
|
2456
2486
|
let idx = priv.escape_stack.findIndex(e => e.handler === handler);
|
|
2457
2487
|
if(idx >= 0) {
|
|
@@ -2513,9 +2543,15 @@ function drain_overlays(gobj)
|
|
|
2513
2543
|
/* Survivors keep their relative order: the stack is a LIFO and a
|
|
2514
2544
|
* panel that outlives the drain must stay where it was, or Escape
|
|
2515
2545
|
* would start closing overlays in an order the user never built. */
|
|
2546
|
+
/* The stack is taken whole BEFORE any close runs: an overlay that
|
|
2547
|
+
* vetoes its close registers again (C_YUI_WINDOW), and popping
|
|
2548
|
+
* the live stack would pop that new entry and close it again,
|
|
2549
|
+
* for ever. Such an entry is newer than every survivor, so it
|
|
2550
|
+
* goes above them. */
|
|
2551
|
+
let entries = priv.overlay_stack.splice(0);
|
|
2516
2552
|
let kept = [];
|
|
2517
|
-
while(
|
|
2518
|
-
let entry =
|
|
2553
|
+
while(entries.length > 0) {
|
|
2554
|
+
let entry = entries.pop();
|
|
2519
2555
|
if(entry.keep_on_navigate) {
|
|
2520
2556
|
kept.unshift(entry);
|
|
2521
2557
|
continue;
|
|
@@ -2526,9 +2562,7 @@ function drain_overlays(gobj)
|
|
|
2526
2562
|
log_warning(`C_YUI_SHELL: overlay close on navigation failed: ${e}`);
|
|
2527
2563
|
}
|
|
2528
2564
|
}
|
|
2529
|
-
|
|
2530
|
-
priv.overlay_stack.push(entry);
|
|
2531
|
-
}
|
|
2565
|
+
priv.overlay_stack.unshift(...kept);
|
|
2532
2566
|
}
|
|
2533
2567
|
|
|
2534
2568
|
/* A URL rewrite moved the entry `st` tags to `hash`. When `st` is a live
|
|
@@ -2817,7 +2851,10 @@ function ac_nav_clicked(gobj, event, kw, src)
|
|
|
2817
2851
|
{
|
|
2818
2852
|
let route = (kw && kw.route) || "";
|
|
2819
2853
|
if(empty_string(route)) {
|
|
2820
|
-
|
|
2854
|
+
/* C_YUI_NAV publishes no click for an item without a route:
|
|
2855
|
+
* whoever sent this one is broken. */
|
|
2856
|
+
log_warning(`C_YUI_SHELL: ${event} with no route, from ${gobj_short_name(src)}`);
|
|
2857
|
+
return -1;
|
|
2821
2858
|
}
|
|
2822
2859
|
|
|
2823
2860
|
/* A click on a section returns to where the user was inside it.
|
|
@@ -2947,8 +2984,9 @@ function prune_route(shell_gobj, route)
|
|
|
2947
2984
|
|
|
2948
2985
|
function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
2949
2986
|
{
|
|
2950
|
-
let priv = shell_gobj.priv;
|
|
2987
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
2951
2988
|
if(!priv) {
|
|
2989
|
+
log_error(`C_YUI_SHELL: yui_shell_set_submenu('${parent_item_id}') — no shell`);
|
|
2952
2990
|
return -1;
|
|
2953
2991
|
}
|
|
2954
2992
|
let nav = find_secondary_nav(priv, parent_item_id);
|
|
@@ -3005,8 +3043,12 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
|
3005
3043
|
}
|
|
3006
3044
|
priv.dynamic_routes[parent_item_id] = new_routes;
|
|
3007
3045
|
|
|
3008
|
-
/* Push the new items into the nav (rebuilds its DOM in place)
|
|
3046
|
+
/* Push the new items into the nav (rebuilds its DOM in place), and
|
|
3047
|
+
* re-apply the translator: the rebuilt labels carry their keys as
|
|
3048
|
+
* raw text until somebody translates them (the same policy as the
|
|
3049
|
+
* index view below, and as C_YUI_NODE's projections). */
|
|
3009
3050
|
gobj_send_event(nav, "EV_SET_ITEMS", {items: items}, shell_gobj);
|
|
3051
|
+
yui_shell_translate(shell_gobj, gobj_read_attr(nav, "$container"));
|
|
3010
3052
|
|
|
3011
3053
|
/* Section-index landing (submenu.index): keep the synthesized
|
|
3012
3054
|
* target and any mounted index view (a "cards" C_YUI_NAV in the
|
|
@@ -3040,18 +3082,21 @@ function yui_shell_set_submenu(shell_gobj, parent_item_id, items)
|
|
|
3040
3082
|
* Global methods table
|
|
3041
3083
|
*---------------------------------------------*/
|
|
3042
3084
|
/***************************************************************
|
|
3043
|
-
* EV_CONNECTION_STATE
|
|
3044
|
-
*
|
|
3045
|
-
* to EVERY event of its shell with one attr
|
|
3046
|
-
* ask for
|
|
3047
|
-
*
|
|
3048
|
-
* and adding
|
|
3049
|
-
*
|
|
3050
|
-
*
|
|
3085
|
+
* EV_CONNECTION_STATE and EV_ICONS_CHANGED are OPTIONAL facts: a
|
|
3086
|
+
* view that needs one subscribes to it by name. An app that
|
|
3087
|
+
* subscribed to EVERY event of its shell with one attr
|
|
3088
|
+
* (`subscriber`) did not ask for them and does not declare them --
|
|
3089
|
+
* published to it anyway, each would be an FSM error in the app
|
|
3090
|
+
* every time it fires, and adding one to the shell a breaking
|
|
3091
|
+
* change for every such app (7.26.6 did exactly that with
|
|
3092
|
+
* EV_ICONS_CHANGED). So they reach only the subscribers that
|
|
3093
|
+
* declare them. Every other event of the shell goes out as before.
|
|
3051
3094
|
***************************************************************/
|
|
3095
|
+
const OPTIONAL_EVENTS = new Set(["EV_CONNECTION_STATE", "EV_ICONS_CHANGED"]);
|
|
3096
|
+
|
|
3052
3097
|
function mt_publication_pre_filter(gobj, subs, event, kw)
|
|
3053
3098
|
{
|
|
3054
|
-
if(event
|
|
3099
|
+
if(!OPTIONAL_EVENTS.has(event)) {
|
|
3055
3100
|
return 1;
|
|
3056
3101
|
}
|
|
3057
3102
|
let subscriber = subs && subs.subscriber;
|
|
@@ -3123,7 +3168,9 @@ function create_gclass(gclass_name)
|
|
|
3123
3168
|
* it was written, and called yui_shell_icons_changed). A class name
|
|
3124
3169
|
* picks its icon up by itself once the rule exists, but a view that
|
|
3125
3170
|
* DECIDED, at render time, whether a name is an icon at all -- the
|
|
3126
|
-
* icon cell of a table -- has to decide again.
|
|
3171
|
+
* icon cell of a table -- has to decide again. Delivered only to
|
|
3172
|
+
* the subscribers that declare it: see
|
|
3173
|
+
* mt_publication_pre_filter(). */
|
|
3127
3174
|
["EV_ICONS_CHANGED", event_flag_t.EVF_OUTPUT_EVENT
|
|
3128
3175
|
|event_flag_t.EVF_PUBLIC_EVENT
|
|
3129
3176
|
|event_flag_t.EVF_NO_WARN_SUBS],
|
|
@@ -3484,9 +3531,20 @@ function yui_shell_register_event_handler(shell_gobj, event, gclass)
|
|
|
3484
3531
|
|
|
3485
3532
|
/* Drawer helpers — toggle the off-canvas nav from the outside
|
|
3486
3533
|
* (e.g. a hamburger button in the toolbar). menu_id is optional. */
|
|
3487
|
-
function yui_shell_open_drawer(shell_gobj, menu_id)
|
|
3488
|
-
|
|
3489
|
-
|
|
3534
|
+
function yui_shell_open_drawer(shell_gobj, menu_id)
|
|
3535
|
+
{
|
|
3536
|
+
open_drawer(shell_gobj, menu_id);
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
function yui_shell_close_drawer(shell_gobj, menu_id)
|
|
3540
|
+
{
|
|
3541
|
+
close_drawer(shell_gobj, menu_id);
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
function yui_shell_toggle_drawer(shell_gobj, menu_id)
|
|
3545
|
+
{
|
|
3546
|
+
toggle_drawer(shell_gobj, menu_id);
|
|
3547
|
+
}
|
|
3490
3548
|
|
|
3491
3549
|
/* Escape priority chain — public API used by overlays that the
|
|
3492
3550
|
* shell does not own (modals from #4, future popups, custom
|
|
@@ -3612,7 +3670,7 @@ function yui_shell_set_translator(shell_gobj, t)
|
|
|
3612
3670
|
*
|
|
3613
3671
|
* The division of labour, unchanged: LIBRARY-built DOM is
|
|
3614
3672
|
* translated through here; APP view gclasses translate their own
|
|
3615
|
-
* DOM (they own a `t` — see
|
|
3673
|
+
* DOM (they own a `t` — see build_view_gobj).
|
|
3616
3674
|
*
|
|
3617
3675
|
* Silent no-op with no shell or no translator: an app that never
|
|
3618
3676
|
* registered one keeps the previous behaviour instead of losing
|
|
@@ -113,6 +113,7 @@ import {
|
|
|
113
113
|
yui_asset_ids, yui_asset_element, yui_asset_open_link, yui_asset_release
|
|
114
114
|
} from "./yui_asset.js";
|
|
115
115
|
import {delete_impact} from "./delete_impact.js";
|
|
116
|
+
import {parse_json_field} from "./form_json_field.js";
|
|
116
117
|
|
|
117
118
|
import "./c_yui_treedb_topic_with_form.css";
|
|
118
119
|
import {yui_shell_show_error} from "./shell_modals.js";
|
|
@@ -495,6 +496,7 @@ function mt_stop(gobj)
|
|
|
495
496
|
close_cell_file_dialog(gobj);
|
|
496
497
|
close_hook_choice(gobj);
|
|
497
498
|
drop_pending_assets(gobj);
|
|
499
|
+
drop_pending_pages(gobj);
|
|
498
500
|
table__destroy(gobj);
|
|
499
501
|
}
|
|
500
502
|
|
|
@@ -1785,6 +1787,7 @@ function create_tabulator(gobj)
|
|
|
1785
1787
|
try {
|
|
1786
1788
|
n = tabulator.getDataCount("active");
|
|
1787
1789
|
} catch(e) {
|
|
1790
|
+
log_warning(`${gobj_short_name(gobj)}: cannot count the table's rows: ${e}`);
|
|
1788
1791
|
n = 0;
|
|
1789
1792
|
}
|
|
1790
1793
|
}
|
|
@@ -2138,7 +2141,9 @@ function build_json_cell_preview(value)
|
|
|
2138
2141
|
['a', {
|
|
2139
2142
|
class: 'JSON_CELL',
|
|
2140
2143
|
title: t('show json'),
|
|
2141
|
-
'data-i18n-title': 'show json'
|
|
2144
|
+
'data-i18n-title': 'show json',
|
|
2145
|
+
'aria-label': t('show json'),
|
|
2146
|
+
'data-i18n-aria-label': 'show json'
|
|
2142
2147
|
}, [
|
|
2143
2148
|
['span', {class: 'JSON_CELL_ICON icon yi-eye'}],
|
|
2144
2149
|
['span', {class: 'JSON_CELL_PREVIEW'}, text]
|
|
@@ -3480,54 +3485,19 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation)
|
|
|
3480
3485
|
case "object":
|
|
3481
3486
|
case "dict":
|
|
3482
3487
|
case "template":
|
|
3483
|
-
if(is_string(value)) {
|
|
3484
|
-
// Come from the form
|
|
3485
|
-
try {
|
|
3486
|
-
value = JSON.parse(value);
|
|
3487
|
-
} catch (e) {
|
|
3488
|
-
value = {};
|
|
3489
|
-
}
|
|
3490
|
-
} else if(is_object(value)) {
|
|
3491
|
-
// Come from the table
|
|
3492
|
-
}
|
|
3493
|
-
if(!is_object(value)) {
|
|
3494
|
-
value = {};
|
|
3495
|
-
}
|
|
3496
|
-
break;
|
|
3497
3488
|
case "array":
|
|
3498
3489
|
case "list":
|
|
3499
|
-
if(is_string(value)) {
|
|
3500
|
-
// Come from the form
|
|
3501
|
-
try {
|
|
3502
|
-
value = JSON.parse(value);
|
|
3503
|
-
} catch (e) {
|
|
3504
|
-
value = [];
|
|
3505
|
-
}
|
|
3506
|
-
} else if(is_array(value)) {
|
|
3507
|
-
// Come from the table
|
|
3508
|
-
}
|
|
3509
|
-
if(!is_array(value)) {
|
|
3510
|
-
value = [];
|
|
3511
|
-
}
|
|
3512
|
-
break;
|
|
3513
3490
|
case "coordinates":
|
|
3514
|
-
case "blob":
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
}
|
|
3520
|
-
value = {};
|
|
3521
|
-
}
|
|
3522
|
-
|
|
3523
|
-
} else if(is_object(value)) {
|
|
3524
|
-
// Come from the table
|
|
3525
|
-
} else if(is_array(value)) {
|
|
3526
|
-
// Come from the table
|
|
3527
|
-
} else {
|
|
3528
|
-
value = {};
|
|
3491
|
+
case "blob": {
|
|
3492
|
+
/* A value that is no json of the column's shape becomes the
|
|
3493
|
+
* empty one -- said, not quiet. */
|
|
3494
|
+
let r = parse_json_field(value, field_desc.type);
|
|
3495
|
+
if(r.error) {
|
|
3496
|
+
log_warning(`${gobj_short_name(gobj)}: column '${col.id}' (${field_desc.type}) holds no valid json, taken as empty`);
|
|
3529
3497
|
}
|
|
3498
|
+
value = r.value;
|
|
3530
3499
|
break;
|
|
3500
|
+
}
|
|
3531
3501
|
|
|
3532
3502
|
case "enum":
|
|
3533
3503
|
switch(field_desc.real_type) {
|
|
@@ -4932,6 +4902,25 @@ function request_page(gobj, page, size)
|
|
|
4932
4902
|
});
|
|
4933
4903
|
}
|
|
4934
4904
|
|
|
4905
|
+
/************************************************************
|
|
4906
|
+
* The view stops: no page request is waited for any more. Each
|
|
4907
|
+
* one's watchdog would otherwise fire EV_PAGE_TIMEOUT on a gobj
|
|
4908
|
+
* stopped -- or destroyed -- 20 s later.
|
|
4909
|
+
************************************************************/
|
|
4910
|
+
function drop_pending_pages(gobj)
|
|
4911
|
+
{
|
|
4912
|
+
let priv = gobj.priv;
|
|
4913
|
+
let pending = priv._pending_pages || {};
|
|
4914
|
+
priv._pending_pages = {};
|
|
4915
|
+
for(let req_id of Object.keys(pending)) {
|
|
4916
|
+
let pend = pending[req_id];
|
|
4917
|
+
if(pend.timer) {
|
|
4918
|
+
window.clearTimeout(pend.timer);
|
|
4919
|
+
}
|
|
4920
|
+
pend.reject(new Error("the view stopped"));
|
|
4921
|
+
}
|
|
4922
|
+
}
|
|
4923
|
+
|
|
4935
4924
|
/************************************************************
|
|
4936
4925
|
* Settle a parked page request, however it ended.
|
|
4937
4926
|
************************************************************/
|
package/src/c_yui_uplot.js
CHANGED
package/src/c_yui_window.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Window - position fixed
|
|
5
5
|
*
|
|
6
|
-
* Copyright (c) 2025, ArtGins.
|
|
6
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
7
7
|
* All Rights Reserved.
|
|
8
8
|
***********************************************************************/
|
|
9
9
|
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
gclass_create,
|
|
15
15
|
event_flag_t,
|
|
16
16
|
log_error,
|
|
17
|
+
log_warning,
|
|
17
18
|
gobj_read_pointer_attr,
|
|
18
19
|
gobj_subscribe_event,
|
|
19
20
|
gobj_write_attr,
|
|
@@ -102,7 +103,7 @@ SDATA(data_type_t.DTP_STRING, "logical_class",0, "", "Logical UPPER_SNAKE
|
|
|
102
103
|
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"),
|
|
103
104
|
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"),
|
|
104
105
|
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"),
|
|
105
|
-
// TODO
|
|
106
|
+
// TODO declared, NOT implemented yet: focus, modal, keyboard (Escape does not close a window)
|
|
106
107
|
SDATA(data_type_t.DTP_POINTER, "focus", 0, null, "Brings focus to the element, can be a number or selector"),
|
|
107
108
|
SDATA(data_type_t.DTP_BOOLEAN, "modal", 0, false, "Enable modal mode"),
|
|
108
109
|
SDATA(data_type_t.DTP_BOOLEAN, "keyboard", 0, true, "Close window on ESC if not modal"),
|
|
@@ -188,15 +189,7 @@ function mt_create(gobj)
|
|
|
188
189
|
* is also why a navigation panel prefers a manager, and falls
|
|
189
190
|
* back to `keep_on_navigate` when the app has no dock.
|
|
190
191
|
* Retired in mt_destroy (covers every teardown path). */
|
|
191
|
-
|
|
192
|
-
if(shell) {
|
|
193
|
-
let overlay = yui_shell_register_overlay(
|
|
194
|
-
shell,
|
|
195
|
-
function() { close_window(gobj); },
|
|
196
|
-
{keep_on_navigate: gobj_read_bool_attr(gobj, "keep_on_navigate")}
|
|
197
|
-
);
|
|
198
|
-
gobj_write_attr(gobj, "back_overlay", overlay);
|
|
199
|
-
}
|
|
192
|
+
register_back_overlay(gobj);
|
|
200
193
|
}
|
|
201
194
|
|
|
202
195
|
/* Keep the window inside the viewport on a breakpoint change.
|
|
@@ -347,7 +340,7 @@ function build_default_header(gobj)
|
|
|
347
340
|
if(!empty_string(prefix)) {
|
|
348
341
|
items.push(
|
|
349
342
|
['span', {class: 'WINDOW_TITLE_PREFIX has-text-weight-semibold'},
|
|
350
|
-
prefix]
|
|
343
|
+
document.createTextNode(String(prefix))] // data, not markup
|
|
351
344
|
);
|
|
352
345
|
}
|
|
353
346
|
if(!empty_string(title)) {
|
|
@@ -400,7 +393,11 @@ function resolve_manager(gobj)
|
|
|
400
393
|
return null;
|
|
401
394
|
}
|
|
402
395
|
if(typeof m === "string") {
|
|
403
|
-
|
|
396
|
+
let name = m;
|
|
397
|
+
m = gobj_find_service(name, false) || null;
|
|
398
|
+
if(!m) {
|
|
399
|
+
log_warning(`${GCLASS_NAME}: window manager '${name}' not found: no dock, no minimize`);
|
|
400
|
+
}
|
|
404
401
|
gobj_write_attr(gobj, "manager", m);
|
|
405
402
|
}
|
|
406
403
|
return m;
|
|
@@ -550,7 +547,9 @@ function build_ui(gobj)
|
|
|
550
547
|
* Minimize (to dock)
|
|
551
548
|
*----------------------------*/
|
|
552
549
|
['button', {
|
|
553
|
-
class: 'WINDOW_MIN yui-wc wc-min', type: 'button',
|
|
550
|
+
class: 'WINDOW_MIN yui-wc wc-min', type: 'button',
|
|
551
|
+
title: t('minimize'), 'data-i18n-title': 'minimize',
|
|
552
|
+
'aria-label': t('minimize'), 'data-i18n-aria-label': 'minimize',
|
|
554
553
|
style: (gobj_read_bool_attr(gobj, "showMin") &&
|
|
555
554
|
gobj_read_pointer_attr(gobj, "manager")) ? '' : 'display:none;',
|
|
556
555
|
}, WC_MIN, {
|
|
@@ -563,7 +562,9 @@ function build_ui(gobj)
|
|
|
563
562
|
* Maximize / restore
|
|
564
563
|
*----------------------------*/
|
|
565
564
|
['button', {
|
|
566
|
-
class: 'WINDOW_MAX yui-wc wc-max', type: 'button',
|
|
565
|
+
class: 'WINDOW_MAX yui-wc wc-max', type: 'button',
|
|
566
|
+
title: t('maximize'), 'data-i18n-title': 'maximize',
|
|
567
|
+
'aria-label': t('maximize'), 'data-i18n-aria-label': 'maximize',
|
|
567
568
|
style: gobj_read_bool_attr(gobj, "showMax") ? '' : 'display:none;',
|
|
568
569
|
}, WC_MAX, {
|
|
569
570
|
click: (evt) => {
|
|
@@ -575,11 +576,13 @@ function build_ui(gobj)
|
|
|
575
576
|
* Close
|
|
576
577
|
*----------------------------*/
|
|
577
578
|
['button', {
|
|
578
|
-
class: 'WINDOW_CLOSE yui-wc wc-close', type: 'button',
|
|
579
|
+
class: 'WINDOW_CLOSE yui-wc wc-close', type: 'button',
|
|
580
|
+
title: t('close'), 'data-i18n-title': 'close',
|
|
581
|
+
'aria-label': t('close'), 'data-i18n-aria-label': 'close',
|
|
579
582
|
}, WC_CLOSE, {
|
|
580
583
|
click: (evt) => {
|
|
581
584
|
evt.stopPropagation();
|
|
582
|
-
|
|
585
|
+
gobj_send_event(gobj, "EV_CLOSE_WINDOW", {}, gobj);
|
|
583
586
|
}
|
|
584
587
|
}]
|
|
585
588
|
]]
|
|
@@ -752,6 +755,37 @@ function destroy_ui(gobj)
|
|
|
752
755
|
}
|
|
753
756
|
}
|
|
754
757
|
|
|
758
|
+
/************************************************************
|
|
759
|
+
* Register this floating window in the shell's overlay history,
|
|
760
|
+
* so the browser Back closes it.
|
|
761
|
+
*
|
|
762
|
+
* The shell takes the entry off its stack BEFORE it calls the
|
|
763
|
+
* close function (Back, or a route change draining overlays). When
|
|
764
|
+
* a subscriber of EV_WINDOW_TO_CLOSE vetoes the close, the window
|
|
765
|
+
* stays up with no entry: Back would no longer close it, and it
|
|
766
|
+
* would float over the next views. So a window that survives its
|
|
767
|
+
* own close function registers again.
|
|
768
|
+
************************************************************/
|
|
769
|
+
function register_back_overlay(gobj)
|
|
770
|
+
{
|
|
771
|
+
let shell = yui_shell_of(gobj);
|
|
772
|
+
if(!shell) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
let overlay = yui_shell_register_overlay(
|
|
776
|
+
shell,
|
|
777
|
+
function() {
|
|
778
|
+
gobj_write_attr(gobj, "back_overlay", null);
|
|
779
|
+
close_window(gobj);
|
|
780
|
+
if(!gobj_is_destroying(gobj) && !gobj_read_attr(gobj, "back_overlay")) {
|
|
781
|
+
register_back_overlay(gobj);
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{keep_on_navigate: gobj_read_bool_attr(gobj, "keep_on_navigate")}
|
|
785
|
+
);
|
|
786
|
+
gobj_write_attr(gobj, "back_overlay", overlay);
|
|
787
|
+
}
|
|
788
|
+
|
|
755
789
|
/************************************************************
|
|
756
790
|
*
|
|
757
791
|
************************************************************/
|
|
@@ -780,14 +814,22 @@ function close_window(gobj)
|
|
|
780
814
|
yui_shell_of(gobj), kw_close.warning,
|
|
781
815
|
{t: t, yes_label: "yes", no_label: "no", cancel_label: "cancel"}
|
|
782
816
|
).then(function(answer) {
|
|
783
|
-
if(answer
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
817
|
+
if(answer !== "yes") {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
/* The question was asynchronous: the window may have been
|
|
821
|
+
* torn down by another path while it was open. */
|
|
822
|
+
if(gobj_is_destroying(gobj)) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if(on_close) {
|
|
826
|
+
on_close();
|
|
827
|
+
}
|
|
828
|
+
if(gobj_is_running(gobj)) {
|
|
787
829
|
gobj_stop(gobj);
|
|
788
|
-
gobj_stop_children(gobj);
|
|
789
|
-
gobj_destroy(gobj);
|
|
790
830
|
}
|
|
831
|
+
gobj_stop_children(gobj);
|
|
832
|
+
gobj_destroy(gobj);
|
|
791
833
|
});
|
|
792
834
|
}
|
|
793
835
|
}
|
|
@@ -841,8 +883,12 @@ function set_max_icon(gobj, maximized)
|
|
|
841
883
|
}
|
|
842
884
|
let $btn = $container.querySelector('.wc-max');
|
|
843
885
|
if($btn) {
|
|
886
|
+
let key = maximized ? 'restore' : 'maximize';
|
|
844
887
|
$btn.innerHTML = maximized ? WC_RESTORE : WC_MAX;
|
|
845
|
-
$btn.setAttribute('
|
|
888
|
+
$btn.setAttribute('title', t(key));
|
|
889
|
+
$btn.setAttribute('data-i18n-title', key);
|
|
890
|
+
$btn.setAttribute('aria-label', t(key));
|
|
891
|
+
$btn.setAttribute('data-i18n-aria-label', key);
|
|
846
892
|
}
|
|
847
893
|
}
|
|
848
894
|
|
|
@@ -469,7 +469,8 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
469
469
|
let prefix = kw.title_prefix || "";
|
|
470
470
|
let label_items = [];
|
|
471
471
|
if(prefix) {
|
|
472
|
-
label_items.push(['span', {class: 'yui-dock-label-prefix'},
|
|
472
|
+
label_items.push(['span', {class: 'yui-dock-label-prefix'},
|
|
473
|
+
document.createTextNode(String(prefix))]); // data, not markup
|
|
473
474
|
}
|
|
474
475
|
if(title_key) {
|
|
475
476
|
label_items.push(
|
|
@@ -479,7 +480,8 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
479
480
|
}
|
|
480
481
|
if(label_items.length === 0) {
|
|
481
482
|
/* No split halves supplied (legacy caller): plain text. */
|
|
482
|
-
label_items.push(['span', {class: 'yui-dock-label-kind'},
|
|
483
|
+
label_items.push(['span', {class: 'yui-dock-label-kind'},
|
|
484
|
+
document.createTextNode(String(title))]); // data, not markup
|
|
483
485
|
}
|
|
484
486
|
|
|
485
487
|
let entry = {gobj: win, $chip: null, minimized: false};
|
|
@@ -496,7 +498,9 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
496
498
|
), [
|
|
497
499
|
chip_lead(kw.icon),
|
|
498
500
|
['span', {class: 'yui-dock-label'}, label_items],
|
|
499
|
-
['button', {class: 'yui-dock-close', type: 'button',
|
|
501
|
+
['button', {class: 'yui-dock-close', type: 'button',
|
|
502
|
+
title: t('close'), 'data-i18n-title': 'close',
|
|
503
|
+
'aria-label': t('close'), 'data-i18n-aria-label': 'close'}, WC_X, {
|
|
500
504
|
click: (evt) => {
|
|
501
505
|
evt.stopPropagation();
|
|
502
506
|
gobj_send_event(entry.gobj, "EV_CLOSE_WINDOW", {}, gobj);
|