@yuneta/gobj-ui 7.26.44 → 7.26.46
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 +160 -20
- package/dist/gobj-ui.cjs.js +326 -37
- package/dist/gobj-ui.es.js +327 -39
- package/index.js +1 -0
- package/package.json +1 -1
- package/scripts/check-markup-strings.mjs +4 -1
- package/scripts/validate-locales.mjs +709 -178
- package/src/c_yui_form.js +116 -50
- package/src/c_yui_node.js +3 -1
- package/src/c_yui_schema_editor.js +3 -0
- package/src/c_yui_shell.js +113 -12
- package/src/c_yui_window.js +44 -5
- package/src/form_table_edits_ask.wiring.test.js +11 -2
- package/src/form_table_rows.wiring.test.js +284 -9
- package/src/form_time_cell_editor.js +143 -0
- package/src/form_time_cell_editor.test.js +116 -0
- package/src/i18n_key_functions.js +2 -2
- package/src/i18n_key_functions.test.js +45 -7
- package/src/node_nav_events.wiring.test.js +6 -0
- package/src/schema_editor_diagram_click.wiring.test.js +28 -0
- package/src/shell_escape_taken.wiring.test.js +34 -0
- package/src/shell_focus_trap.js +47 -1
- package/src/shell_focus_trap.test.js +95 -0
- package/src/shell_modals.js +2 -2
- package/src/shell_stop_overlays.wiring.test.js +143 -0
- package/src/tabulator_edit_internals.test.js +50 -0
- package/src/window_dialog.wiring.test.js +80 -1
- package/src/window_rect_rounding.wiring.test.js +45 -0
package/src/c_yui_form.js
CHANGED
|
@@ -96,6 +96,7 @@ import "tabulator-tables/dist/css/tabulator_bulma.css";
|
|
|
96
96
|
import "./tabulator.css";
|
|
97
97
|
import {is_time_field} from "./json_view_helpers.js";
|
|
98
98
|
import {date_to_datetime_local, datetime_local_to_epoch} from "./form_time_value.js";
|
|
99
|
+
import {form_time_cell_editor} from "./form_time_cell_editor.js";
|
|
99
100
|
import {parse_json_field, json_editor_value} from "./form_json_field.js";
|
|
100
101
|
import {
|
|
101
102
|
json_editor_menu_items,
|
|
@@ -132,8 +133,8 @@ SDATA(data_type_t.DTP_STRING, "pkey", 0, "id", "Primary key fie
|
|
|
132
133
|
SDATA(data_type_t.DTP_STRING, "topic_name", 0, "", "Treedb topic name: labels use the i18n cascade '<topic>.<col>' -> '<col>' -> header (like table headers)"),
|
|
133
134
|
SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
|
|
134
135
|
SDATA(data_type_t.DTP_BOOLEAN, "readonly", 0, false, "Show EVERY field read-only, whatever its schema says: a record being LOOKED at, not edited. Independent of `editable`, which drives the TABLE rendering; this one drives the FORM"),
|
|
135
|
-
SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "
|
|
136
|
-
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
|
|
136
|
+
SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
|
|
137
|
+
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows (not drawn when the form is not `selectable`)"),
|
|
137
138
|
SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
|
|
138
139
|
SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
|
|
139
140
|
/*
|
|
@@ -613,6 +614,47 @@ function destroy_widget(gobj, what, widget)
|
|
|
613
614
|
}
|
|
614
615
|
}
|
|
615
616
|
|
|
617
|
+
/************************************************************
|
|
618
|
+
* Close the cell editor a table has open, dropping what is
|
|
619
|
+
* typed in it, before its rows are wiped. Tabulator 6.6.0
|
|
620
|
+
* closes it while it wipes them, and the redraw that follows
|
|
621
|
+
* walks the rows already wiped: a reload, a Clear or a destroy
|
|
622
|
+
* with an editor open in any row but the first threw, and left
|
|
623
|
+
* the table half wiped.
|
|
624
|
+
*
|
|
625
|
+
* Tabulator has no public way to ask which cell is edited: this
|
|
626
|
+
* reads its edit module (`modules.edit`, `currentCell`,
|
|
627
|
+
* `cancelEdit()`), names pinned against the installed Tabulator
|
|
628
|
+
* by tabulator_edit_internals.test.js. A Tabulator without them
|
|
629
|
+
* is said: the guard would do nothing, and the crash come back.
|
|
630
|
+
************************************************************/
|
|
631
|
+
function close_table_editor(gobj, tabulator)
|
|
632
|
+
{
|
|
633
|
+
let edit = tabulator.modules? tabulator.modules.edit : null;
|
|
634
|
+
if(!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
|
|
635
|
+
log_warning(`${gobj_short_name(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): ` +
|
|
636
|
+
`an open cell editor is not closed before its table is wiped`);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if(edit.currentCell) {
|
|
640
|
+
edit.cancelEdit();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
/************************************************************
|
|
645
|
+
* The element of the table (`.tabulator` kept on it) that holds
|
|
646
|
+
* $el, the innermost one.
|
|
647
|
+
************************************************************/
|
|
648
|
+
function table_element_of($el)
|
|
649
|
+
{
|
|
650
|
+
for(let $n = $el; $n; $n = $n.parentNode) {
|
|
651
|
+
if($n.tabulator) {
|
|
652
|
+
return $n;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
|
|
616
658
|
/************************************************************
|
|
617
659
|
* A table element that is gone: its identity is no table now,
|
|
618
660
|
* and what was waiting to be loaded in it never will be.
|
|
@@ -639,6 +681,7 @@ function destroy_row_tables(gobj, $row)
|
|
|
639
681
|
$row.yui_nested = null;
|
|
640
682
|
for(let $nested of nested) {
|
|
641
683
|
if($nested.tabulator) {
|
|
684
|
+
close_table_editor(gobj, $nested.tabulator);
|
|
642
685
|
destroy_rows_tables(gobj, $nested.tabulator);
|
|
643
686
|
destroy_widget(gobj, "nested table", $nested.tabulator);
|
|
644
687
|
$nested.tabulator = null;
|
|
@@ -677,6 +720,7 @@ function destroy_widgets(gobj, $container)
|
|
|
677
720
|
$el.jsoneditor = null;
|
|
678
721
|
}
|
|
679
722
|
if($el.tabulator) {
|
|
723
|
+
close_table_editor(gobj, $el.tabulator);
|
|
680
724
|
destroy_rows_tables(gobj, $el.tabulator);
|
|
681
725
|
destroy_widget(gobj, "table", $el.tabulator);
|
|
682
726
|
$el.tabulator = null;
|
|
@@ -2222,7 +2266,8 @@ function create_coordinates(gobj, attrs)
|
|
|
2222
2266
|
* Create tabulator
|
|
2223
2267
|
*
|
|
2224
2268
|
* A row builds its nested tables the first time it is drawn, each
|
|
2225
|
-
*
|
|
2269
|
+
* BUILT with the rows of the row's own data (`rows`, a copy: the
|
|
2270
|
+
* table keeps what it is given), and keeps them on its element
|
|
2226
2271
|
* (`yui_nested`) until the row goes (destroy_row_tables). A row
|
|
2227
2272
|
* drawn AGAIN -- a forced redraw, a column rebuilt -- has its
|
|
2228
2273
|
* children taken off by Tabulator before its formatter runs: they
|
|
@@ -2233,31 +2278,47 @@ function create_coordinates(gobj, attrs)
|
|
|
2233
2278
|
* `tableBuilt`, ONE per table (`yui_pending_rows`): a later load
|
|
2234
2279
|
* replaces it, a clear drops it. Each load used to hang a listener
|
|
2235
2280
|
* of its own, so two loads before the build drew the rows twice.
|
|
2281
|
+
*
|
|
2282
|
+
* A nested table is not loaded after it is built, as the form's
|
|
2283
|
+
* own tables are (EV_LOAD_TABLE_ROWS): each such load laid it out
|
|
2284
|
+
* twice and redrew it once more, and with a nested table per row
|
|
2285
|
+
* that was most of the time of a load.
|
|
2286
|
+
*
|
|
2287
|
+
* A table selects rows only when a host sets `selectableRows` (true
|
|
2288
|
+
* or a number) in `tabulator_settings`. Tabulator's SelectRow then
|
|
2289
|
+
* toggles a row on its own click, asking `selectableRowsCheck` --
|
|
2290
|
+
* the form's `selectable` -- first. Up to 7.26.44 the form toggled
|
|
2291
|
+
* the row again in `rowClick`, which undid every click. The default
|
|
2292
|
+
* `"highlight"` is left as it is, hover and all.
|
|
2293
|
+
*
|
|
2294
|
+
* The checkbox column (`with_checkbox`) asks `selectable` too, and is
|
|
2295
|
+
* not drawn when the form is not selectable: Tabulator's row box ticks
|
|
2296
|
+
* before its toggle is refused (a ticked box over a row not selected),
|
|
2297
|
+
* and its header box selects every row asking nothing. Up to 7.26.45
|
|
2298
|
+
* the boxes were drawn and lied; with the default `selectableRows`
|
|
2299
|
+
* they selected whatever `selectable` said.
|
|
2300
|
+
*
|
|
2301
|
+
* A click in a nested table stays there: it bubbled to the row that
|
|
2302
|
+
* holds the table, whose own click listener (SelectRow's) toggled
|
|
2303
|
+
* that row too.
|
|
2236
2304
|
******************************************************************/
|
|
2237
|
-
function create_tabulator(gobj, $extend, name, template)
|
|
2305
|
+
function create_tabulator(gobj, $extend, name, template, rows)
|
|
2238
2306
|
{
|
|
2239
|
-
/* A click selects a row only when the form is `selectable` AND its
|
|
2240
|
-
* table selects rows (`selectableRows`, off unless a host sets it in
|
|
2241
|
-
* `tabulator_settings`): toggleSelect() on a table that does not
|
|
2242
|
-
* select throws. */
|
|
2243
|
-
function get_selectable_state(row) {
|
|
2244
|
-
let selectable_rows = tabulator.options.selectableRows;
|
|
2245
|
-
return gobj_read_bool_attr(gobj, "selectable") &&
|
|
2246
|
-
(selectable_rows === true || typeof selectable_rows === "number");
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
2307
|
$extend.template = template;
|
|
2250
2308
|
|
|
2251
2309
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
|
2310
|
+
if(is_array(rows) && rows.length > 0) {
|
|
2311
|
+
tabulator_settings.data = json_deep_copy(rows);
|
|
2312
|
+
}
|
|
2252
2313
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
}
|
|
2314
|
+
/* Tabulator toggles the row on its own click: `selectable` only vetoes */
|
|
2315
|
+
let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
|
|
2316
|
+
let selectable_rows = tabulator_settings.selectableRows;
|
|
2317
|
+
if(selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) {
|
|
2318
|
+
tabulator_settings.selectableRowsCheck = function() {
|
|
2319
|
+
return gobj_read_bool_attr(gobj, "selectable");
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2261
2322
|
|
|
2262
2323
|
let columns = [];
|
|
2263
2324
|
if(gobj_read_bool_attr(gobj, "with_rownum")) {
|
|
@@ -2294,13 +2355,21 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2294
2355
|
}
|
|
2295
2356
|
];
|
|
2296
2357
|
let $extend = createElement2(extend);
|
|
2358
|
+
/* Widget plumbing, not an action: the event is the nested table's */
|
|
2359
|
+
$extend.addEventListener("click", function(ev) {
|
|
2360
|
+
ev.stopPropagation();
|
|
2361
|
+
});
|
|
2362
|
+
$extend.addEventListener("mousedown", function(ev) {
|
|
2363
|
+
if(ev.shiftKey) {
|
|
2364
|
+
ev.stopPropagation();
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
let rows = data[sub_element.name];
|
|
2297
2368
|
$extend.tabulator = create_tabulator(
|
|
2298
|
-
gobj, $extend, sub_element.name, sub_element.template
|
|
2369
|
+
gobj, $extend, sub_element.name, sub_element.template, rows
|
|
2299
2370
|
);
|
|
2300
2371
|
$row.appendChild($extend);
|
|
2301
2372
|
$row.yui_nested.push($extend);
|
|
2302
|
-
let rows = data[sub_element.name];
|
|
2303
|
-
load_tabulator_data(gobj, $extend, is_array(rows)? rows : []);
|
|
2304
2373
|
}
|
|
2305
2374
|
};
|
|
2306
2375
|
}
|
|
@@ -2326,7 +2395,7 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2326
2395
|
);
|
|
2327
2396
|
}
|
|
2328
2397
|
|
|
2329
|
-
if(gobj_read_bool_attr(gobj, "
|
|
2398
|
+
if(with_checkbox && gobj_read_bool_attr(gobj, "selectable")) {
|
|
2330
2399
|
tabulator_settings.rowHeader = {
|
|
2331
2400
|
formatter: "rowSelection",
|
|
2332
2401
|
titleFormatter: "rowSelection",
|
|
@@ -2358,6 +2427,22 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2358
2427
|
}
|
|
2359
2428
|
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
2360
2429
|
});
|
|
2430
|
+
/* What the reader TYPES in a cell editor is `edited` at once, as in a
|
|
2431
|
+
* field of the form (its `input`): `dataChanged` comes only when the
|
|
2432
|
+
* editor commits, and a host that reloads or closes the form by code
|
|
2433
|
+
* asks `edited` first. Up to 7.26.45 a half-typed cell was not
|
|
2434
|
+
* edited, and such a reload dropped it without a question. Only the
|
|
2435
|
+
* editor of a cell of THIS table: not a header filter, not the
|
|
2436
|
+
* selection box, not a nested table's editor (that table says it). */
|
|
2437
|
+
$extend.addEventListener("input", function(ev) {
|
|
2438
|
+
let $target = ev.target;
|
|
2439
|
+
if(!$target || typeof $target.closest !== "function" ||
|
|
2440
|
+
!$target.closest(".tabulator-cell.tabulator-editing") ||
|
|
2441
|
+
table_element_of($target) !== $extend) {
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
2445
|
+
});
|
|
2361
2446
|
$extend.yui_pending_rows = null;
|
|
2362
2447
|
tabulator.on("tableBuilt", function() {
|
|
2363
2448
|
let rows = $extend.yui_pending_rows;
|
|
@@ -2395,20 +2480,12 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2395
2480
|
//e - the click event object
|
|
2396
2481
|
//row - row component
|
|
2397
2482
|
e.preventDefault();
|
|
2398
|
-
if(get_selectable_state(row)) {
|
|
2399
|
-
row.toggleSelect();
|
|
2400
|
-
}
|
|
2401
2483
|
});
|
|
2402
2484
|
|
|
2403
2485
|
tabulator.on("cellClick", function(e, cell) {
|
|
2404
2486
|
//e - the click event object
|
|
2405
2487
|
//cell - cell component
|
|
2406
2488
|
e.preventDefault();
|
|
2407
|
-
let row = cell.getRow();
|
|
2408
|
-
// if(get_selectable_state(row)) {
|
|
2409
|
-
// // cannot set at same time with rowClick, one select and other de-select
|
|
2410
|
-
// row.toggleSelect();
|
|
2411
|
-
// }
|
|
2412
2489
|
});
|
|
2413
2490
|
|
|
2414
2491
|
return tabulator;
|
|
@@ -2630,25 +2707,13 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2630
2707
|
|
|
2631
2708
|
case "now":
|
|
2632
2709
|
case "time":
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2710
|
+
/* Tabulator's `datetime` with a `format` needs luxon: see
|
|
2711
|
+
* form_time_cell_editor.js. Named after its column
|
|
2712
|
+
* (yui_tabulator_name_editor, below). */
|
|
2713
|
+
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
2636
2714
|
column.editorParams = {
|
|
2637
|
-
format: "dd/MM/yyyy hh:mm", // the format of the date value stored in the cell
|
|
2638
2715
|
verticalNavigation: "table", //navigate cursor around table without changing the value
|
|
2639
|
-
elementAttributes: {
|
|
2640
|
-
/* Tabulator writes this attribute once, when the
|
|
2641
|
-
* editor opens, so it is translated then -- which
|
|
2642
|
-
* is also when it is read. */
|
|
2643
|
-
title: t("slide bar to choose option")
|
|
2644
|
-
}
|
|
2645
2716
|
};
|
|
2646
|
-
switch(field_desc.real_type) {
|
|
2647
|
-
case "string":
|
|
2648
|
-
break;
|
|
2649
|
-
case "integer":
|
|
2650
|
-
break;
|
|
2651
|
-
}
|
|
2652
2717
|
break;
|
|
2653
2718
|
|
|
2654
2719
|
case "color":
|
|
@@ -3142,6 +3207,7 @@ function clear_data(gobj, $form)
|
|
|
3142
3207
|
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
3143
3208
|
$table.yui_pending_rows = null;
|
|
3144
3209
|
if($table.tabulator.initialized) {
|
|
3210
|
+
close_table_editor(gobj, $table.tabulator);
|
|
3145
3211
|
destroy_rows_tables(gobj, $table.tabulator);
|
|
3146
3212
|
$table.tabulator.clearData();
|
|
3147
3213
|
}
|
package/src/c_yui_node.js
CHANGED
|
@@ -623,7 +623,8 @@ function translate_own_dom(gobj, $el)
|
|
|
623
623
|
* A render can come from a click on one of them -- the active item
|
|
624
624
|
* clicked again is a navigation to the same hash, done in the same
|
|
625
625
|
* turn -- and that nav is still inside its publication of
|
|
626
|
-
* EV_NAV_CLICKED.
|
|
626
|
+
* EV_NAV_CLICKED. They are not heard from the moment they leave:
|
|
627
|
+
* what one published in that turn was taken as the current nav's.
|
|
627
628
|
************************************************************/
|
|
628
629
|
function clear_navs(gobj)
|
|
629
630
|
{
|
|
@@ -637,6 +638,7 @@ function clear_navs(gobj)
|
|
|
637
638
|
if($nav && $nav.parentNode) {
|
|
638
639
|
$nav.parentNode.removeChild($nav);
|
|
639
640
|
}
|
|
641
|
+
gobj_unsubscribe_event(nav, null, {}, gobj);
|
|
640
642
|
priv.retired_navs.push(nav);
|
|
641
643
|
}
|
|
642
644
|
priv.navs = [];
|
|
@@ -1922,6 +1922,8 @@ function render_diagram(gobj)
|
|
|
1922
1922
|
* its own node click, which it publishes from inside G6's dispatch
|
|
1923
1923
|
* of that click: stopped there, the gobj went from under its own
|
|
1924
1924
|
* publication and the G6 graph from under its own event.
|
|
1925
|
+
* It is not heard from the moment it leaves: what it published in
|
|
1926
|
+
* that turn reached the editor as the current drawing's.
|
|
1925
1927
|
***************************************************************/
|
|
1926
1928
|
function destroy_diagram(gobj)
|
|
1927
1929
|
{
|
|
@@ -1937,6 +1939,7 @@ function destroy_diagram(gobj)
|
|
|
1937
1939
|
if($d && $d.parentNode) {
|
|
1938
1940
|
$d.parentNode.removeChild($d);
|
|
1939
1941
|
}
|
|
1942
|
+
gobj_unsubscribe_event(diagram, null, {}, gobj);
|
|
1940
1943
|
priv.retired_diagrams.push(diagram);
|
|
1941
1944
|
if(priv.retired_diagrams.length === 1) {
|
|
1942
1945
|
gobj_post_event(gobj, "EV_DESTROY_DIAGRAMS", {}, gobj);
|
package/src/c_yui_shell.js
CHANGED
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
|
|
60
60
|
import {
|
|
61
61
|
activate_focus_trap_on,
|
|
62
|
+
focus_trap_panel,
|
|
62
63
|
} from "./shell_focus_trap.js";
|
|
63
64
|
import {escape_is_taken} from "./escape_taken.js";
|
|
64
65
|
|
|
@@ -180,11 +181,15 @@ let PRIVATE_DATA = {
|
|
|
180
181
|
event_handlers: {},
|
|
181
182
|
hash_handler: null,
|
|
182
183
|
keydown_handler: null,
|
|
183
|
-
/* Escape priority chain: array of { layer, handler }. Each
|
|
184
|
+
/* Escape priority chain: array of { layer, handler, teardown }. Each
|
|
184
185
|
* interactive overlay (drawer today, modal/popup tomorrow)
|
|
185
186
|
* pushes its close handler when it opens and pops it when
|
|
186
187
|
* it closes. Escape calls the top handler only — LIFO. */
|
|
187
188
|
escape_stack: [],
|
|
189
|
+
/* The order of the last entry pushed: every entry carries its
|
|
190
|
+
* own (`seq`), so a window can tell an overlay opened after it
|
|
191
|
+
* (yui_shell_escape_order). */
|
|
192
|
+
escape_seq: 0,
|
|
188
193
|
/* Overlay history integration (Back button ↔ modals/windows).
|
|
189
194
|
* Each history-participating overlay (modal, floating window)
|
|
190
195
|
* pushes a { id, close } record here when it opens, plus a
|
|
@@ -532,6 +537,7 @@ function mt_start(gobj)
|
|
|
532
537
|
return;
|
|
533
538
|
}
|
|
534
539
|
if(escape_is_taken(ev)) {
|
|
540
|
+
take_back_focus(ev);
|
|
535
541
|
return;
|
|
536
542
|
}
|
|
537
543
|
let top = priv.escape_stack[priv.escape_stack.length - 1];
|
|
@@ -573,9 +579,11 @@ function mt_stop(gobj)
|
|
|
573
579
|
return 0;
|
|
574
580
|
}
|
|
575
581
|
|
|
576
|
-
/* Tear down
|
|
577
|
-
*
|
|
578
|
-
*
|
|
582
|
+
/* Tear down every overlay that was open at stop time -- drawers,
|
|
583
|
+
* modals, questions, the toolbar dropdown -- so no focus trap,
|
|
584
|
+
* document-level listener or escape-stack entry outlives the
|
|
585
|
+
* shell. */
|
|
586
|
+
close_overlays(gobj);
|
|
579
587
|
close_toolbar_dropdown(gobj);
|
|
580
588
|
|
|
581
589
|
if(priv.hash_handler) {
|
|
@@ -648,7 +656,8 @@ function mt_destroy(gobj)
|
|
|
648
656
|
* dropdown; calling close_toolbar_dropdown here is idempotent
|
|
649
657
|
* (it returns early when nothing is open) and prevents a
|
|
650
658
|
* dangling document mousedown listener / escape-stack entry
|
|
651
|
-
* when stop is skipped. */
|
|
659
|
+
* when stop is skipped. The other overlays the same way. */
|
|
660
|
+
close_overlays(gobj);
|
|
652
661
|
close_toolbar_dropdown(gobj);
|
|
653
662
|
|
|
654
663
|
let live_idx = __live_shells__.indexOf(gobj);
|
|
@@ -2527,7 +2536,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
|
|
|
2527
2536
|
$panel.__yui_backdrop_handler__ = backdrop;
|
|
2528
2537
|
$panel.__yui_dismiss_handler__ = dismiss;
|
|
2529
2538
|
$panel.__yui_trigger__ = $trigger || null;
|
|
2530
|
-
push_escape(gobj, "popup", close_fn);
|
|
2539
|
+
push_escape(gobj, "popup", close_fn, close_fn);
|
|
2531
2540
|
|
|
2532
2541
|
/* Focus trap inside the panel — same module modals/drawers use. */
|
|
2533
2542
|
$panel.__yui_focus_release__ = activate_focus_trap_on($panel);
|
|
@@ -2711,21 +2720,86 @@ function drawers(gobj, menu_id)
|
|
|
2711
2720
|
return out;
|
|
2712
2721
|
}
|
|
2713
2722
|
|
|
2723
|
+
/************************************************************
|
|
2724
|
+
* An Escape that closed an inline editor (a table cell) took the
|
|
2725
|
+
* focus with it, to <body>: the overlay that holds the focus (the
|
|
2726
|
+
* top trap: a dialog, a drawer) takes it back, as a window does --
|
|
2727
|
+
* a reader was left on the page, outside the dialog it was in.
|
|
2728
|
+
************************************************************/
|
|
2729
|
+
function take_back_focus(ev)
|
|
2730
|
+
{
|
|
2731
|
+
if(!ev.target || ev.target.isConnected !== false) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
let active = document.activeElement;
|
|
2735
|
+
if(active && active !== document.body) {
|
|
2736
|
+
return;
|
|
2737
|
+
}
|
|
2738
|
+
let $panel = focus_trap_panel();
|
|
2739
|
+
if(!$panel || $panel.isConnected === false) {
|
|
2740
|
+
return;
|
|
2741
|
+
}
|
|
2742
|
+
if(!$panel.hasAttribute("tabindex")) {
|
|
2743
|
+
$panel.setAttribute("tabindex", "-1"); /* focusable, not in the Tab order */
|
|
2744
|
+
}
|
|
2745
|
+
$panel.focus();
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2714
2748
|
/************************************************************
|
|
2715
2749
|
* Escape priority chain helpers — push/pop a {layer, handler}
|
|
2716
2750
|
* record on `priv.escape_stack`. Escape calls the top entry
|
|
2717
2751
|
* only and consumes the event; LIFO ordering naturally matches
|
|
2718
2752
|
* the z-index layering most apps use (drawer at the bottom,
|
|
2719
2753
|
* modal on top, popup on top of that).
|
|
2754
|
+
*
|
|
2755
|
+
* `teardown` is the overlay's UNCONDITIONAL close, what the shell
|
|
2756
|
+
* runs when it stops with the overlay still up (close_overlays);
|
|
2757
|
+
* `handler` may be a guarded one (a modal's before_close).
|
|
2720
2758
|
************************************************************/
|
|
2721
|
-
function push_escape(gobj, layer, handler)
|
|
2759
|
+
function push_escape(gobj, layer, handler, teardown)
|
|
2722
2760
|
{
|
|
2723
2761
|
let priv = gobj.priv;
|
|
2724
2762
|
if(!priv || !priv.escape_stack) {
|
|
2725
2763
|
log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
|
|
2726
2764
|
return;
|
|
2727
2765
|
}
|
|
2728
|
-
priv.
|
|
2766
|
+
priv.escape_seq += 1;
|
|
2767
|
+
priv.escape_stack.push({
|
|
2768
|
+
layer: layer,
|
|
2769
|
+
handler: handler,
|
|
2770
|
+
teardown: (typeof teardown === "function") ? teardown : null,
|
|
2771
|
+
seq: priv.escape_seq
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
/************************************************************
|
|
2776
|
+
* Close every overlay still up, the top first, as if each had
|
|
2777
|
+
* been dismissed: a shell that stops -- a logout, a session cut
|
|
2778
|
+
* -- with a drawer, a modal or a question open. Up to gobj-ui
|
|
2779
|
+
* 7.26.45 only the toolbar dropdown was closed: the others kept
|
|
2780
|
+
* their focus trap, and every window opened afterwards believed
|
|
2781
|
+
* itself under an overlay and took no focus; a question never
|
|
2782
|
+
* answered. Run before the views stop, so what an overlay's
|
|
2783
|
+
* on_close calls is still alive. An overlay pushed with no
|
|
2784
|
+
* teardown is left to its owner.
|
|
2785
|
+
************************************************************/
|
|
2786
|
+
function close_overlays(gobj)
|
|
2787
|
+
{
|
|
2788
|
+
let priv = gobj.priv;
|
|
2789
|
+
if(!priv || !priv.escape_stack) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
let entries = priv.escape_stack.slice().reverse();
|
|
2793
|
+
for(let entry of entries) {
|
|
2794
|
+
if(!entry.teardown) {
|
|
2795
|
+
continue;
|
|
2796
|
+
}
|
|
2797
|
+
try {
|
|
2798
|
+
entry.teardown();
|
|
2799
|
+
} catch(e) {
|
|
2800
|
+
log_warning(`C_YUI_SHELL: closing the '${entry.layer}' overlay at stop failed: ${e}`);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2729
2803
|
}
|
|
2730
2804
|
|
|
2731
2805
|
function pop_escape(gobj, handler)
|
|
@@ -3138,7 +3212,7 @@ function open_drawer_one(gobj, $c)
|
|
|
3138
3212
|
}
|
|
3139
3213
|
let close_fn = () => close_drawer_one(gobj, $c);
|
|
3140
3214
|
$c.__yui_close_handler__ = close_fn;
|
|
3141
|
-
push_escape(gobj, "overlay", close_fn);
|
|
3215
|
+
push_escape(gobj, "overlay", close_fn, close_fn);
|
|
3142
3216
|
$c.classList.add("is-active");
|
|
3143
3217
|
let panel = $c.querySelector(".yui-drawer-panel") || $c;
|
|
3144
3218
|
$c.__yui_focus_release__ = activate_focus_trap_on(panel);
|
|
@@ -4420,16 +4494,42 @@ function yui_shell_toggle_drawer(shell_gobj, menu_id)
|
|
|
4420
4494
|
* `layer` is a free-form tag (e.g. "modal", "popup", "overlay").
|
|
4421
4495
|
* Today it is informational; the LIFO ordering of the stack is
|
|
4422
4496
|
* what determines Escape priority — and naturally matches the
|
|
4423
|
-
* z-index layering most apps use (drawer < popup < modal).
|
|
4424
|
-
|
|
4497
|
+
* z-index layering most apps use (drawer < popup < modal).
|
|
4498
|
+
*
|
|
4499
|
+
* `teardown` (optional): the overlay's unconditional close, which
|
|
4500
|
+
* the shell runs if it stops with the overlay still up (a logout
|
|
4501
|
+
* with a modal open). Give it whenever `handler` may refuse to
|
|
4502
|
+
* close, or the overlay outlives its shell with its focus trap. */
|
|
4503
|
+
function yui_shell_push_escape(shell_gobj, layer, handler, teardown)
|
|
4425
4504
|
{
|
|
4426
|
-
push_escape(shell_gobj, layer, handler);
|
|
4505
|
+
push_escape(shell_gobj, layer, handler, teardown);
|
|
4427
4506
|
}
|
|
4428
4507
|
function yui_shell_pop_escape(shell_gobj, handler)
|
|
4429
4508
|
{
|
|
4430
4509
|
pop_escape(shell_gobj, handler);
|
|
4431
4510
|
}
|
|
4432
4511
|
|
|
4512
|
+
/* The order of the overlay Escape closes first (the top of the
|
|
4513
|
+
* stack), 0 when there is none. The orders only grow, so a window
|
|
4514
|
+
* that kept the answer when it opened knows, at its own Escape,
|
|
4515
|
+
* whether an overlay was opened after it -- and yields the key to
|
|
4516
|
+
* the shell, which closes that overlay first:
|
|
4517
|
+
*
|
|
4518
|
+
* priv.escape_order = yui_shell_escape_order(shell); // opened
|
|
4519
|
+
* ...
|
|
4520
|
+
* if(yui_shell_escape_order(shell) > priv.escape_order) {
|
|
4521
|
+
* return; // not mine: the shell's
|
|
4522
|
+
* }
|
|
4523
|
+
*/
|
|
4524
|
+
function yui_shell_escape_order(shell_gobj)
|
|
4525
|
+
{
|
|
4526
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
4527
|
+
if(!priv || !priv.escape_stack || priv.escape_stack.length === 0) {
|
|
4528
|
+
return 0;
|
|
4529
|
+
}
|
|
4530
|
+
return priv.escape_stack[priv.escape_stack.length - 1].seq;
|
|
4531
|
+
}
|
|
4532
|
+
|
|
4433
4533
|
/* Overlay history integration — public API for overlays the shell does
|
|
4434
4534
|
* not own (modals from shell_modals.js, floating C_YUI_WINDOW popups).
|
|
4435
4535
|
*
|
|
@@ -4819,6 +4919,7 @@ export {
|
|
|
4819
4919
|
yui_shell_toggle_drawer,
|
|
4820
4920
|
yui_shell_push_escape,
|
|
4821
4921
|
yui_shell_pop_escape,
|
|
4922
|
+
yui_shell_escape_order,
|
|
4822
4923
|
yui_shell_register_overlay,
|
|
4823
4924
|
yui_shell_overlay_dismissed,
|
|
4824
4925
|
yui_shell_unpark_route,
|
package/src/c_yui_window.js
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
is_gobj,
|
|
51
51
|
kw_get_local_storage_value,
|
|
52
52
|
kw_set_local_storage_value,
|
|
53
|
+
kw_remove_local_storage_value,
|
|
53
54
|
gobj_read_attr,
|
|
54
55
|
gobj_read_bool_attr,
|
|
55
56
|
gobj_read_str_attr,
|
|
@@ -80,10 +81,11 @@ import {
|
|
|
80
81
|
yui_shell_window_layer,
|
|
81
82
|
yui_shell_modal_layer,
|
|
82
83
|
yui_shell_raise_window,
|
|
84
|
+
yui_shell_escape_order,
|
|
83
85
|
yui_shell_watch_changes,
|
|
84
86
|
yui_shell_unwatch_changes,
|
|
85
87
|
} from "./c_yui_shell.js";
|
|
86
|
-
import {activate_focus_trap_on, FOCUSABLE_SELECTOR} from "./shell_focus_trap.js";
|
|
88
|
+
import {activate_focus_trap_on, focus_trap_panel, FOCUSABLE_SELECTOR} from "./shell_focus_trap.js";
|
|
87
89
|
import {escape_is_taken} from "./escape_taken.js";
|
|
88
90
|
|
|
89
91
|
import "./c_yui_window.css";
|
|
@@ -181,6 +183,9 @@ let PRIVATE_DATA = {
|
|
|
181
183
|
* release of its focus trap. */
|
|
182
184
|
$lock: null,
|
|
183
185
|
release_focus: null,
|
|
186
|
+
/* The top of the shell's Escape stack when the window started:
|
|
187
|
+
* an overlay opened after it takes the key first. */
|
|
188
|
+
escape_order: 0,
|
|
184
189
|
};
|
|
185
190
|
|
|
186
191
|
let __gclass__ = null;
|
|
@@ -313,6 +318,12 @@ function mt_create(gobj)
|
|
|
313
318
|
* the first Tab of a keyboard reader landed in a window they had
|
|
314
319
|
* not opened. A modal window takes it all the same: nothing else
|
|
315
320
|
* can be used while it is up.
|
|
321
|
+
*
|
|
322
|
+
* Nor does one opened under an overlay that holds the focus (a
|
|
323
|
+
* modal window, a dialog, a drawer, a menu: all are drawn above
|
|
324
|
+
* the window layer). Up to gobj-ui 7.26.44 it took the focus where
|
|
325
|
+
* it could not be seen, and the next Tab gave it back to the
|
|
326
|
+
* overlay; it opens under it now, and is there when it goes.
|
|
316
327
|
***************************************************************/
|
|
317
328
|
function mt_start(gobj)
|
|
318
329
|
{
|
|
@@ -328,12 +339,16 @@ function mt_start(gobj)
|
|
|
328
339
|
if(active && active !== document.body && !$container.contains(active)) {
|
|
329
340
|
priv.opener = active;
|
|
330
341
|
}
|
|
342
|
+
priv.escape_order = yui_shell_escape_order(yui_shell_of(gobj));
|
|
331
343
|
let modal = gobj_read_bool_attr(gobj, "modal");
|
|
344
|
+
/* Read before a modal one puts up its own. */
|
|
345
|
+
let $trap = focus_trap_panel();
|
|
346
|
+
let under_an_overlay = !!$trap && !$trap.contains($container);
|
|
332
347
|
if(modal && !priv.release_focus) {
|
|
333
348
|
/* Saves the opener itself, and gives it back on release. */
|
|
334
349
|
priv.release_focus = activate_focus_trap_on($container);
|
|
335
350
|
}
|
|
336
|
-
if(modal || opened_by_the_reader()) {
|
|
351
|
+
if(modal || (opened_by_the_reader() && !under_an_overlay)) {
|
|
337
352
|
focus_target(gobj, $container).focus();
|
|
338
353
|
}
|
|
339
354
|
}
|
|
@@ -641,8 +656,9 @@ function window_root(gobj)
|
|
|
641
656
|
/************************************************************
|
|
642
657
|
* An Escape typed in the window. The callback only decides
|
|
643
658
|
* whether the key is the window's -- not when `keyboard` is
|
|
644
|
-
* off, nor one that what it was typed in took
|
|
645
|
-
*
|
|
659
|
+
* off, nor one that what it was typed in took, nor while an
|
|
660
|
+
* overlay of the shell opened after the window is up -- and
|
|
661
|
+
* sends the event: the close is the ✕'s, in the action.
|
|
646
662
|
************************************************************/
|
|
647
663
|
function on_escape_key(gobj, evt)
|
|
648
664
|
{
|
|
@@ -664,6 +680,9 @@ function on_escape_key(gobj, evt)
|
|
|
664
680
|
}
|
|
665
681
|
return;
|
|
666
682
|
}
|
|
683
|
+
if(yui_shell_escape_order(yui_shell_of(gobj)) > gobj.priv.escape_order) {
|
|
684
|
+
return; /* a shell overlay opened after the window: the shell closes it */
|
|
685
|
+
}
|
|
667
686
|
evt.preventDefault();
|
|
668
687
|
evt.stopPropagation();
|
|
669
688
|
gobj_send_event(gobj, "EV_CLOSE_WINDOW", {key: "Escape"}, gobj);
|
|
@@ -747,7 +766,25 @@ function build_ui(gobj)
|
|
|
747
766
|
*----------------------------------------------*/
|
|
748
767
|
if(gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
|
|
749
768
|
if(gobj_is_service(gobj)) {
|
|
750
|
-
|
|
769
|
+
/* A bad entry is said ONCE: forgotten, the next move or
|
|
770
|
+
* resize saves a good one. A rect with no size is what the
|
|
771
|
+
* box of a window not drawn answers. One only off the screen
|
|
772
|
+
* is kept: x, y, width and height are the DESIRED place,
|
|
773
|
+
* clamped to the viewport here and on every resize
|
|
774
|
+
* (handleResize), so a window saved on a larger screen goes
|
|
775
|
+
* back there when it is plugged in again. */
|
|
776
|
+
let key = `${gobj_name(gobj)}-rect`;
|
|
777
|
+
let stored = kw_get_local_storage_value(key);
|
|
778
|
+
let rect = whole_rect(stored);
|
|
779
|
+
if(!rect && stored != null) {
|
|
780
|
+
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
|
|
781
|
+
kw_remove_local_storage_value(key);
|
|
782
|
+
} else if(rect && (rect.width <= 0 || rect.height <= 0)) {
|
|
783
|
+
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' has no size ` +
|
|
784
|
+
`(${rect.width} x ${rect.height}): ignored`);
|
|
785
|
+
kw_remove_local_storage_value(key);
|
|
786
|
+
rect = null;
|
|
787
|
+
}
|
|
751
788
|
if(rect) {
|
|
752
789
|
rect.x = rect.x<0?0:rect.x;
|
|
753
790
|
rect.y = rect.y<0?0:rect.y;
|
|
@@ -1689,6 +1726,8 @@ function ac_shell_changed(gobj, event, kw, src)
|
|
|
1689
1726
|
gobj_write_attr(gobj, "back_overlay", null);
|
|
1690
1727
|
priv.back_shell = null;
|
|
1691
1728
|
}
|
|
1729
|
+
/* The order it kept is of the other shell's Escape stack. */
|
|
1730
|
+
priv.escape_order = going? 0 : yui_shell_escape_order(src);
|
|
1692
1731
|
|
|
1693
1732
|
let $container = gobj_read_attr(gobj, "$container");
|
|
1694
1733
|
if(!$container) {
|
|
@@ -60,6 +60,13 @@ vi.mock("tabulator-tables", () => {
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
tables.push(this);
|
|
63
|
+
/* The rows it is built with (`data`): drawn, and no
|
|
64
|
+
* `dataChanged`, as Tabulator loads them. */
|
|
65
|
+
if(settings && Array.isArray(settings.data)) {
|
|
66
|
+
for(const record of settings.data) {
|
|
67
|
+
this.add(record, true);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
63
70
|
return new Proxy(this, {
|
|
64
71
|
get(target, prop) {
|
|
65
72
|
if(prop in target) {
|
|
@@ -80,7 +87,7 @@ vi.mock("tabulator-tables", () => {
|
|
|
80
87
|
fn([]);
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
|
-
add(record) {
|
|
90
|
+
add(record, silent) {
|
|
84
91
|
/* The row's element lives in the table's, as in Tabulator:
|
|
85
92
|
* a nested table drawn in it is inside the form. */
|
|
86
93
|
const $row = document.createElement("div");
|
|
@@ -90,7 +97,9 @@ vi.mock("tabulator-tables", () => {
|
|
|
90
97
|
this.settings.rowFormatter(row);
|
|
91
98
|
}
|
|
92
99
|
this.rows.push(row);
|
|
93
|
-
|
|
100
|
+
if(!silent) {
|
|
101
|
+
this.emit("dataChanged");
|
|
102
|
+
}
|
|
94
103
|
return row;
|
|
95
104
|
}
|
|
96
105
|
addRow(record) {
|