@yuneta/gobj-ui 7.26.44 → 7.26.45
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 +83 -16
- package/dist/gobj-ui.cjs.js +103 -20
- package/dist/gobj-ui.es.js +103 -21
- package/index.js +1 -0
- package/package.json +1 -1
- package/scripts/check-markup-strings.mjs +4 -1
- package/scripts/validate-locales.mjs +531 -155
- package/src/c_yui_form.js +47 -32
- package/src/c_yui_node.js +3 -1
- package/src/c_yui_schema_editor.js +3 -0
- package/src/c_yui_shell.js +55 -1
- package/src/c_yui_window.js +30 -5
- package/src/form_table_edits_ask.wiring.test.js +11 -2
- package/src/form_table_rows.wiring.test.js +120 -8
- package/src/i18n_key_functions.js +2 -2
- package/src/i18n_key_functions.test.js +37 -3
- 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 +15 -0
- package/src/window_dialog.wiring.test.js +80 -1
- package/src/window_rect_rounding.wiring.test.js +22 -0
package/src/c_yui_form.js
CHANGED
|
@@ -132,7 +132,7 @@ SDATA(data_type_t.DTP_STRING, "pkey", 0, "id", "Primary key fie
|
|
|
132
132
|
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
133
|
SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
|
|
134
134
|
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, "
|
|
135
|
+
SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
|
|
136
136
|
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
|
|
137
137
|
SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
|
|
138
138
|
SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
|
|
@@ -613,6 +613,22 @@ function destroy_widget(gobj, what, widget)
|
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
/************************************************************
|
|
617
|
+
* Close the cell editor a table has open, dropping what is
|
|
618
|
+
* typed in it, before its rows are wiped. Tabulator 6.6.0
|
|
619
|
+
* closes it while it wipes them, and the redraw that follows
|
|
620
|
+
* walks the rows already wiped: a reload, a Clear or a destroy
|
|
621
|
+
* with an editor open in any row but the first threw, and left
|
|
622
|
+
* the table half wiped.
|
|
623
|
+
************************************************************/
|
|
624
|
+
function close_table_editor(tabulator)
|
|
625
|
+
{
|
|
626
|
+
let edit = tabulator.modules? tabulator.modules.edit : null;
|
|
627
|
+
if(edit && edit.currentCell) {
|
|
628
|
+
edit.cancelEdit();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
616
632
|
/************************************************************
|
|
617
633
|
* A table element that is gone: its identity is no table now,
|
|
618
634
|
* and what was waiting to be loaded in it never will be.
|
|
@@ -639,6 +655,7 @@ function destroy_row_tables(gobj, $row)
|
|
|
639
655
|
$row.yui_nested = null;
|
|
640
656
|
for(let $nested of nested) {
|
|
641
657
|
if($nested.tabulator) {
|
|
658
|
+
close_table_editor($nested.tabulator);
|
|
642
659
|
destroy_rows_tables(gobj, $nested.tabulator);
|
|
643
660
|
destroy_widget(gobj, "nested table", $nested.tabulator);
|
|
644
661
|
$nested.tabulator = null;
|
|
@@ -677,6 +694,7 @@ function destroy_widgets(gobj, $container)
|
|
|
677
694
|
$el.jsoneditor = null;
|
|
678
695
|
}
|
|
679
696
|
if($el.tabulator) {
|
|
697
|
+
close_table_editor($el.tabulator);
|
|
680
698
|
destroy_rows_tables(gobj, $el.tabulator);
|
|
681
699
|
destroy_widget(gobj, "table", $el.tabulator);
|
|
682
700
|
$el.tabulator = null;
|
|
@@ -2222,7 +2240,8 @@ function create_coordinates(gobj, attrs)
|
|
|
2222
2240
|
* Create tabulator
|
|
2223
2241
|
*
|
|
2224
2242
|
* A row builds its nested tables the first time it is drawn, each
|
|
2225
|
-
*
|
|
2243
|
+
* BUILT with the rows of the row's own data (`rows`, a copy: the
|
|
2244
|
+
* table keeps what it is given), and keeps them on its element
|
|
2226
2245
|
* (`yui_nested`) until the row goes (destroy_row_tables). A row
|
|
2227
2246
|
* drawn AGAIN -- a forced redraw, a column rebuilt -- has its
|
|
2228
2247
|
* children taken off by Tabulator before its formatter runs: they
|
|
@@ -2233,31 +2252,35 @@ function create_coordinates(gobj, attrs)
|
|
|
2233
2252
|
* `tableBuilt`, ONE per table (`yui_pending_rows`): a later load
|
|
2234
2253
|
* replaces it, a clear drops it. Each load used to hang a listener
|
|
2235
2254
|
* of its own, so two loads before the build drew the rows twice.
|
|
2255
|
+
*
|
|
2256
|
+
* A nested table is not loaded after it is built, as the form's
|
|
2257
|
+
* own tables are (EV_LOAD_TABLE_ROWS): each such load laid it out
|
|
2258
|
+
* twice and redrew it once more, and with a nested table per row
|
|
2259
|
+
* that was most of the time of a load.
|
|
2260
|
+
*
|
|
2261
|
+
* A table selects rows only when a host sets `selectableRows` (true
|
|
2262
|
+
* or a number) in `tabulator_settings`. Tabulator's SelectRow then
|
|
2263
|
+
* toggles a row on its own click, asking `selectableRowsCheck` --
|
|
2264
|
+
* the form's `selectable` -- first. Up to 7.26.44 the form toggled
|
|
2265
|
+
* the row again in `rowClick`, which undid every click. The default
|
|
2266
|
+
* `"highlight"` is left as it is, hover and all.
|
|
2236
2267
|
******************************************************************/
|
|
2237
|
-
function create_tabulator(gobj, $extend, name, template)
|
|
2268
|
+
function create_tabulator(gobj, $extend, name, template, rows)
|
|
2238
2269
|
{
|
|
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
2270
|
$extend.template = template;
|
|
2250
2271
|
|
|
2251
2272
|
let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
|
|
2273
|
+
if(is_array(rows) && rows.length > 0) {
|
|
2274
|
+
tabulator_settings.data = json_deep_copy(rows);
|
|
2275
|
+
}
|
|
2252
2276
|
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
});
|
|
2277
|
+
/* Tabulator toggles the row on its own click: `selectable` only vetoes */
|
|
2278
|
+
let selectable_rows = tabulator_settings.selectableRows;
|
|
2279
|
+
if(selectable_rows === true || typeof selectable_rows === "number") {
|
|
2280
|
+
tabulator_settings.selectableRowsCheck = function() {
|
|
2281
|
+
return gobj_read_bool_attr(gobj, "selectable");
|
|
2282
|
+
};
|
|
2283
|
+
}
|
|
2261
2284
|
|
|
2262
2285
|
let columns = [];
|
|
2263
2286
|
if(gobj_read_bool_attr(gobj, "with_rownum")) {
|
|
@@ -2294,13 +2317,12 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2294
2317
|
}
|
|
2295
2318
|
];
|
|
2296
2319
|
let $extend = createElement2(extend);
|
|
2320
|
+
let rows = data[sub_element.name];
|
|
2297
2321
|
$extend.tabulator = create_tabulator(
|
|
2298
|
-
gobj, $extend, sub_element.name, sub_element.template
|
|
2322
|
+
gobj, $extend, sub_element.name, sub_element.template, rows
|
|
2299
2323
|
);
|
|
2300
2324
|
$row.appendChild($extend);
|
|
2301
2325
|
$row.yui_nested.push($extend);
|
|
2302
|
-
let rows = data[sub_element.name];
|
|
2303
|
-
load_tabulator_data(gobj, $extend, is_array(rows)? rows : []);
|
|
2304
2326
|
}
|
|
2305
2327
|
};
|
|
2306
2328
|
}
|
|
@@ -2395,20 +2417,12 @@ function create_tabulator(gobj, $extend, name, template)
|
|
|
2395
2417
|
//e - the click event object
|
|
2396
2418
|
//row - row component
|
|
2397
2419
|
e.preventDefault();
|
|
2398
|
-
if(get_selectable_state(row)) {
|
|
2399
|
-
row.toggleSelect();
|
|
2400
|
-
}
|
|
2401
2420
|
});
|
|
2402
2421
|
|
|
2403
2422
|
tabulator.on("cellClick", function(e, cell) {
|
|
2404
2423
|
//e - the click event object
|
|
2405
2424
|
//cell - cell component
|
|
2406
2425
|
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
2426
|
});
|
|
2413
2427
|
|
|
2414
2428
|
return tabulator;
|
|
@@ -3142,6 +3156,7 @@ function clear_data(gobj, $form)
|
|
|
3142
3156
|
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
3143
3157
|
$table.yui_pending_rows = null;
|
|
3144
3158
|
if($table.tabulator.initialized) {
|
|
3159
|
+
close_table_editor($table.tabulator);
|
|
3145
3160
|
destroy_rows_tables(gobj, $table.tabulator);
|
|
3146
3161
|
$table.tabulator.clearData();
|
|
3147
3162
|
}
|
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
|
|
|
@@ -185,6 +186,10 @@ let PRIVATE_DATA = {
|
|
|
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];
|
|
@@ -2711,6 +2717,31 @@ function drawers(gobj, menu_id)
|
|
|
2711
2717
|
return out;
|
|
2712
2718
|
}
|
|
2713
2719
|
|
|
2720
|
+
/************************************************************
|
|
2721
|
+
* An Escape that closed an inline editor (a table cell) took the
|
|
2722
|
+
* focus with it, to <body>: the overlay that holds the focus (the
|
|
2723
|
+
* top trap: a dialog, a drawer) takes it back, as a window does --
|
|
2724
|
+
* a reader was left on the page, outside the dialog it was in.
|
|
2725
|
+
************************************************************/
|
|
2726
|
+
function take_back_focus(ev)
|
|
2727
|
+
{
|
|
2728
|
+
if(!ev.target || ev.target.isConnected !== false) {
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
let active = document.activeElement;
|
|
2732
|
+
if(active && active !== document.body) {
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
let $panel = focus_trap_panel();
|
|
2736
|
+
if(!$panel || $panel.isConnected === false) {
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2739
|
+
if(!$panel.hasAttribute("tabindex")) {
|
|
2740
|
+
$panel.setAttribute("tabindex", "-1"); /* focusable, not in the Tab order */
|
|
2741
|
+
}
|
|
2742
|
+
$panel.focus();
|
|
2743
|
+
}
|
|
2744
|
+
|
|
2714
2745
|
/************************************************************
|
|
2715
2746
|
* Escape priority chain helpers — push/pop a {layer, handler}
|
|
2716
2747
|
* record on `priv.escape_stack`. Escape calls the top entry
|
|
@@ -2725,7 +2756,8 @@ function push_escape(gobj, layer, handler)
|
|
|
2725
2756
|
log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
|
|
2726
2757
|
return;
|
|
2727
2758
|
}
|
|
2728
|
-
priv.
|
|
2759
|
+
priv.escape_seq += 1;
|
|
2760
|
+
priv.escape_stack.push({ layer: layer, handler: handler, seq: priv.escape_seq });
|
|
2729
2761
|
}
|
|
2730
2762
|
|
|
2731
2763
|
function pop_escape(gobj, handler)
|
|
@@ -4430,6 +4462,27 @@ function yui_shell_pop_escape(shell_gobj, handler)
|
|
|
4430
4462
|
pop_escape(shell_gobj, handler);
|
|
4431
4463
|
}
|
|
4432
4464
|
|
|
4465
|
+
/* The order of the overlay Escape closes first (the top of the
|
|
4466
|
+
* stack), 0 when there is none. The orders only grow, so a window
|
|
4467
|
+
* that kept the answer when it opened knows, at its own Escape,
|
|
4468
|
+
* whether an overlay was opened after it -- and yields the key to
|
|
4469
|
+
* the shell, which closes that overlay first:
|
|
4470
|
+
*
|
|
4471
|
+
* priv.escape_order = yui_shell_escape_order(shell); // opened
|
|
4472
|
+
* ...
|
|
4473
|
+
* if(yui_shell_escape_order(shell) > priv.escape_order) {
|
|
4474
|
+
* return; // not mine: the shell's
|
|
4475
|
+
* }
|
|
4476
|
+
*/
|
|
4477
|
+
function yui_shell_escape_order(shell_gobj)
|
|
4478
|
+
{
|
|
4479
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
4480
|
+
if(!priv || !priv.escape_stack || priv.escape_stack.length === 0) {
|
|
4481
|
+
return 0;
|
|
4482
|
+
}
|
|
4483
|
+
return priv.escape_stack[priv.escape_stack.length - 1].seq;
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4433
4486
|
/* Overlay history integration — public API for overlays the shell does
|
|
4434
4487
|
* not own (modals from shell_modals.js, floating C_YUI_WINDOW popups).
|
|
4435
4488
|
*
|
|
@@ -4819,6 +4872,7 @@ export {
|
|
|
4819
4872
|
yui_shell_toggle_drawer,
|
|
4820
4873
|
yui_shell_push_escape,
|
|
4821
4874
|
yui_shell_pop_escape,
|
|
4875
|
+
yui_shell_escape_order,
|
|
4822
4876
|
yui_shell_register_overlay,
|
|
4823
4877
|
yui_shell_overlay_dismissed,
|
|
4824
4878
|
yui_shell_unpark_route,
|
package/src/c_yui_window.js
CHANGED
|
@@ -80,10 +80,11 @@ import {
|
|
|
80
80
|
yui_shell_window_layer,
|
|
81
81
|
yui_shell_modal_layer,
|
|
82
82
|
yui_shell_raise_window,
|
|
83
|
+
yui_shell_escape_order,
|
|
83
84
|
yui_shell_watch_changes,
|
|
84
85
|
yui_shell_unwatch_changes,
|
|
85
86
|
} from "./c_yui_shell.js";
|
|
86
|
-
import {activate_focus_trap_on, FOCUSABLE_SELECTOR} from "./shell_focus_trap.js";
|
|
87
|
+
import {activate_focus_trap_on, focus_trap_panel, FOCUSABLE_SELECTOR} from "./shell_focus_trap.js";
|
|
87
88
|
import {escape_is_taken} from "./escape_taken.js";
|
|
88
89
|
|
|
89
90
|
import "./c_yui_window.css";
|
|
@@ -181,6 +182,9 @@ let PRIVATE_DATA = {
|
|
|
181
182
|
* release of its focus trap. */
|
|
182
183
|
$lock: null,
|
|
183
184
|
release_focus: null,
|
|
185
|
+
/* The top of the shell's Escape stack when the window started:
|
|
186
|
+
* an overlay opened after it takes the key first. */
|
|
187
|
+
escape_order: 0,
|
|
184
188
|
};
|
|
185
189
|
|
|
186
190
|
let __gclass__ = null;
|
|
@@ -313,6 +317,12 @@ function mt_create(gobj)
|
|
|
313
317
|
* the first Tab of a keyboard reader landed in a window they had
|
|
314
318
|
* not opened. A modal window takes it all the same: nothing else
|
|
315
319
|
* can be used while it is up.
|
|
320
|
+
*
|
|
321
|
+
* Nor does one opened under an overlay that holds the focus (a
|
|
322
|
+
* modal window, a dialog, a drawer, a menu: all are drawn above
|
|
323
|
+
* the window layer). Up to gobj-ui 7.26.44 it took the focus where
|
|
324
|
+
* it could not be seen, and the next Tab gave it back to the
|
|
325
|
+
* overlay; it opens under it now, and is there when it goes.
|
|
316
326
|
***************************************************************/
|
|
317
327
|
function mt_start(gobj)
|
|
318
328
|
{
|
|
@@ -328,12 +338,16 @@ function mt_start(gobj)
|
|
|
328
338
|
if(active && active !== document.body && !$container.contains(active)) {
|
|
329
339
|
priv.opener = active;
|
|
330
340
|
}
|
|
341
|
+
priv.escape_order = yui_shell_escape_order(yui_shell_of(gobj));
|
|
331
342
|
let modal = gobj_read_bool_attr(gobj, "modal");
|
|
343
|
+
/* Read before a modal one puts up its own. */
|
|
344
|
+
let $trap = focus_trap_panel();
|
|
345
|
+
let under_an_overlay = !!$trap && !$trap.contains($container);
|
|
332
346
|
if(modal && !priv.release_focus) {
|
|
333
347
|
/* Saves the opener itself, and gives it back on release. */
|
|
334
348
|
priv.release_focus = activate_focus_trap_on($container);
|
|
335
349
|
}
|
|
336
|
-
if(modal || opened_by_the_reader()) {
|
|
350
|
+
if(modal || (opened_by_the_reader() && !under_an_overlay)) {
|
|
337
351
|
focus_target(gobj, $container).focus();
|
|
338
352
|
}
|
|
339
353
|
}
|
|
@@ -641,8 +655,9 @@ function window_root(gobj)
|
|
|
641
655
|
/************************************************************
|
|
642
656
|
* An Escape typed in the window. The callback only decides
|
|
643
657
|
* whether the key is the window's -- not when `keyboard` is
|
|
644
|
-
* off, nor one that what it was typed in took
|
|
645
|
-
*
|
|
658
|
+
* off, nor one that what it was typed in took, nor while an
|
|
659
|
+
* overlay of the shell opened after the window is up -- and
|
|
660
|
+
* sends the event: the close is the ✕'s, in the action.
|
|
646
661
|
************************************************************/
|
|
647
662
|
function on_escape_key(gobj, evt)
|
|
648
663
|
{
|
|
@@ -664,6 +679,9 @@ function on_escape_key(gobj, evt)
|
|
|
664
679
|
}
|
|
665
680
|
return;
|
|
666
681
|
}
|
|
682
|
+
if(yui_shell_escape_order(yui_shell_of(gobj)) > gobj.priv.escape_order) {
|
|
683
|
+
return; /* a shell overlay opened after the window: the shell closes it */
|
|
684
|
+
}
|
|
667
685
|
evt.preventDefault();
|
|
668
686
|
evt.stopPropagation();
|
|
669
687
|
gobj_send_event(gobj, "EV_CLOSE_WINDOW", {key: "Escape"}, gobj);
|
|
@@ -747,7 +765,12 @@ function build_ui(gobj)
|
|
|
747
765
|
*----------------------------------------------*/
|
|
748
766
|
if(gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
|
|
749
767
|
if(gobj_is_service(gobj)) {
|
|
750
|
-
let
|
|
768
|
+
let key = `${gobj_name(gobj)}-rect`;
|
|
769
|
+
let stored = kw_get_local_storage_value(key);
|
|
770
|
+
let rect = whole_rect(stored);
|
|
771
|
+
if(!rect && stored != null) {
|
|
772
|
+
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
|
|
773
|
+
}
|
|
751
774
|
if(rect) {
|
|
752
775
|
rect.x = rect.x<0?0:rect.x;
|
|
753
776
|
rect.y = rect.y<0?0:rect.y;
|
|
@@ -1689,6 +1712,8 @@ function ac_shell_changed(gobj, event, kw, src)
|
|
|
1689
1712
|
gobj_write_attr(gobj, "back_overlay", null);
|
|
1690
1713
|
priv.back_shell = null;
|
|
1691
1714
|
}
|
|
1715
|
+
/* The order it kept is of the other shell's Escape stack. */
|
|
1716
|
+
priv.escape_order = going? 0 : yui_shell_escape_order(src);
|
|
1692
1717
|
|
|
1693
1718
|
let $container = gobj_read_attr(gobj, "$container");
|
|
1694
1719
|
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) {
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
* getData() with copies and a row's getData() with the row itself,
|
|
27
27
|
* draws a row by running its formatter, says `dataChanged` per row
|
|
28
28
|
* added, synchronously, and builds itself a turn after it is made.
|
|
29
|
+
* A click on a row toggles it before `rowClick`, as Tabulator's
|
|
30
|
+
* SelectRow does when the table selects rows: a form that toggled
|
|
31
|
+
* it again in `rowClick` (7.26.44) undid every click.
|
|
29
32
|
*
|
|
30
33
|
* Copyright (c) 2026, ArtGins.
|
|
31
34
|
* All Rights Reserved.
|
|
@@ -62,12 +65,22 @@ vi.mock("tabulator-tables", () => {
|
|
|
62
65
|
localize: {
|
|
63
66
|
installLang: () => {
|
|
64
67
|
}
|
|
68
|
+
},
|
|
69
|
+
edit: {
|
|
70
|
+
currentCell: false,
|
|
71
|
+
cancelEdit: () => {
|
|
72
|
+
this.modules.edit.currentCell = false;
|
|
73
|
+
}
|
|
65
74
|
}
|
|
66
75
|
};
|
|
67
76
|
tables.push(this);
|
|
68
|
-
/* Tabulator builds itself a turn after it is made
|
|
77
|
+
/* Tabulator builds itself a turn after it is made, with
|
|
78
|
+
* the rows it was given (`data`), saying no `dataChanged`. */
|
|
69
79
|
setTimeout(() => {
|
|
70
80
|
if(!this.destroyed) {
|
|
81
|
+
for(const record of (settings && settings.data) || []) {
|
|
82
|
+
this.add(record, true);
|
|
83
|
+
}
|
|
71
84
|
this.initialized = true;
|
|
72
85
|
this.emit("tableBuilt");
|
|
73
86
|
}
|
|
@@ -97,7 +110,7 @@ vi.mock("tabulator-tables", () => {
|
|
|
97
110
|
throw new Error("Table Not Initialized");
|
|
98
111
|
}
|
|
99
112
|
}
|
|
100
|
-
add(record) {
|
|
113
|
+
add(record, silent) {
|
|
101
114
|
const $row = document.createElement("div");
|
|
102
115
|
this.element.appendChild($row);
|
|
103
116
|
const row = {data: record, $row: $row};
|
|
@@ -105,7 +118,7 @@ vi.mock("tabulator-tables", () => {
|
|
|
105
118
|
getElement: () => row.$row,
|
|
106
119
|
getData: () => row.data,
|
|
107
120
|
toggleSelect: () => {
|
|
108
|
-
|
|
121
|
+
this.toggle_row(row);
|
|
109
122
|
},
|
|
110
123
|
delete: () => {
|
|
111
124
|
this.delete_row(this.rows.indexOf(row));
|
|
@@ -115,7 +128,9 @@ vi.mock("tabulator-tables", () => {
|
|
|
115
128
|
this.settings.rowFormatter(row.component);
|
|
116
129
|
}
|
|
117
130
|
this.rows.push(row);
|
|
118
|
-
|
|
131
|
+
if(!silent) {
|
|
132
|
+
this.emit("dataChanged");
|
|
133
|
+
}
|
|
119
134
|
return row.component;
|
|
120
135
|
}
|
|
121
136
|
addRow(record) {
|
|
@@ -128,6 +143,26 @@ vi.mock("tabulator-tables", () => {
|
|
|
128
143
|
this.calls.addData++;
|
|
129
144
|
return Promise.resolve(records.map((record) => this.add(record)));
|
|
130
145
|
}
|
|
146
|
+
/* SelectRow's own toggle, gated by `selectableRowsCheck`. */
|
|
147
|
+
toggle_row(row) {
|
|
148
|
+
let check = this.options.selectableRowsCheck || (() => true);
|
|
149
|
+
if(check(row.component)) {
|
|
150
|
+
row.selected = !row.selected;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/* A click on a row: SelectRow toggles it on its own `click`
|
|
154
|
+
* when the table selects rows, then Tabulator says `rowClick`. */
|
|
155
|
+
click_row(index) {
|
|
156
|
+
const row = this.rows[index];
|
|
157
|
+
let selectable_rows = this.options.selectableRows;
|
|
158
|
+
if(selectable_rows === true || typeof selectable_rows === "number") {
|
|
159
|
+
this.toggle_row(row);
|
|
160
|
+
}
|
|
161
|
+
this.emit("rowClick", {
|
|
162
|
+
preventDefault: () => {
|
|
163
|
+
}
|
|
164
|
+
}, row.component);
|
|
165
|
+
}
|
|
131
166
|
getRows() {
|
|
132
167
|
return this.rows.map((row) => row.component);
|
|
133
168
|
}
|
|
@@ -159,8 +194,23 @@ vi.mock("tabulator-tables", () => {
|
|
|
159
194
|
}
|
|
160
195
|
this.settings.rowFormatter(row.component);
|
|
161
196
|
}
|
|
197
|
+
/* A cell editor opened in a row, as a click on a cell does. */
|
|
198
|
+
open_editor(index) {
|
|
199
|
+
this.modules.edit.currentCell = this.rows[index];
|
|
200
|
+
}
|
|
201
|
+
/* What Tabulator 6.6.0 does when it wipes its rows with an
|
|
202
|
+
* editor open: the row that holds it closes it, and the redraw
|
|
203
|
+
* that follows walks the rows already wiped -- it throws when
|
|
204
|
+
* any row came before. */
|
|
205
|
+
wipe_rows() {
|
|
206
|
+
const editing = this.modules.edit.currentCell;
|
|
207
|
+
if(editing && this.rows.indexOf(editing) > 0) {
|
|
208
|
+
throw new TypeError("Cannot read properties of undefined (reading 'add')");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
162
211
|
clearData() {
|
|
163
212
|
this.must_be_built();
|
|
213
|
+
this.wipe_rows();
|
|
164
214
|
for(const row of this.rows) {
|
|
165
215
|
while(row.$row.firstChild) {
|
|
166
216
|
row.$row.removeChild(row.$row.firstChild);
|
|
@@ -178,6 +228,7 @@ vi.mock("tabulator-tables", () => {
|
|
|
178
228
|
setLocale() {
|
|
179
229
|
}
|
|
180
230
|
destroy() {
|
|
231
|
+
this.wipe_rows();
|
|
181
232
|
this.destroyed = true;
|
|
182
233
|
}
|
|
183
234
|
}
|
|
@@ -489,15 +540,33 @@ describe("a table is loaded in one call", () => {
|
|
|
489
540
|
expect(close_asks(form)).toBe(false);
|
|
490
541
|
expect(errors()).toEqual([]);
|
|
491
542
|
});
|
|
543
|
+
|
|
544
|
+
/* Up to 7.26.44 a nested table was built empty and loaded after
|
|
545
|
+
* its build -- laid out twice and redrawn once more, per row: with
|
|
546
|
+
* a nested table per row, most of the time of a load. */
|
|
547
|
+
test("a nested table is BUILT with its rows: no load of its own, no redraw", async () => {
|
|
548
|
+
const host_record = record();
|
|
549
|
+
const {form, first} = build(host_record);
|
|
550
|
+
await settle();
|
|
551
|
+
await new Promise(resolve => setTimeout(resolve, 60));
|
|
552
|
+
const alarms = alarms_of(first);
|
|
553
|
+
const triggers = triggers_of(alarms, 0);
|
|
554
|
+
expect(triggers.rows.map((r) => r.data)).toEqual([{measure: "temperature", value: 30}]);
|
|
555
|
+
expect(triggers.calls.addData).toBe(0);
|
|
556
|
+
expect(triggers.calls.redraw).toBe(0);
|
|
557
|
+
/* A copy: an edit there does not write into the record. */
|
|
558
|
+
triggers.edit_cell(0, "value", 31);
|
|
559
|
+
expect(host_record.alarms[0].triggers[0].value).toBe(30);
|
|
560
|
+
expect(gobj_read_attr(form, "record").alarms[0].triggers[0].value).toBe(30);
|
|
561
|
+
expect(gobj_read_attr(form, "edited")).toBe(true);
|
|
562
|
+
expect(errors()).toEqual([]);
|
|
563
|
+
});
|
|
492
564
|
});
|
|
493
565
|
|
|
494
566
|
describe("a click on a row", () => {
|
|
495
567
|
function click(alarms, index)
|
|
496
568
|
{
|
|
497
|
-
alarms.
|
|
498
|
-
preventDefault: () => {
|
|
499
|
-
}
|
|
500
|
-
}, alarms.rows[index].component);
|
|
569
|
+
alarms.click_row(index);
|
|
501
570
|
}
|
|
502
571
|
|
|
503
572
|
test("does not WRITE the `selectable` attribute, and selects nothing when Tabulator selects no rows", async () => {
|
|
@@ -516,6 +585,8 @@ describe("a click on a row", () => {
|
|
|
516
585
|
const alarms = alarms_of(first);
|
|
517
586
|
click(alarms, 1);
|
|
518
587
|
expect(alarms.rows[1].selected).toBe(true);
|
|
588
|
+
click(alarms, 1);
|
|
589
|
+
expect(alarms.rows[1].selected).toBeFalsy();
|
|
519
590
|
expect(errors()).toEqual([]);
|
|
520
591
|
});
|
|
521
592
|
|
|
@@ -531,3 +602,44 @@ describe("a click on a row", () => {
|
|
|
531
602
|
expect(errors()).toEqual([]);
|
|
532
603
|
});
|
|
533
604
|
});
|
|
605
|
+
|
|
606
|
+
describe("a cell editor open while its table goes", () => {
|
|
607
|
+
function warnings()
|
|
608
|
+
{
|
|
609
|
+
return logged.filter((l) => /warn|error/i.test(l.level) || /WARNING|ERROR/.test(l.msg));
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
test("a reload with an editor open in the second row reloads the rows", async () => {
|
|
613
|
+
const {form, first} = build(record());
|
|
614
|
+
await settle();
|
|
615
|
+
const alarms = alarms_of(first);
|
|
616
|
+
alarms.open_editor(1);
|
|
617
|
+
triggers_of(alarms, 1).open_editor(0);
|
|
618
|
+
gobj_send_event(form, "EV_LOAD_RECORD", {
|
|
619
|
+
template_version: 7,
|
|
620
|
+
alarms: [{name: "cold", triggers: [{measure: "temperature", value: 5}]}]
|
|
621
|
+
}, form);
|
|
622
|
+
await settle();
|
|
623
|
+
expect(shown(alarms)).toEqual([{name: "cold", values: [5]}]);
|
|
624
|
+
expect(warnings()).toEqual([]);
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
test("a destroy with an editor open in a second row destroys every table, silently", async () => {
|
|
628
|
+
const before = live();
|
|
629
|
+
const {form, first} = build({
|
|
630
|
+
template_version: 7,
|
|
631
|
+
alarms: [
|
|
632
|
+
{name: "a", triggers: [{measure: "m", value: 1}, {measure: "n", value: 2}]},
|
|
633
|
+
{name: "b", triggers: [{measure: "m", value: 3}]}
|
|
634
|
+
]
|
|
635
|
+
});
|
|
636
|
+
await settle();
|
|
637
|
+
const alarms = alarms_of(first);
|
|
638
|
+
alarms.open_editor(1);
|
|
639
|
+
triggers_of(alarms, 0).open_editor(1);
|
|
640
|
+
gobj_stop(form);
|
|
641
|
+
gobj_destroy(form);
|
|
642
|
+
expect(live() - before).toBe(0);
|
|
643
|
+
expect(warnings()).toEqual([]);
|
|
644
|
+
});
|
|
645
|
+
});
|
|
@@ -284,13 +284,13 @@ export const I18N_KEY_FUNCTIONS = Object.freeze([
|
|
|
284
284
|
{module: "c_yui_shell.js", name: "build_toolbar", exported: false,
|
|
285
285
|
keys: ["1.toolbar.aria_label", "1.toolbar.items[].name", "1.toolbar.items[].aria_label",
|
|
286
286
|
"1.toolbar.items[].tooltip", "1.toolbar.items[].wordmark", "1.toolbar.items[].id"],
|
|
287
|
-
fallbacks: {"1.toolbar.items[].id": ["1.toolbar.items[].aria_label"]}},
|
|
287
|
+
fallbacks: {"1.toolbar.items[].id": ["1.toolbar.items[].aria_label", "1.toolbar.items[].name"]}},
|
|
288
288
|
{module: "c_yui_shell.js", name: "build_toolbar_action_item", exported: false,
|
|
289
289
|
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"],
|
|
290
290
|
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
291
291
|
{module: "c_yui_shell.js", name: "build_toolbar_brand_item", exported: false,
|
|
292
292
|
keys: ["1.name", "1.aria_label", "1.tooltip", "1.wordmark", "1.id"],
|
|
293
|
-
fallbacks: {"1.id": ["1.aria_label"]}},
|
|
293
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
294
294
|
{module: "c_yui_shell.js", name: "build_toolbar_avatar_item", exported: false,
|
|
295
295
|
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"],
|
|
296
296
|
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|