@yuneta/gobj-ui 7.26.41 → 7.26.43

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.
Files changed (66) hide show
  1. package/README.md +510 -78
  2. package/dist/gobj-ui.cjs.js +1120 -326
  3. package/dist/gobj-ui.es.js +1120 -326
  4. package/package.json +1 -1
  5. package/scripts/validate-locales.mjs +971 -177
  6. package/src/c_g6_nodes_tree.js +3 -2
  7. package/src/c_yui_form.js +261 -154
  8. package/src/c_yui_fsm_graph.js +3 -2
  9. package/src/c_yui_gobj_tree_js.js +3 -2
  10. package/src/c_yui_json_graph.js +3 -2
  11. package/src/c_yui_nav.js +43 -28
  12. package/src/c_yui_node.js +51 -7
  13. package/src/c_yui_schema_editor.css +16 -0
  14. package/src/c_yui_schema_editor.js +110 -20
  15. package/src/c_yui_shell.css +4 -1
  16. package/src/c_yui_shell.js +227 -61
  17. package/src/c_yui_treedb_schema.js +3 -2
  18. package/src/c_yui_window.js +373 -62
  19. package/src/c_yui_window_manager.js +80 -8
  20. package/src/escape_taken.js +58 -0
  21. package/src/form_close_asks_for_edits.wiring.test.js +6 -3
  22. package/src/form_json_editor_names.js +3 -1
  23. package/src/form_json_editor_names.wiring.test.js +8 -4
  24. package/src/form_json_expand.wiring.test.js +6 -3
  25. package/src/form_json_field.wiring.test.js +8 -4
  26. package/src/form_label_i18n.wiring.test.js +10 -5
  27. package/src/form_table_edits_ask.wiring.test.js +18 -8
  28. package/src/form_table_rearm.wiring.test.js +13 -5
  29. package/src/form_table_rows.wiring.test.js +489 -0
  30. package/src/form_table_validator.wiring.test.js +8 -4
  31. package/src/form_template_field.wiring.test.js +6 -3
  32. package/src/g6_canvas_tab_order.css +29 -0
  33. package/src/g6_canvas_tab_order.js +41 -9
  34. package/src/g6_canvas_tab_order.wiring.test.js +107 -1
  35. package/src/g6_long_press_clock.test.js +8 -3
  36. package/src/i18n_key_functions.js +81 -27
  37. package/src/i18n_key_functions.test.js +402 -4
  38. package/src/modal_guard_back.wiring.test.js +188 -0
  39. package/src/named_controls.wiring.test.js +323 -19
  40. package/src/nav_cards_helpers.js +9 -4
  41. package/src/nav_item_badge.wiring.test.js +163 -15
  42. package/src/node_nav_events.wiring.test.js +93 -1
  43. package/src/route_map_model.js +59 -10
  44. package/src/route_map_model.test.js +90 -0
  45. package/src/schema_editor_diagram_click.wiring.test.js +277 -0
  46. package/src/schema_editor_openers.wiring.test.js +283 -0
  47. package/src/shell_dialog_names.wiring.test.js +149 -0
  48. package/src/shell_escape_taken.wiring.test.js +142 -0
  49. package/src/shell_focus_trap.js +30 -2
  50. package/src/shell_focus_trap.test.js +90 -6
  51. package/src/shell_modals.js +113 -22
  52. package/src/shell_route_map.js +15 -3
  53. package/src/shell_section_index.js +3 -1
  54. package/src/table_editor_name.wiring.test.js +10 -5
  55. package/src/treedb_column_title.wiring.test.js +8 -4
  56. package/src/treedb_graph_writes.wiring.test.js +6 -3
  57. package/src/treedb_json_drill.wiring.test.js +6 -3
  58. package/src/uplot_add_serie.test.js +6 -3
  59. package/src/uplot_ink.test.js +8 -4
  60. package/src/window_dialog.wiring.test.js +486 -0
  61. package/src/window_dock_band.wiring.test.js +189 -0
  62. package/src/window_layer.wiring.test.js +114 -0
  63. package/src/window_rect_rounding.wiring.test.js +121 -0
  64. package/src/yui_gclass_view.js +16 -1
  65. package/src/yui_tabulator_i18n.js +31 -1
  66. package/src/yui_tabulator_i18n.test.js +46 -0
@@ -15,6 +15,13 @@
15
15
  * developer window of gui_agent, gui_treedb and wattyzer vanished
16
16
  * after a logout and a login. The dock, the same.
17
17
  *
18
+ * The gclass viewer opened from such a window follows it
19
+ * (REV-CLOUD V24.5.6): up to 7.26.41 it was told the element its
20
+ * opener hung from as its `$parent` -- the body, between a logout and
21
+ * the next login -- and stayed there after the login, above the new
22
+ * shell's dialogs. And with two shells alive, destroying the last one
23
+ * gives the windows to the other (it gave them to the body).
24
+ *
18
25
  * Copyright (c) 2026, ArtGins.
19
26
  * All Rights Reserved.
20
27
  ***********************************************************************/
@@ -30,6 +37,18 @@ if(typeof globalThis.matchMedia === "undefined") {
30
37
  globalThis.matchMedia = () => ({matches: false, addEventListener() {}, removeEventListener() {}});
31
38
  }
32
39
 
40
+ /* The gclass viewer watches its container; nothing resizes here. */
41
+ if(typeof globalThis.ResizeObserver === "undefined") {
42
+ globalThis.ResizeObserver = class {
43
+ observe() {
44
+ }
45
+ unobserve() {
46
+ }
47
+ disconnect() {
48
+ }
49
+ };
50
+ }
51
+
33
52
  const {
34
53
  SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr,
35
54
  gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
@@ -40,6 +59,7 @@ const {register_c_yui_shell, yui_shell_window_layer, yui_shell_language_changed}
40
59
  const {register_c_yui_nav} = await import("./c_yui_nav.js");
41
60
  const {register_c_yui_window} = await import("./c_yui_window.js");
42
61
  const {register_c_yui_window_manager} = await import("./c_yui_window_manager.js");
62
+ const {open_gclass_view, close_gclass_view} = await import("./yui_gclass_view.js");
43
63
 
44
64
  const SRC = dirname(fileURLToPath(import.meta.url));
45
65
 
@@ -409,3 +429,97 @@ describe("the title of a dock chip changes language (REV-CLOUD V23, QA of estado
409
429
  logout(shell2);
410
430
  });
411
431
  });
432
+
433
+ describe("REV-CLOUD V24.5.6: a gclass viewer opened from a window goes where its opener goes", () => {
434
+ /* A view inside a window parented to the app: the frontend view in
435
+ * the developer window, whose `gclass` button opens the viewer. */
436
+ function window_with_a_view(name, kw)
437
+ {
438
+ const view = gobj_create(`${name}_view`, "C_TEST_LAYER_VIEW", {}, yuno);
439
+ const win = open_window(name, Object.assign({body: view}, kw || {}));
440
+ return {view, win};
441
+ }
442
+
443
+ test("opened between a logout and the next login: the next shell takes it in with its opener", () => {
444
+ const shell1 = build_shell();
445
+ const {view, win} = window_with_a_view(`gv_dev_${++seq}`);
446
+ logout(shell1);
447
+ expect(lives_in(win, document.body)).toBe(true);
448
+
449
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
450
+ expect(!!(handle && handle.win)).toBe(true);
451
+ expect(lives_in(handle.win, document.body)).toBe(true);
452
+
453
+ /* Login: both in the new shell's window layer, under its
454
+ * dialogs. Up to 7.26.41 the viewer stayed in the body. */
455
+ const shell2 = build_shell();
456
+ expect(lives_in(win, yui_shell_window_layer(shell2))).toBe(true);
457
+ expect(lives_in(handle.win, yui_shell_window_layer(shell2))).toBe(true);
458
+
459
+ close_gclass_view(handle);
460
+ close(win);
461
+ gobj_destroy(view);
462
+ logout(shell2);
463
+ expect(errors()).toEqual([]);
464
+ });
465
+
466
+ test("opened in a shell: beside its opener, and with it through a logout and a login", () => {
467
+ const shell1 = build_shell();
468
+ const {view, win} = window_with_a_view(`gv_in_${++seq}`);
469
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
470
+ expect(lives_in(handle.win, yui_shell_window_layer(shell1))).toBe(true);
471
+
472
+ logout(shell1);
473
+ expect(lives_in(win, document.body)).toBe(true);
474
+ expect(lives_in(handle.win, document.body)).toBe(true);
475
+
476
+ const shell2 = build_shell();
477
+ expect(lives_in(handle.win, yui_shell_window_layer(shell2))).toBe(true);
478
+
479
+ close_gclass_view(handle);
480
+ close(win);
481
+ gobj_destroy(view);
482
+ logout(shell2);
483
+ expect(errors()).toEqual([]);
484
+ });
485
+
486
+ test("opened from a window its host placed in an element of the page: beside it, there for good", () => {
487
+ const shell = build_shell();
488
+ const $mine = document.createElement("div");
489
+ document.body.appendChild($mine);
490
+ const {view, win} = window_with_a_view(`gv_placed_${++seq}`, {$parent: $mine});
491
+
492
+ /* Any other place is another stacking context: the viewer could
493
+ * open BEHIND the window it was opened from. */
494
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
495
+ expect(lives_in(handle.win, $mine)).toBe(true);
496
+ logout(shell);
497
+ const shell2 = build_shell();
498
+ expect(lives_in(handle.win, $mine)).toBe(true);
499
+
500
+ close_gclass_view(handle);
501
+ close(win);
502
+ gobj_destroy(view);
503
+ $mine.remove();
504
+ logout(shell2);
505
+ expect(errors()).toEqual([]);
506
+ });
507
+ });
508
+
509
+ describe("two shells alive: destroying the last one gives the windows to the other", () => {
510
+ test("the windows go to the shell that remains, not to the body", () => {
511
+ const first = build_shell();
512
+ const second = build_shell();
513
+ const w = open_window(`two_shells_${++seq}`);
514
+ expect(lives_in(w, yui_shell_window_layer(second))).toBe(true);
515
+
516
+ logout(second);
517
+ expect(lives_in(w, yui_shell_window_layer(first))).toBe(true);
518
+
519
+ logout(first);
520
+ expect(lives_in(w, document.body)).toBe(true);
521
+
522
+ close(w);
523
+ expect(errors()).toEqual([]);
524
+ });
525
+ });
@@ -0,0 +1,121 @@
1
+ /***********************************************************************
2
+ * window_rect_rounding.wiring.test.js
3
+ *
4
+ * A C_YUI_WINDOW with auto_save_size_and_position keeps its x, y,
5
+ * width and height (DTP_INTEGER) in localStorage. They came from
6
+ * getBoundingClientRect(), which answers fractions of a pixel under
7
+ * a zoom or a device pixel ratio: a fraction was saved, and written
8
+ * back into the integer attrs. They are whole pixels now, when they
9
+ * are saved (a move, a resize) and when they are restored -- an
10
+ * entry saved before with fractions still restores, rounded. (A
11
+ * value is read as its attribute's type, as the C kernel reads it:
12
+ * 2.5 to an integer is refused.)
13
+ *
14
+ * Copyright (c) 2026, ArtGins.
15
+ * All Rights Reserved.
16
+ ***********************************************************************/
17
+ import {describe, test, expect, beforeAll} from "vitest";
18
+ import {install_dom_double} from "../test/dom_double.js";
19
+
20
+ install_dom_double();
21
+
22
+ if(typeof globalThis.matchMedia === "undefined") {
23
+ globalThis.matchMedia = () => ({matches: false, addEventListener() {}, removeEventListener() {}});
24
+ }
25
+
26
+ const {
27
+ SDATA_END, gclass_create,
28
+ gobj_start_up, gobj_create_yuno, gobj_create_service,
29
+ gobj_start, gobj_read_attr,
30
+ set_log_callback,
31
+ } = await import("@yuneta/gobj-js");
32
+ const {register_c_yui_window} = await import("./c_yui_window.js");
33
+
34
+ const logged = [];
35
+ let yuno = null;
36
+
37
+ const FRACTIONS = {x: 10.3, y: 20.7, width: 400.5, height: 300.2};
38
+ const ROUNDED = {x: 10, y: 21, width: 401, height: 300};
39
+
40
+ beforeAll(async () => {
41
+ const i18next = (await import("i18next")).default;
42
+ await i18next.init({lng: "en", resources: {}});
43
+ gobj_start_up(null, null, null, null, null, null, null);
44
+ set_log_callback((level, msg) => {
45
+ logged.push({level: String(level), msg: String(msg)});
46
+ });
47
+ gclass_create("C_TEST_RECT_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
48
+ register_c_yui_window();
49
+ yuno = gobj_create_yuno("rect_yuno", "C_TEST_RECT_HOST", {});
50
+ gobj_start(yuno);
51
+ });
52
+
53
+ function errors()
54
+ {
55
+ return logged.filter((l) => l.level === "error").map((l) => l.msg);
56
+ }
57
+
58
+ function saved(name)
59
+ {
60
+ return JSON.parse(window.localStorage.getItem(`${name}-rect`));
61
+ }
62
+
63
+ function attrs_rect(win)
64
+ {
65
+ return {
66
+ x: gobj_read_attr(win, "x"),
67
+ y: gobj_read_attr(win, "y"),
68
+ width: gobj_read_attr(win, "width"),
69
+ height: gobj_read_attr(win, "height"),
70
+ };
71
+ }
72
+
73
+ function press(win, selector, at, end)
74
+ {
75
+ const $container = gobj_read_attr(win, "$container");
76
+ $container.getBoundingClientRect = () => ({...FRACTIONS});
77
+ const $el = $container.querySelector(selector);
78
+ $el.dispatchEvent({
79
+ type: "pointerdown", target: $el, offsetX: 0, offsetY: 0, ...at,
80
+ stopPropagation() {}, preventDefault() {},
81
+ });
82
+ document.dispatchEvent({type: "pointerup", ...end, stopPropagation() {}, preventDefault() {}});
83
+ }
84
+
85
+ describe("the saved rect of a window is whole pixels", () => {
86
+ test("an entry saved with fractions restores rounded", () => {
87
+ window.localStorage.setItem("rect_old-rect", JSON.stringify({...FRACTIONS}));
88
+ logged.length = 0;
89
+ const win = gobj_create_service("rect_old", "C_YUI_WINDOW", {
90
+ header: "old", body: ["div", {}, "old"], auto_save_size_and_position: true,
91
+ }, yuno);
92
+ gobj_start(win);
93
+ expect(attrs_rect(win)).toEqual(ROUNDED);
94
+ expect(errors()).toEqual([]);
95
+ });
96
+
97
+ test("a move saves whole pixels, and writes them into the attrs", () => {
98
+ const win = gobj_create_service("rect_move", "C_YUI_WINDOW", {
99
+ header: "move", body: ["div", {}, "move"], auto_save_size_and_position: true,
100
+ }, yuno);
101
+ gobj_start(win);
102
+ logged.length = 0;
103
+ press(win, ".WINDOW_HEADER", {screenX: 0, screenY: 0}, {screenX: 5, screenY: 5});
104
+ expect(saved("rect_move")).toEqual(ROUNDED);
105
+ expect(attrs_rect(win)).toEqual(ROUNDED);
106
+ expect(errors()).toEqual([]);
107
+ });
108
+
109
+ test("a resize saves whole pixels, and writes them into the attrs", () => {
110
+ const win = gobj_create_service("rect_resize", "C_YUI_WINDOW", {
111
+ header: "resize", body: ["div", {}, "resize"], auto_save_size_and_position: true,
112
+ showFooter: false, // the resize handle in the body: WINDOW_RESIZE
113
+ }, yuno);
114
+ gobj_start(win);
115
+ logged.length = 0;
116
+ press(win, ".WINDOW_RESIZE", {pageX: 0, pageY: 0}, {pageX: 5, pageY: 5});
117
+ expect(saved("rect_resize")).toEqual(ROUNDED);
118
+ expect(attrs_rect(win)).toEqual(ROUNDED);
119
+ expect(errors()).toEqual([]);
120
+ });
121
+ });
@@ -43,7 +43,7 @@ import {
43
43
  import {describe_local_gclass} from "./gclass_describe.js";
44
44
  import {register_c_yui_gclass} from "./c_yui_gclass.js";
45
45
  import {yui_shell_show_error, yui_shell_show_modal} from "./shell_modals.js";
46
- import {yui_shell_of} from "./c_yui_shell.js";
46
+ import {yui_shell_of, yui_shell_window_layer} from "./c_yui_shell.js";
47
47
 
48
48
  import {t} from "i18next";
49
49
 
@@ -308,6 +308,17 @@ function close_gclass_view(handle)
308
308
  * lands BEHIND its opener whatever number it is given, and
309
309
  * the button reads as one that did nothing.
310
310
  *
311
+ * An opener in the place the shell gives every window -- its
312
+ * window layer, the body while there is none -- gives the
313
+ * viewer no `$parent` at all: the viewer takes that place too,
314
+ * and FOLLOWS the shell with its opener (C_YUI_WINDOW's
315
+ * ac_shell_changed). Up to 7.26.41 it was handed that element
316
+ * by name, and a name is a choice its host made: a viewer
317
+ * opened from the developer window between a logout and the
318
+ * next login was told "the body", and stayed there after the
319
+ * login -- above the new shell's dialogs -- while its opener
320
+ * moved into the shell.
321
+ *
311
322
  * Opened from no window: null -- the window layer of the
312
323
  * shell, where every window lives (the legacy '#top-layer'
313
324
  * when a page has one). It was the shell's popup layer: above
@@ -319,6 +330,10 @@ function window_layer_of(host)
319
330
  if($c && typeof $c.closest === "function") {
320
331
  let $win = $c.closest(".C_YUI_WINDOW");
321
332
  if($win && $win.parentNode) {
333
+ let $shell_place = yui_shell_window_layer(yui_shell_of(host)) || document.body;
334
+ if($win.parentNode === $shell_place) {
335
+ return null;
336
+ }
322
337
  return $win.parentNode;
323
338
  }
324
339
  }
@@ -20,6 +20,10 @@
20
20
  *
21
21
  * yui_tabulator_relocalize(table, t, {device_id: t("device id")});
22
22
  *
23
+ * A column GROUP is bound by field too, and Tabulator gives it none:
24
+ * give it one (`{title, field: "sizes", columns: [...]}`, no row reads
25
+ * it) and its title goes in the same object. One without is said.
26
+ *
23
27
  * Every key carries an English `defaultValue`, so an app that does not
24
28
  * define it renders exactly what Tabulator rendered before — the
25
29
  * keys are an OPPORTUNITY to translate, never a requirement.
@@ -242,6 +246,29 @@ function yui_tabulator_name_editor(column_def, name_of)
242
246
  };
243
247
  }
244
248
 
249
+ /***************************************************************
250
+ * A column GROUP whose title cannot change language, said.
251
+ *
252
+ * Tabulator binds a column's title to the locale by its `field`, and
253
+ * a group has none: its title stays in the language the table was
254
+ * built in. Given a `field` (no row reads a group's), a group is
255
+ * bound like any other column, and its title goes in `titles`.
256
+ ***************************************************************/
257
+ function say_groups_without_field(columns)
258
+ {
259
+ for(let column of columns || []) {
260
+ let def = column.getDefinition() || {};
261
+ if(!Array.isArray(def.columns)) {
262
+ continue;
263
+ }
264
+ if(!def.field) {
265
+ log_warning(`yui_tabulator_relocalize: column group '${def.title}' has no field: ` +
266
+ `its title stays in the language it was built in`);
267
+ }
268
+ say_groups_without_field(column.getSubColumns());
269
+ }
270
+ }
271
+
245
272
  /***************************************************************
246
273
  * yui_tabulator_relocalize() -- see "Put an EXISTING table in the
247
274
  * current language" above.
@@ -251,7 +278,9 @@ function yui_tabulator_name_editor(column_def, name_of)
251
278
  * (`columns`), where Tabulator binds each column's title: setLocale()
252
279
  * draws them again without rebuilding a column -- updateDefinition()
253
280
  * re-renders every row, and a row whose formatter builds something (a
254
- * nested table) builds it anew. A field left out keeps its title.
281
+ * nested table) builds it anew. A field left out keeps its title. A
282
+ * column GROUP is bound only if it has a `field` of its own: one
283
+ * without is said (say_groups_without_field).
255
284
  ***************************************************************/
256
285
  function yui_tabulator_relocalize(table, t, titles)
257
286
  {
@@ -263,6 +292,7 @@ function yui_tabulator_relocalize(table, t, titles)
263
292
  let strings = tabulator_strings(t);
264
293
  if(titles && typeof titles === "object") {
265
294
  strings.columns = Object.assign({}, titles);
295
+ say_groups_without_field(table.getColumns(true));
266
296
  }
267
297
 
268
298
  /* Tabulator DEEP-CLONES options.langs into its localize module when
@@ -10,6 +10,7 @@
10
10
  * All Rights Reserved.
11
11
  ***********************************************************************/
12
12
  import {describe, it, expect} from "vitest";
13
+ import {set_log_callback} from "@yuneta/gobj-js";
13
14
 
14
15
  import {
15
16
  yui_tabulator_name_filters,
@@ -163,4 +164,49 @@ describe("yui_tabulator_relocalize", () => {
163
164
  yui_tabulator_relocalize(tb, t);
164
165
  expect(tb.installed[tb.locale].columns).toBe(undefined);
165
166
  });
167
+
168
+ /* A column double, a group when it has `columns`. */
169
+ function col(def, subs)
170
+ {
171
+ return {
172
+ getDefinition: () => def,
173
+ getSubColumns: () => subs || [],
174
+ };
175
+ }
176
+
177
+ /* Tabulator binds a title to the locale by `field`, and a GROUP has
178
+ * none: its title stayed in the language the table was built in,
179
+ * and nothing said so. A group given a `field` is bound like any
180
+ * other column (checked on Tabulator 6.6 in a browser). */
181
+ it("a column group with no field is said; one with a field is a title like any other", () => {
182
+ const warned = [];
183
+ set_log_callback((level, msg) => {
184
+ if(String(level) === "warning") {
185
+ warned.push(String(msg));
186
+ }
187
+ });
188
+ try {
189
+ const a = col({field: "a", title: "A"});
190
+ const b = col({field: "b", title: "B"});
191
+ const tb = table();
192
+ tb.getColumns = (structured) => structured ?
193
+ [col({field: "x", title: "X"}), col({title: "Sizes", columns: [{}, {}]}, [a, b])] : [];
194
+ yui_tabulator_relocalize(tb, t, {x: "Equis", a: "A es", b: "B es"});
195
+ expect(warned.filter((m) => m.includes("'Sizes'") && m.includes("no field")).length).toBe(1);
196
+
197
+ warned.length = 0;
198
+ const named = table();
199
+ named.getColumns = (structured) => structured ?
200
+ [col({title: "Sizes", field: "sizes", columns: [{}, {}]}, [a, b])] : [];
201
+ yui_tabulator_relocalize(named, t, {sizes: "Tallas", a: "A es", b: "B es"});
202
+ expect(warned).toEqual([]);
203
+ expect(named.installed[named.locale].columns.sizes).toBe("Tallas");
204
+
205
+ /* Without titles nothing is asked of the columns. */
206
+ yui_tabulator_relocalize(tb, t);
207
+ expect(warned).toEqual([]);
208
+ } finally {
209
+ set_log_callback(null);
210
+ }
211
+ });
166
212
  });