@yuneta/gobj-ui 7.26.47 → 7.26.49
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 +139 -31
- package/dist/gobj-ui.cjs.js +327 -16
- package/dist/gobj-ui.es.js +327 -16
- package/package.json +2 -2
- package/scripts/validate-locales.mjs +734 -76
- package/src/c_yui_form.js +63 -5
- package/src/c_yui_gobj_tree_js.js +37 -4
- package/src/c_yui_shell.js +360 -3
- package/src/form_table_rows.wiring.test.js +32 -0
- package/src/form_time_cell_editor.js +20 -5
- package/src/form_time_cell_editor.test.js +73 -0
- package/src/form_time_field.wiring.test.js +71 -0
- package/src/gobj_tree_camera.wiring.test.js +185 -0
- package/src/overlay_marker_after_back.wiring.test.js +3 -0
- package/src/shell_focus_trap.js +21 -0
- package/src/shell_focus_trap.test.js +52 -0
- package/src/shell_history_debt.wiring.test.js +456 -0
- package/src/shell_stop_overlays.wiring.test.js +55 -2
package/dist/gobj-ui.es.js
CHANGED
|
@@ -143,6 +143,10 @@ function yui_tint(colour) {
|
|
|
143
143
|
* stack, which was for good: a panel that only moved (taken out
|
|
144
144
|
* and put back, its trap never released) lost its trap. It is
|
|
145
145
|
* skipped now, and leaves the stack only by its release().
|
|
146
|
+
* The first time a trap is skipped it is said, once: a panel out
|
|
147
|
+
* of the document whose owner is gone keeps its keydown listener
|
|
148
|
+
* until a release() that will never come, and up to gobj-ui
|
|
149
|
+
* 7.26.48 nothing said so (twenty such panels, twenty listeners).
|
|
146
150
|
*
|
|
147
151
|
* No gobj dependency: only gobj-js's logger. The optional
|
|
148
152
|
* second argument lets callers inject a mock document object
|
|
@@ -157,9 +161,16 @@ function top_trap() {
|
|
|
157
161
|
for (let i = __trap_stack__.length - 1; i >= 0; i--) {
|
|
158
162
|
let trap = __trap_stack__[i];
|
|
159
163
|
if (trap.$panel.isConnected !== false) return trap;
|
|
164
|
+
if (!trap.said_skipped) {
|
|
165
|
+
trap.said_skipped = true;
|
|
166
|
+
log_warning(`focus trap: its panel (${panel_name(trap.$panel)}) is out of the document and the trap was not released; it is skipped, and its listener stays until its release() (an owner torn down with it open?)`);
|
|
167
|
+
}
|
|
160
168
|
}
|
|
161
169
|
return null;
|
|
162
170
|
}
|
|
171
|
+
function panel_name($panel) {
|
|
172
|
+
return (typeof $panel.className === "string" ? $panel.className.trim() : "") || "a panel with no class";
|
|
173
|
+
}
|
|
163
174
|
function is_drawn(el) {
|
|
164
175
|
if (typeof el.checkVisibility === "function") return el.checkVisibility();
|
|
165
176
|
if (typeof el.getClientRects === "function") return el.getClientRects().length > 0;
|
|
@@ -1210,6 +1221,9 @@ function secondary_nav_renders(item, layout) {
|
|
|
1210
1221
|
***************************************************************/
|
|
1211
1222
|
var GCLASS_NAME$22 = "C_YUI_SHELL";
|
|
1212
1223
|
var __live_shells__ = [];
|
|
1224
|
+
var __retiring_shell__ = null;
|
|
1225
|
+
var __dead_entries__ = /* @__PURE__ */ new Set();
|
|
1226
|
+
var __orphan_back__ = null;
|
|
1213
1227
|
var __shell_watchers__ = [];
|
|
1214
1228
|
var __window_z__ = 10;
|
|
1215
1229
|
var ZONE_IDS = [
|
|
@@ -1275,6 +1289,7 @@ var PRIVATE_DATA$22 = {
|
|
|
1275
1289
|
deferred_timer: null,
|
|
1276
1290
|
expected_pop_ids: [],
|
|
1277
1291
|
given_up: null,
|
|
1292
|
+
own_entries: [],
|
|
1278
1293
|
popstate_handler: null,
|
|
1279
1294
|
avatar_provider: null,
|
|
1280
1295
|
avatar_nodes: [],
|
|
@@ -1375,6 +1390,7 @@ function mt_start$21(gobj) {
|
|
|
1375
1390
|
log_warning(`C_YUI_SHELL: restoring '${p.restore_hash}' failed: ${e}`);
|
|
1376
1391
|
}
|
|
1377
1392
|
p.restore_hash = "";
|
|
1393
|
+
if (retire_dead_entries(gobj)) return;
|
|
1378
1394
|
push_pending_markers(gobj);
|
|
1379
1395
|
}
|
|
1380
1396
|
return;
|
|
@@ -1400,6 +1416,8 @@ function mt_start$21(gobj) {
|
|
|
1400
1416
|
}
|
|
1401
1417
|
};
|
|
1402
1418
|
window.addEventListener("popstate", priv.popstate_handler);
|
|
1419
|
+
keep_dead_entries_across_reload();
|
|
1420
|
+
adopt_orphan_back(gobj);
|
|
1403
1421
|
}
|
|
1404
1422
|
priv.keydown_handler = (ev) => {
|
|
1405
1423
|
if (ev.key !== "Escape" && ev.keyCode !== 27) return;
|
|
@@ -1421,6 +1439,7 @@ function mt_start$21(gobj) {
|
|
|
1421
1439
|
show_stage_placeholder(gobj, "main", "C_YUI_SHELL: no route to display (empty hash, no default_route, no stages.main.default_route)");
|
|
1422
1440
|
log_error("C_YUI_SHELL: no initial route — set default_route, shell.stages.<name>.default_route, or navigate via hash");
|
|
1423
1441
|
}
|
|
1442
|
+
if (priv.popstate_handler) retire_dead_entries(gobj);
|
|
1424
1443
|
}
|
|
1425
1444
|
/***************************************************************
|
|
1426
1445
|
* Framework Method: Stop
|
|
@@ -1430,6 +1449,7 @@ function mt_stop$20(gobj) {
|
|
|
1430
1449
|
if (!priv) return 0;
|
|
1431
1450
|
retire_overlays(gobj);
|
|
1432
1451
|
close_toolbar_dropdown(gobj);
|
|
1452
|
+
if (priv.popstate_handler) hand_over_history(gobj);
|
|
1433
1453
|
if (priv.hash_handler) {
|
|
1434
1454
|
window.removeEventListener("hashchange", priv.hash_handler);
|
|
1435
1455
|
priv.hash_handler = null;
|
|
@@ -1990,6 +2010,8 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
1990
2010
|
if (gobj_read_attr(gobj, "use_hash")) {
|
|
1991
2011
|
if (!!!(priv.stages && priv.stages.main && priv.stages.main.active_route) && prev && prev !== route) {
|
|
1992
2012
|
navigate_to(gobj, prev, depth + 1, true);
|
|
2013
|
+
let key = current_entry_key();
|
|
2014
|
+
if (key) __dead_entries__.delete(key);
|
|
1993
2015
|
let h = route_to_hash(route);
|
|
1994
2016
|
try {
|
|
1995
2017
|
window.history.pushState(null, "", h);
|
|
@@ -1997,6 +2019,7 @@ function navigate_to(gobj, route, depth, no_drain) {
|
|
|
1997
2019
|
window.location.hash = h;
|
|
1998
2020
|
}
|
|
1999
2021
|
}
|
|
2022
|
+
if (window.location.hash === route_to_hash(route)) note_own_entry(gobj);
|
|
2000
2023
|
}
|
|
2001
2024
|
publish_action();
|
|
2002
2025
|
return;
|
|
@@ -2809,7 +2832,200 @@ function close_overlays(gobj) {
|
|
|
2809
2832
|
function retire_overlays(gobj) {
|
|
2810
2833
|
let priv = gobj.priv;
|
|
2811
2834
|
if (priv && priv.overlay_stack) priv.overlay_stack.splice(0);
|
|
2812
|
-
|
|
2835
|
+
let outer = __retiring_shell__;
|
|
2836
|
+
__retiring_shell__ = gobj;
|
|
2837
|
+
try {
|
|
2838
|
+
close_overlays(gobj);
|
|
2839
|
+
} finally {
|
|
2840
|
+
__retiring_shell__ = outer;
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
/************************************************************
|
|
2844
|
+
* The history a shell that stops leaves to the next one.
|
|
2845
|
+
*
|
|
2846
|
+
* Its markers and the action entries of its `stay` routes
|
|
2847
|
+
* are dead now: a Back onto one closes nothing (up to gobj-ui
|
|
2848
|
+
* 7.26.48 they stayed, one more dead Back per overlay and per
|
|
2849
|
+
* logout, accumulating). It cannot take them off itself: a
|
|
2850
|
+
* back() is asynchronous and it no longer hears where it
|
|
2851
|
+
* lands. They go to __dead_entries__, and the next shell takes
|
|
2852
|
+
* them off at its start (retire_dead_entries()). A back() of
|
|
2853
|
+
* its own still in flight goes to __orphan_back__, which a
|
|
2854
|
+
* shell started before it lands adopts.
|
|
2855
|
+
*
|
|
2856
|
+
* A page with no next shell keeps them: with no router on the
|
|
2857
|
+
* page, a Back over the app's own entries changes nothing on
|
|
2858
|
+
* screen anyway, and the next shell retires them all the same.
|
|
2859
|
+
************************************************************/
|
|
2860
|
+
function hand_over_history(gobj) {
|
|
2861
|
+
let priv = gobj.priv;
|
|
2862
|
+
for (let key of priv.own_entries) __dead_entries__.add(key);
|
|
2863
|
+
priv.own_entries = [];
|
|
2864
|
+
if (priv.expected_pops > 0) {
|
|
2865
|
+
if (__orphan_back__) drop_orphan_back("another shell stopped with a back() in flight");
|
|
2866
|
+
let orphan = {
|
|
2867
|
+
pops: priv.expected_pops,
|
|
2868
|
+
hash: priv.expected_pop_hash,
|
|
2869
|
+
restore_hash: priv.restore_hash,
|
|
2870
|
+
ids: priv.expected_pop_ids.slice(),
|
|
2871
|
+
since: performance.now(),
|
|
2872
|
+
listener: null
|
|
2873
|
+
};
|
|
2874
|
+
orphan.listener = () => {
|
|
2875
|
+
orphan.pops--;
|
|
2876
|
+
if (orphan.pops > 0) return;
|
|
2877
|
+
if (orphan.restore_hash && window.location.hash !== orphan.restore_hash) try {
|
|
2878
|
+
window.history.replaceState(window.history.state, "", orphan.restore_hash);
|
|
2879
|
+
} catch (e) {
|
|
2880
|
+
log_warning(`C_YUI_SHELL: restoring '${orphan.restore_hash}' failed: ${e}`);
|
|
2881
|
+
}
|
|
2882
|
+
drop_orphan_back(null);
|
|
2883
|
+
};
|
|
2884
|
+
window.addEventListener("popstate", orphan.listener);
|
|
2885
|
+
__orphan_back__ = orphan;
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
function drop_orphan_back(reason) {
|
|
2889
|
+
let orphan = __orphan_back__;
|
|
2890
|
+
if (!orphan) return;
|
|
2891
|
+
__orphan_back__ = null;
|
|
2892
|
+
window.removeEventListener("popstate", orphan.listener);
|
|
2893
|
+
if (reason) log_warning(`C_YUI_SHELL: a back() of a stopped shell is no longer waited for: ${reason}`);
|
|
2894
|
+
}
|
|
2895
|
+
/************************************************************
|
|
2896
|
+
* A shell that starts while a back() of a stopped one is in
|
|
2897
|
+
* flight waits for it as for one of its own: an overlay it
|
|
2898
|
+
* opens meanwhile gets its marker after the landing, and a
|
|
2899
|
+
* route it pushes runs after it. Pushed before, Chromium runs
|
|
2900
|
+
* the traversal from the new entry and Firefox drops it.
|
|
2901
|
+
************************************************************/
|
|
2902
|
+
function adopt_orphan_back(gobj) {
|
|
2903
|
+
let orphan = __orphan_back__;
|
|
2904
|
+
if (!orphan) return;
|
|
2905
|
+
if (performance.now() - orphan.since > DEFERRED_ROUTE_WAIT_MS) {
|
|
2906
|
+
drop_orphan_back(`it did not land in ${DEFERRED_ROUTE_WAIT_MS} ms`);
|
|
2907
|
+
return;
|
|
2908
|
+
}
|
|
2909
|
+
__orphan_back__ = null;
|
|
2910
|
+
window.removeEventListener("popstate", orphan.listener);
|
|
2911
|
+
let priv = gobj.priv;
|
|
2912
|
+
priv.expected_pops = orphan.pops;
|
|
2913
|
+
priv.expected_pop_hash = orphan.hash;
|
|
2914
|
+
priv.restore_hash = orphan.restore_hash;
|
|
2915
|
+
priv.expected_pop_ids = orphan.ids;
|
|
2916
|
+
arm_back_wait(gobj);
|
|
2917
|
+
}
|
|
2918
|
+
/************************************************************
|
|
2919
|
+
* A reload is a shell going away with its overlays up, and
|
|
2920
|
+
* no stop: the entries it made stay in the session history,
|
|
2921
|
+
* and they are entries of the new document too (a Back onto
|
|
2922
|
+
* one is a popstate, not a load). Their keys are kept in the
|
|
2923
|
+
* tab's sessionStorage when the page goes, and the first
|
|
2924
|
+
* shell of the new document takes them off as a stop's.
|
|
2925
|
+
************************************************************/
|
|
2926
|
+
var DEAD_ENTRIES_STORAGE_KEY = "yui_shell_dead_entries";
|
|
2927
|
+
var __dead_entries_kept__ = false;
|
|
2928
|
+
function keep_dead_entries_across_reload() {
|
|
2929
|
+
if (__dead_entries_kept__) return;
|
|
2930
|
+
__dead_entries_kept__ = true;
|
|
2931
|
+
let storage = null;
|
|
2932
|
+
try {
|
|
2933
|
+
storage = window.sessionStorage;
|
|
2934
|
+
} catch (e) {
|
|
2935
|
+
log_warning(`C_YUI_SHELL: no sessionStorage, a reload keeps its dead history entries: ${e}`);
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
if (!storage) return;
|
|
2939
|
+
let raw = null;
|
|
2940
|
+
try {
|
|
2941
|
+
raw = storage.getItem(DEAD_ENTRIES_STORAGE_KEY);
|
|
2942
|
+
storage.removeItem(DEAD_ENTRIES_STORAGE_KEY);
|
|
2943
|
+
} catch (e) {
|
|
2944
|
+
log_warning(`C_YUI_SHELL: reading the dead history entries of the last load failed: ${e}`);
|
|
2945
|
+
}
|
|
2946
|
+
if (raw) {
|
|
2947
|
+
let keys = null;
|
|
2948
|
+
try {
|
|
2949
|
+
keys = JSON.parse(raw);
|
|
2950
|
+
} catch (e) {
|
|
2951
|
+
log_warning(`C_YUI_SHELL: the dead history entries of the last load are not json: ${e}`);
|
|
2952
|
+
}
|
|
2953
|
+
if (Array.isArray(keys)) {
|
|
2954
|
+
for (let key of keys) if (typeof key === "string") __dead_entries__.add(key);
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
window.addEventListener("pagehide", () => {
|
|
2958
|
+
let keys = new Set(__dead_entries__);
|
|
2959
|
+
for (let shell of __live_shells__) for (let key of shell.priv && shell.priv.own_entries || []) keys.add(key);
|
|
2960
|
+
try {
|
|
2961
|
+
if (keys.size > 0) storage.setItem(DEAD_ENTRIES_STORAGE_KEY, JSON.stringify([...keys]));
|
|
2962
|
+
else storage.removeItem(DEAD_ENTRIES_STORAGE_KEY);
|
|
2963
|
+
} catch (e) {
|
|
2964
|
+
log_warning(`C_YUI_SHELL: keeping the dead history entries for the next load failed: ${e}`);
|
|
2965
|
+
}
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
function current_entry_key() {
|
|
2969
|
+
let nav = window.navigation;
|
|
2970
|
+
if (!nav || !nav.currentEntry || typeof nav.entries !== "function") return null;
|
|
2971
|
+
return nav.currentEntry.key || null;
|
|
2972
|
+
}
|
|
2973
|
+
var OWN_ENTRIES_PRUNE_AT = 64;
|
|
2974
|
+
function note_own_entry(gobj) {
|
|
2975
|
+
let priv = gobj.priv;
|
|
2976
|
+
let key = current_entry_key();
|
|
2977
|
+
if (!key || priv.own_entries.includes(key)) return;
|
|
2978
|
+
priv.own_entries.push(key);
|
|
2979
|
+
if (priv.own_entries.length > OWN_ENTRIES_PRUNE_AT) {
|
|
2980
|
+
let alive = new Set(window.navigation.entries().map((e) => e.key));
|
|
2981
|
+
priv.own_entries = priv.own_entries.filter((k) => alive.has(k));
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
/************************************************************
|
|
2985
|
+
* Take off, with ONE history.go(-n), the dead entries a
|
|
2986
|
+
* stopped shell left under the current one (hand_over_history).
|
|
2987
|
+
* The walk stops at the first entry that is not dead, so it
|
|
2988
|
+
* never goes past an entry of the reader's. The traversal is
|
|
2989
|
+
* this shell's own (expected_pops): its overlays' markers and
|
|
2990
|
+
* the routes it pushes wait for the landing, and a position
|
|
2991
|
+
* the URL holds is put back on the entry it lands on, as for
|
|
2992
|
+
* any back() of ours (restore_hash). Returns true when it
|
|
2993
|
+
* went.
|
|
2994
|
+
************************************************************/
|
|
2995
|
+
function retire_dead_entries(gobj) {
|
|
2996
|
+
let priv = gobj.priv;
|
|
2997
|
+
if (__dead_entries__.size === 0 || priv.expected_pops > 0 || !priv.popstate_handler || !current_entry_key()) return false;
|
|
2998
|
+
let nav = window.navigation;
|
|
2999
|
+
let entries = nav.entries();
|
|
3000
|
+
let index = nav.currentEntry.index;
|
|
3001
|
+
let alive = new Set(entries.map((e) => e.key));
|
|
3002
|
+
for (let key of __dead_entries__) if (!alive.has(key)) __dead_entries__.delete(key);
|
|
3003
|
+
let landing = index;
|
|
3004
|
+
while (landing > 0 && __dead_entries__.has(entries[landing].key)) landing--;
|
|
3005
|
+
let steps = index - landing;
|
|
3006
|
+
if (steps === 0) return false;
|
|
3007
|
+
let landing_hash = "";
|
|
3008
|
+
try {
|
|
3009
|
+
landing_hash = new URL(entries[landing].url).hash;
|
|
3010
|
+
} catch (e) {
|
|
3011
|
+
log_warning(`C_YUI_SHELL: the entry under the dead ones has no url: ${e}`);
|
|
3012
|
+
return false;
|
|
3013
|
+
}
|
|
3014
|
+
for (let i = landing + 1; i <= index; i++) __dead_entries__.delete(entries[i].key);
|
|
3015
|
+
priv.expected_pops++;
|
|
3016
|
+
priv.expected_pop_hash = landing_hash;
|
|
3017
|
+
priv.restore_hash = window.location.hash !== landing_hash ? window.location.hash : "";
|
|
3018
|
+
try {
|
|
3019
|
+
window.history.go(-steps);
|
|
3020
|
+
} catch (e) {
|
|
3021
|
+
priv.expected_pops--;
|
|
3022
|
+
priv.restore_hash = "";
|
|
3023
|
+
log_warning(`C_YUI_SHELL: retiring ${steps} dead history entries failed: ${e}`);
|
|
3024
|
+
return false;
|
|
3025
|
+
}
|
|
3026
|
+
clear_deferred_timer(gobj);
|
|
3027
|
+
arm_back_wait(gobj);
|
|
3028
|
+
return true;
|
|
2813
3029
|
}
|
|
2814
3030
|
function pop_escape(gobj, handler) {
|
|
2815
3031
|
let priv = gobj.priv;
|
|
@@ -2922,6 +3138,7 @@ function push_overlay_marker(gobj, entry) {
|
|
|
2922
3138
|
}
|
|
2923
3139
|
try {
|
|
2924
3140
|
window.history.pushState({ __yui_overlay__: entry.id }, "");
|
|
3141
|
+
note_own_entry(gobj);
|
|
2925
3142
|
} catch (e) {
|
|
2926
3143
|
let idx = priv.overlay_stack.indexOf(entry);
|
|
2927
3144
|
if (idx >= 0) priv.overlay_stack.splice(idx, 1);
|
|
@@ -2949,6 +3166,10 @@ function defer_route(gobj, route) {
|
|
|
2949
3166
|
let priv = gobj.priv;
|
|
2950
3167
|
if (priv.deferred_route && priv.deferred_route !== route) log_warning(`C_YUI_SHELL: route '${priv.deferred_route}' waiting for a back() of ours is replaced by '${route}'`);
|
|
2951
3168
|
priv.deferred_route = route;
|
|
3169
|
+
arm_back_wait(gobj);
|
|
3170
|
+
}
|
|
3171
|
+
function arm_back_wait(gobj) {
|
|
3172
|
+
let priv = gobj.priv;
|
|
2952
3173
|
if (!priv.deferred_timer) priv.deferred_timer = window.setTimeout(() => {
|
|
2953
3174
|
if (!gobj.priv) return;
|
|
2954
3175
|
gobj.priv.deferred_timer = null;
|
|
@@ -3751,9 +3972,39 @@ function yui_shell_overlay_dismissed(shell_gobj, overlay) {
|
|
|
3751
3972
|
* stranded action entries and RE-FIRES the action, reopening
|
|
3752
3973
|
* the overlay and hijacking the navigation the user asked
|
|
3753
3974
|
* for. Only back() while the URL still sits on the route.
|
|
3975
|
+
*
|
|
3976
|
+
* A close that comes from a shell that STOPS (a logout with the
|
|
3977
|
+
* overlay up) does not go back: the URL is rewritten in place,
|
|
3978
|
+
* to the resting route under the overlay. A back() is
|
|
3979
|
+
* asynchronous and the stopped shell would never hear where it
|
|
3980
|
+
* lands -- the overlay's own marker is left in place, so a
|
|
3981
|
+
* single back() landed on the action entry, the URL stayed on
|
|
3982
|
+
* the action route, and a new shell built in the same turn read
|
|
3983
|
+
* it and opened the overlay again (up to gobj-ui 7.26.47).
|
|
3754
3984
|
************************************************************/
|
|
3755
3985
|
function yui_shell_unpark_route(route) {
|
|
3756
|
-
|
|
3986
|
+
let hash = route_to_hash(normalize_route(route));
|
|
3987
|
+
if (window.location.hash !== hash) return;
|
|
3988
|
+
let shell = __retiring_shell__;
|
|
3989
|
+
if (shell) {
|
|
3990
|
+
let resting = resting_route_of(shell);
|
|
3991
|
+
try {
|
|
3992
|
+
window.history.replaceState(window.history.state, "", route_to_hash(resting));
|
|
3993
|
+
} catch (e) {
|
|
3994
|
+
log_warning(`C_YUI_SHELL: unparking '${route}' at stop failed: ${e}`);
|
|
3995
|
+
}
|
|
3996
|
+
return;
|
|
3997
|
+
}
|
|
3998
|
+
window.history.back();
|
|
3999
|
+
}
|
|
4000
|
+
/************************************************************
|
|
4001
|
+
* The resting route a shell shows under its overlays: the
|
|
4002
|
+
* current one (only ever written for a RESTING route), else
|
|
4003
|
+
* the main stage's, else the default.
|
|
4004
|
+
************************************************************/
|
|
4005
|
+
function resting_route_of(gobj) {
|
|
4006
|
+
let priv = gobj.priv || {};
|
|
4007
|
+
return gobj_read_attr(gobj, "current_route") || priv.stages && priv.stages.main && priv.stages.main.active_route || gobj_read_attr(gobj, "default_route") || "/";
|
|
3757
4008
|
}
|
|
3758
4009
|
/************************************************************
|
|
3759
4010
|
* Avatar provider — toolbar items with type:"avatar" call the
|
|
@@ -9839,8 +10090,10 @@ function time_value_to_text(value, real_type) {
|
|
|
9839
10090
|
* it had. Up to gobj-ui 7.26.46 both committed null: one
|
|
9840
10091
|
* Backspace and Enter erased the stored time. To clear a time
|
|
9841
10092
|
* on purpose, clear EVERY part of the box: an empty box
|
|
9842
|
-
* commits null.
|
|
9843
|
-
*
|
|
10093
|
+
* commits null. Inside the box the Left and Right arrows move
|
|
10094
|
+
* between its parts; Tab is the table's (Tabulator's navNext):
|
|
10095
|
+
* it leaves the cell and opens the editor of the next one, in
|
|
10096
|
+
* Chromium and Firefox alike.
|
|
9844
10097
|
*
|
|
9845
10098
|
* Copyright (c) 2026, ArtGins.
|
|
9846
10099
|
* All Rights Reserved.
|
|
@@ -9876,6 +10129,7 @@ function form_time_cell_editor(real_type) {
|
|
|
9876
10129
|
let attrs = params.elementAttributes;
|
|
9877
10130
|
if (attrs && typeof attrs === "object") for (let key of Object.keys(attrs)) input.setAttribute(key, attrs[key]);
|
|
9878
10131
|
input.value = original_text;
|
|
10132
|
+
let shown_text = input.value;
|
|
9879
10133
|
onRendered(function() {
|
|
9880
10134
|
if (cell.getType() === "cell") {
|
|
9881
10135
|
input.focus({ preventScroll: true });
|
|
@@ -9891,7 +10145,7 @@ function form_time_cell_editor(real_type) {
|
|
|
9891
10145
|
else input.setAttribute("aria-invalid", "true");
|
|
9892
10146
|
return;
|
|
9893
10147
|
}
|
|
9894
|
-
if (input.value ===
|
|
10148
|
+
if (input.value === shown_text) {
|
|
9895
10149
|
cancel();
|
|
9896
10150
|
return;
|
|
9897
10151
|
}
|
|
@@ -9905,9 +10159,11 @@ function form_time_cell_editor(real_type) {
|
|
|
9905
10159
|
input.addEventListener("blur", function(e) {
|
|
9906
10160
|
if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit(true);
|
|
9907
10161
|
});
|
|
9908
|
-
|
|
10162
|
+
let recheck = function() {
|
|
9909
10163
|
if (!incomplete()) input.removeAttribute("aria-invalid");
|
|
9910
|
-
}
|
|
10164
|
+
};
|
|
10165
|
+
input.addEventListener("input", recheck);
|
|
10166
|
+
input.addEventListener("keyup", recheck);
|
|
9911
10167
|
input.addEventListener("keydown", function(e) {
|
|
9912
10168
|
switch (e.key) {
|
|
9913
10169
|
case "Enter":
|
|
@@ -10405,7 +10661,11 @@ function mt_writing$2(gobj, path) {
|
|
|
10405
10661
|
if (path === "selectable") {
|
|
10406
10662
|
let $container = gobj_read_attr(gobj, "$container");
|
|
10407
10663
|
if (!$container) return;
|
|
10408
|
-
|
|
10664
|
+
let selectable = gobj_read_bool_attr(gobj, "selectable");
|
|
10665
|
+
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) if ($table.tabulator) {
|
|
10666
|
+
show_row_selection(gobj, $table.tabulator);
|
|
10667
|
+
if (!selectable && $table.tabulator.initialized) $table.tabulator.deselectRow();
|
|
10668
|
+
}
|
|
10409
10669
|
}
|
|
10410
10670
|
}
|
|
10411
10671
|
/************************************************************
|
|
@@ -11031,7 +11291,7 @@ function build_form(gobj) {
|
|
|
11031
11291
|
******************************************************************/
|
|
11032
11292
|
function build_html_form(gobj, $form, prefix, template) {
|
|
11033
11293
|
Object.entries(template).forEach(([key, value]) => {
|
|
11034
|
-
const field_desc =
|
|
11294
|
+
const field_desc = form_template_field_desc(key, value);
|
|
11035
11295
|
if (!prefix && yui_icons_is_svg_field(gobj_read_str_attr(gobj, "topic_name"), field_desc.name)) field_desc.type = "svg";
|
|
11036
11296
|
let html_field_conf = build_form_field_conf(gobj, field_desc);
|
|
11037
11297
|
html_field_conf.name = field_desc.name;
|
|
@@ -12034,6 +12294,7 @@ function create_coordinates(gobj, attrs) {
|
|
|
12034
12294
|
const latitude = position.coords.latitude;
|
|
12035
12295
|
$input.value = `${position.coords.longitude}, ${latitude}`;
|
|
12036
12296
|
$input.classList.remove("is-danger");
|
|
12297
|
+
$input.removeAttribute("aria-invalid");
|
|
12037
12298
|
let $h = $input.closest(".xcontrol").parentNode.querySelector(".help");
|
|
12038
12299
|
$h.textContent = "";
|
|
12039
12300
|
$h.style.display = "none";
|
|
@@ -12054,7 +12315,9 @@ function create_coordinates(gobj, attrs) {
|
|
|
12054
12315
|
default: errorMsg = t("unknown error");
|
|
12055
12316
|
}
|
|
12056
12317
|
$input.classList.add("is-danger");
|
|
12318
|
+
$input.setAttribute("aria-invalid", "true");
|
|
12057
12319
|
let $h = $input.closest(".xcontrol").parentNode.querySelector(".help");
|
|
12320
|
+
describe_by_help($input, $h);
|
|
12058
12321
|
$h.textContent = errorMsg;
|
|
12059
12322
|
$h.style.display = "block";
|
|
12060
12323
|
}
|
|
@@ -12290,7 +12553,7 @@ function column_title(field_desc) {
|
|
|
12290
12553
|
function table_column_titles(template) {
|
|
12291
12554
|
let titles = {};
|
|
12292
12555
|
Object.entries(template || {}).forEach(([key, value]) => {
|
|
12293
|
-
const field_desc =
|
|
12556
|
+
const field_desc = form_template_field_desc(key, value);
|
|
12294
12557
|
titles[field_desc.name] = column_title(field_desc);
|
|
12295
12558
|
});
|
|
12296
12559
|
return titles;
|
|
@@ -12303,7 +12566,7 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12303
12566
|
return gobj_read_bool_attr(gobj, "editable");
|
|
12304
12567
|
}
|
|
12305
12568
|
Object.entries(template).forEach(([key, value]) => {
|
|
12306
|
-
const field_desc =
|
|
12569
|
+
const field_desc = form_template_field_desc(key, value);
|
|
12307
12570
|
let readonly = !field_desc.is_writable;
|
|
12308
12571
|
let validator = [];
|
|
12309
12572
|
let column = {
|
|
@@ -12473,6 +12736,21 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12473
12736
|
return columns;
|
|
12474
12737
|
}
|
|
12475
12738
|
/************************************************************
|
|
12739
|
+
* A field of the template. A dot-token spec that names a
|
|
12740
|
+
* `time` / `now` type and no real type ("time.writable") is
|
|
12741
|
+
* an epoch, as the real type of a treedb time column is
|
|
12742
|
+
* integer: template_get_field_desc() (gobj-js) gives every
|
|
12743
|
+
* spec without one `string`, and a `string` time column is
|
|
12744
|
+
* an ISO text (form_time_value.js). Since gobj-ui 7.26.47
|
|
12745
|
+
* such a field showed its epoch as no time, and a save of
|
|
12746
|
+
* any field wrote null over it.
|
|
12747
|
+
************************************************************/
|
|
12748
|
+
function form_template_field_desc(key, value) {
|
|
12749
|
+
let field_desc = template_get_field_desc(key, value);
|
|
12750
|
+
if (is_string(value) && (field_desc.type === "time" || field_desc.type === "now") && !value.split(".").includes(field_desc.real_type)) field_desc.real_type = "integer";
|
|
12751
|
+
return field_desc;
|
|
12752
|
+
}
|
|
12753
|
+
/************************************************************
|
|
12476
12754
|
* What is wrong with a field, in the APP's language.
|
|
12477
12755
|
*
|
|
12478
12756
|
* `input.validationMessage` is the BROWSER's sentence in the BROWSER's
|
|
@@ -12508,6 +12786,7 @@ function mark_field_validity($input) {
|
|
|
12508
12786
|
let v = $input.validity;
|
|
12509
12787
|
if ((!v || v.valid) && !$input.yui_json_error) {
|
|
12510
12788
|
$input.classList.remove("is-danger");
|
|
12789
|
+
$input.removeAttribute("aria-invalid");
|
|
12511
12790
|
if ($h) {
|
|
12512
12791
|
$h.textContent = "";
|
|
12513
12792
|
$h.removeAttribute("data-i18n");
|
|
@@ -12516,7 +12795,9 @@ function mark_field_validity($input) {
|
|
|
12516
12795
|
return true;
|
|
12517
12796
|
}
|
|
12518
12797
|
$input.classList.add("is-danger");
|
|
12798
|
+
$input.setAttribute("aria-invalid", "true");
|
|
12519
12799
|
if ($h) {
|
|
12800
|
+
describe_by_help($input, $h);
|
|
12520
12801
|
let key = field_validation_key($input);
|
|
12521
12802
|
if (key) $h.setAttribute("data-i18n", key);
|
|
12522
12803
|
else $h.removeAttribute("data-i18n");
|
|
@@ -12525,6 +12806,15 @@ function mark_field_validity($input) {
|
|
|
12525
12806
|
}
|
|
12526
12807
|
return false;
|
|
12527
12808
|
}
|
|
12809
|
+
var __help_seq__ = 0;
|
|
12810
|
+
function describe_by_help($input, $h) {
|
|
12811
|
+
if (!$h.id) $h.id = `yui-form-help-${++__help_seq__}`;
|
|
12812
|
+
let ids = ($input.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean);
|
|
12813
|
+
if (!ids.includes($h.id)) {
|
|
12814
|
+
ids.push($h.id);
|
|
12815
|
+
$input.setAttribute("aria-describedby", ids.join(" "));
|
|
12816
|
+
}
|
|
12817
|
+
}
|
|
12528
12818
|
/************************************************************
|
|
12529
12819
|
*
|
|
12530
12820
|
************************************************************/
|
|
@@ -12710,11 +13000,13 @@ function clear_data(gobj, $form) {
|
|
|
12710
13000
|
*
|
|
12711
13001
|
************************************************************/
|
|
12712
13002
|
function clear_validation(gobj, $form) {
|
|
12713
|
-
$form.querySelectorAll("input").forEach(($input) => {
|
|
13003
|
+
$form.querySelectorAll("input, .yui-form-data-input").forEach(($input) => {
|
|
12714
13004
|
$input.classList.remove("is-danger");
|
|
13005
|
+
$input.removeAttribute("aria-invalid");
|
|
12715
13006
|
});
|
|
12716
13007
|
$form.querySelectorAll(".help").forEach(($input) => {
|
|
12717
13008
|
$input.textContent = "";
|
|
13009
|
+
$input.removeAttribute("data-i18n");
|
|
12718
13010
|
$input.style.display = "none";
|
|
12719
13011
|
});
|
|
12720
13012
|
$form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
|
|
@@ -23411,12 +23703,12 @@ function restore_view_state(gobj) {
|
|
|
23411
23703
|
let done = false;
|
|
23412
23704
|
priv.restoring = true;
|
|
23413
23705
|
try {
|
|
23414
|
-
if (
|
|
23706
|
+
if (Number.isFinite(state.zoom) && state.zoom > 0) {
|
|
23415
23707
|
graph.zoomTo(state.zoom);
|
|
23416
23708
|
priv.last_zoom = state.zoom;
|
|
23417
23709
|
done = true;
|
|
23418
23710
|
}
|
|
23419
|
-
if (Array.isArray(state.position) && state.position.length >= 2) {
|
|
23711
|
+
if (Array.isArray(state.position) && state.position.length >= 2 && Number.isFinite(state.position[0]) && Number.isFinite(state.position[1])) {
|
|
23420
23712
|
graph.translateTo([state.position[0], state.position[1]]);
|
|
23421
23713
|
done = true;
|
|
23422
23714
|
}
|
|
@@ -23444,12 +23736,31 @@ function save_view_state(gobj) {
|
|
|
23444
23736
|
collapsed: priv.collapse_state || {},
|
|
23445
23737
|
anchor: priv.anchor_state === "on" ? priv.anchor_name : ""
|
|
23446
23738
|
};
|
|
23739
|
+
let camera = null;
|
|
23447
23740
|
try {
|
|
23448
|
-
|
|
23449
|
-
state.position = graph.getPosition();
|
|
23741
|
+
camera = camera_of(graph.getZoom(), graph.getPosition());
|
|
23450
23742
|
} catch (e) {}
|
|
23743
|
+
if (!camera) {
|
|
23744
|
+
let old = load_view_state(gobj);
|
|
23745
|
+
camera = old ? camera_of(old.zoom, old.position) : null;
|
|
23746
|
+
}
|
|
23747
|
+
if (camera) {
|
|
23748
|
+
state.zoom = camera.zoom;
|
|
23749
|
+
state.position = camera.position;
|
|
23750
|
+
}
|
|
23451
23751
|
kw_set_local_storage_value(view_store_key(gobj), state);
|
|
23452
23752
|
}
|
|
23753
|
+
function camera_of(zoom, position) {
|
|
23754
|
+
if (!(Number.isFinite(zoom) && zoom > 0)) return null;
|
|
23755
|
+
if (!position || typeof position.length !== "number" || position.length < 2) return null;
|
|
23756
|
+
let x = position[0];
|
|
23757
|
+
let y = position[1];
|
|
23758
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return null;
|
|
23759
|
+
return {
|
|
23760
|
+
zoom,
|
|
23761
|
+
position: [x, y]
|
|
23762
|
+
};
|
|
23763
|
+
}
|
|
23453
23764
|
function load_view_state(gobj) {
|
|
23454
23765
|
let state = kw_get_local_storage_value(view_store_key(gobj), null, false);
|
|
23455
23766
|
return state && typeof state === "object" ? state : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@rollup/plugin-terser": "^1.0.0",
|
|
41
41
|
"@vitest/coverage-v8": "^4.1.10",
|
|
42
|
-
"@yuneta/gobj-js": "^7.26.
|
|
42
|
+
"@yuneta/gobj-js": "^7.26.27",
|
|
43
43
|
"vite": "^8.3.3",
|
|
44
44
|
"vitest": "^4.1.10"
|
|
45
45
|
},
|