@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
|
@@ -52,7 +52,7 @@ const {
|
|
|
52
52
|
gobj_start, gobj_read_attr, gobj_is_destroying, gobj_send_event,
|
|
53
53
|
set_log_callback,
|
|
54
54
|
} = await import("@yuneta/gobj-js");
|
|
55
|
-
const {register_c_yui_shell} = await import("./c_yui_shell.js");
|
|
55
|
+
const {register_c_yui_shell, yui_shell_push_escape, yui_shell_pop_escape} = await import("./c_yui_shell.js");
|
|
56
56
|
const {register_c_yui_window} = await import("./c_yui_window.js");
|
|
57
57
|
const {register_c_yui_window_manager} = await import("./c_yui_window_manager.js");
|
|
58
58
|
|
|
@@ -338,6 +338,41 @@ describe("a window the reader did not open", () => {
|
|
|
338
338
|
$of(win).querySelector(".WINDOW_CLOSE").click();
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
|
+
|
|
342
|
+
/* Every overlay that holds the focus (a modal, a dialog, a drawer,
|
|
343
|
+
* a menu) is drawn above the window layer: a window opened under
|
|
344
|
+
* one took the focus where it could not be seen, and the next Tab
|
|
345
|
+
* gave it back to the overlay. */
|
|
346
|
+
test("one opened under a modal leaves the focus in the modal; it is there when the modal goes", () => {
|
|
347
|
+
const $opener = document.createElement("button");
|
|
348
|
+
document.body.appendChild($opener);
|
|
349
|
+
$opener.focus();
|
|
350
|
+
with_activation(true, () => {
|
|
351
|
+
const modal = open_window({modal: true});
|
|
352
|
+
const $field = $of(modal).querySelector(".TEST_FIRST");
|
|
353
|
+
$field.focus();
|
|
354
|
+
const win = open_window();
|
|
355
|
+
expect(document.activeElement === $field, "the focus stays in the modal").toBe(true);
|
|
356
|
+
expect($of(win).parentNode === shell.priv.window_layer ||
|
|
357
|
+
$of(win).parentNode === shell.priv.layers.overlay, "under the modal, in the window layer").toBe(true);
|
|
358
|
+
|
|
359
|
+
$of(modal).querySelector(".WINDOW_CLOSE").click();
|
|
360
|
+
expect(document.activeElement === $opener, "the focus is back on the opener").toBe(true);
|
|
361
|
+
expect(gobj_is_destroying(win)).toBe(false);
|
|
362
|
+
$of(win).querySelector(".WINDOW_CLOSE").click();
|
|
363
|
+
});
|
|
364
|
+
$opener.remove();
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
test("one opened in a modal's own body takes the focus", () => {
|
|
368
|
+
with_activation(true, () => {
|
|
369
|
+
const modal = open_window({modal: true});
|
|
370
|
+
const win = open_window({$parent: $of(modal).querySelector(".TEST_BODY")});
|
|
371
|
+
expect(document.activeElement === $of(win), "the focus is in the window").toBe(true);
|
|
372
|
+
$of(win).querySelector(".WINDOW_CLOSE").click();
|
|
373
|
+
$of(modal).querySelector(".WINDOW_CLOSE").click();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
341
376
|
});
|
|
342
377
|
|
|
343
378
|
describe("Escape", () => {
|
|
@@ -413,6 +448,50 @@ describe("Escape", () => {
|
|
|
413
448
|
});
|
|
414
449
|
});
|
|
415
450
|
|
|
451
|
+
describe("Escape, with an overlay of the shell open", () => {
|
|
452
|
+
/* The window stops the key at its container, so the shell's own
|
|
453
|
+
* Escape (an overlay stack, LIFO, heard on `window`) never saw
|
|
454
|
+
* it: with the focus in the window, an overlay opened AFTER it --
|
|
455
|
+
* the toolbar's user menu -- stayed open, and the window under
|
|
456
|
+
* it closed. */
|
|
457
|
+
test("one opened after the window is closed first; the window is next", () => {
|
|
458
|
+
const win = open_window();
|
|
459
|
+
const $input = $of(win).querySelector(".TEST_FIRST");
|
|
460
|
+
let overlay_open = true;
|
|
461
|
+
const close_overlay = () => {
|
|
462
|
+
overlay_open = false;
|
|
463
|
+
yui_shell_pop_escape(shell, close_overlay);
|
|
464
|
+
};
|
|
465
|
+
yui_shell_push_escape(shell, "popup", close_overlay);
|
|
466
|
+
$input.focus();
|
|
467
|
+
|
|
468
|
+
let ev = press($input, "Escape");
|
|
469
|
+
expect(overlay_open, "the overlay closed").toBe(false);
|
|
470
|
+
expect(gobj_is_destroying(win)).toBe(false);
|
|
471
|
+
expect(ev.defaultPrevented).toBe(true);
|
|
472
|
+
|
|
473
|
+
press($input, "Escape");
|
|
474
|
+
expect(gobj_is_destroying(win)).toBe(true);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test("one opened before the window stays: the window is closed first", () => {
|
|
478
|
+
let overlay_open = true;
|
|
479
|
+
const close_overlay = () => {
|
|
480
|
+
overlay_open = false;
|
|
481
|
+
yui_shell_pop_escape(shell, close_overlay);
|
|
482
|
+
};
|
|
483
|
+
yui_shell_push_escape(shell, "popup", close_overlay);
|
|
484
|
+
const win = open_window();
|
|
485
|
+
const $input = $of(win).querySelector(".TEST_FIRST");
|
|
486
|
+
$input.focus();
|
|
487
|
+
|
|
488
|
+
press($input, "Escape");
|
|
489
|
+
expect(gobj_is_destroying(win)).toBe(true);
|
|
490
|
+
expect(overlay_open, "the overlay is still open").toBe(true);
|
|
491
|
+
close_overlay();
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
|
|
416
495
|
describe("a modal window", () => {
|
|
417
496
|
test("blocks the rest: a backdrop in the dialog layer, aria-modal, no dock", () => {
|
|
418
497
|
const dock = gobj_create_service("dlg_dock", "C_YUI_WINDOW_MANAGER", {}, app);
|
|
@@ -94,6 +94,51 @@ describe("the saved rect of a window is whole pixels", () => {
|
|
|
94
94
|
expect(errors()).toEqual([]);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
+
test("an entry that is not a rect is said, and the window opens where it would", () => {
|
|
98
|
+
window.localStorage.setItem("rect_bad-rect", JSON.stringify({x: 10, y: "20", width: 400}));
|
|
99
|
+
logged.length = 0;
|
|
100
|
+
const win = gobj_create_service("rect_bad", "C_YUI_WINDOW", {
|
|
101
|
+
header: "bad", body: ["div", {}, "bad"], auto_save_size_and_position: true,
|
|
102
|
+
x: 5, y: 6, width: 300, height: 200,
|
|
103
|
+
}, yuno);
|
|
104
|
+
gobj_start(win);
|
|
105
|
+
expect(attrs_rect(win)).toEqual({x: 5, y: 6, width: 300, height: 200});
|
|
106
|
+
const warned = logged.filter((l) => l.level === "warning" && l.msg.includes("rect_bad-rect"));
|
|
107
|
+
expect(warned.length, "the bad entry is said").toBe(1);
|
|
108
|
+
expect(window.localStorage.getItem("rect_bad-rect"), "and forgotten: said once").toBe(null);
|
|
109
|
+
expect(errors()).toEqual([]);
|
|
110
|
+
|
|
111
|
+
/* No entry at all is nothing to say. */
|
|
112
|
+
logged.length = 0;
|
|
113
|
+
const fresh = gobj_create_service("rect_none", "C_YUI_WINDOW", {
|
|
114
|
+
header: "none", body: ["div", {}, "none"], auto_save_size_and_position: true,
|
|
115
|
+
}, yuno);
|
|
116
|
+
gobj_start(fresh);
|
|
117
|
+
expect(logged.filter((l) => l.msg.includes("rect_none-rect"))).toEqual([]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/* A rect with no size -- what the box of a window that is not
|
|
121
|
+
* drawn answers -- is no place to open in: the window was drawn at
|
|
122
|
+
* the CSS minimum while its attrs said 0 x 0, and every open
|
|
123
|
+
* restored it again. It is said, forgotten, and the window opens
|
|
124
|
+
* where it would. (A rect only OFF the screen is kept: the attrs
|
|
125
|
+
* are the DESIRED place, clamped to the viewport on every resize,
|
|
126
|
+
* so a window saved on a larger screen goes back there.) */
|
|
127
|
+
test("an entry with no size is said once, forgotten, and the window opens where it would", () => {
|
|
128
|
+
window.localStorage.setItem("rect_zero-rect", JSON.stringify({x: 0, y: 0, width: 0, height: 0}));
|
|
129
|
+
logged.length = 0;
|
|
130
|
+
const win = gobj_create_service("rect_zero", "C_YUI_WINDOW", {
|
|
131
|
+
header: "zero", body: ["div", {}, "zero"], auto_save_size_and_position: true,
|
|
132
|
+
x: 5, y: 6, width: 300, height: 200,
|
|
133
|
+
}, yuno);
|
|
134
|
+
gobj_start(win);
|
|
135
|
+
expect(attrs_rect(win)).toEqual({x: 5, y: 6, width: 300, height: 200});
|
|
136
|
+
const warned = logged.filter((l) => l.level === "warning" && l.msg.includes("rect_zero-rect"));
|
|
137
|
+
expect(warned.length, "the empty entry is said").toBe(1);
|
|
138
|
+
expect(window.localStorage.getItem("rect_zero-rect")).toBe(null);
|
|
139
|
+
expect(errors()).toEqual([]);
|
|
140
|
+
});
|
|
141
|
+
|
|
97
142
|
test("a move saves whole pixels, and writes them into the attrs", () => {
|
|
98
143
|
const win = gobj_create_service("rect_move", "C_YUI_WINDOW", {
|
|
99
144
|
header: "move", body: ["div", {}, "move"], auto_save_size_and_position: true,
|