@yuneta/gobj-ui 7.26.40 → 7.26.42

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 (39) hide show
  1. package/README.md +325 -65
  2. package/dist/gobj-ui.cjs.js +418 -176
  3. package/dist/gobj-ui.es.js +418 -176
  4. package/package.json +1 -1
  5. package/scripts/validate-locales.mjs +644 -142
  6. package/src/c_g6_nodes_tree.js +3 -2
  7. package/src/c_yui_form.js +80 -68
  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_schema_editor.css +16 -0
  13. package/src/c_yui_schema_editor.js +61 -17
  14. package/src/c_yui_shell.js +199 -59
  15. package/src/c_yui_treedb_schema.js +3 -2
  16. package/src/c_yui_window_manager.js +6 -6
  17. package/src/form_table_edits_ask.wiring.test.js +398 -0
  18. package/src/form_table_rearm.wiring.test.js +9 -7
  19. package/src/g6_canvas_tab_order.css +29 -0
  20. package/src/g6_canvas_tab_order.js +41 -9
  21. package/src/g6_canvas_tab_order.wiring.test.js +107 -1
  22. package/src/i18n_key_functions.js +41 -25
  23. package/src/i18n_key_functions.test.js +178 -2
  24. package/src/modal_guard_back.wiring.test.js +135 -0
  25. package/src/named_controls.wiring.test.js +270 -6
  26. package/src/nav_cards_helpers.js +9 -4
  27. package/src/nav_item_badge.wiring.test.js +163 -15
  28. package/src/route_map_model.js +59 -10
  29. package/src/route_map_model.test.js +90 -0
  30. package/src/schema_editor_openers.wiring.test.js +283 -0
  31. package/src/shell_modals.js +24 -4
  32. package/src/shell_route_map.js +15 -3
  33. package/src/shell_section_index.js +3 -1
  34. package/src/window_layer.wiring.test.js +114 -0
  35. package/src/yui_gclass_view.js +16 -1
  36. package/src/yui_tabulator_i18n.js +21 -1
  37. package/src/yui_tabulator_i18n.test.js +39 -0
  38. package/src/yui_text.js +10 -0
  39. package/src/yui_text.test.js +13 -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
+ });
@@ -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
  }
@@ -14,6 +14,12 @@
14
14
  * new Tabulator($el, {..., ...yui_tabulator_lang(t)});
15
15
  * yui_tabulator_relocalize(table, t); // on a language change
16
16
  *
17
+ * A view whose COLUMN TITLES change language hands them too, in the
18
+ * new language, by field -- Tabulator binds each column's title to its
19
+ * locale, so they change with it and no column is rebuilt:
20
+ *
21
+ * yui_tabulator_relocalize(table, t, {device_id: t("device id")});
22
+ *
17
23
  * Every key carries an English `defaultValue`, so an app that does not
18
24
  * define it renders exactly what Tabulator rendered before — the
19
25
  * keys are an OPPORTUNITY to translate, never a requirement.
@@ -236,7 +242,18 @@ function yui_tabulator_name_editor(column_def, name_of)
236
242
  };
237
243
  }
238
244
 
239
- function yui_tabulator_relocalize(table, t)
245
+ /***************************************************************
246
+ * yui_tabulator_relocalize() -- see "Put an EXISTING table in the
247
+ * current language" above.
248
+ *
249
+ * `titles`, optional: {field: title}, the titles of the columns in
250
+ * the new language, already translated. They go in the locale
251
+ * (`columns`), where Tabulator binds each column's title: setLocale()
252
+ * draws them again without rebuilding a column -- updateDefinition()
253
+ * 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.
255
+ ***************************************************************/
256
+ function yui_tabulator_relocalize(table, t, titles)
240
257
  {
241
258
  if(!table) {
242
259
  return;
@@ -244,6 +261,9 @@ function yui_tabulator_relocalize(table, t)
244
261
  try {
245
262
  let name = next_lang_name();
246
263
  let strings = tabulator_strings(t);
264
+ if(titles && typeof titles === "object") {
265
+ strings.columns = Object.assign({}, titles);
266
+ }
247
267
 
248
268
  /* Tabulator DEEP-CLONES options.langs into its localize module when
249
269
  * the table is built, and never looks at the option again: writing a
@@ -15,6 +15,7 @@ import {
15
15
  yui_tabulator_name_filters,
16
16
  yui_tabulator_name_row_selects,
17
17
  yui_tabulator_name_editor,
18
+ yui_tabulator_relocalize,
18
19
  } from "./yui_tabulator_i18n.js";
19
20
 
20
21
  /* An element double: attributes, and the one child a selector finds. */
@@ -125,3 +126,41 @@ describe("yui_tabulator_name_editor", () => {
125
126
  expect(def.editorParams({})).toEqual({a: 1});
126
127
  });
127
128
  });
129
+
130
+ describe("yui_tabulator_relocalize", () => {
131
+ /* A table double: what the localize module is given, and the
132
+ * locale it is set to. */
133
+ function table()
134
+ {
135
+ const installed = {};
136
+ const tb = {
137
+ options: {},
138
+ installed,
139
+ locale: null,
140
+ modules: {localize: {installLang: (name, strings) => {
141
+ installed[name] = strings;
142
+ }}},
143
+ setLocale: (name) => {
144
+ tb.locale = name;
145
+ },
146
+ getColumns: () => [],
147
+ element: element(null),
148
+ };
149
+ return tb;
150
+ }
151
+
152
+ it("hands the column titles to the locale, where Tabulator binds them", () => {
153
+ const tb = table();
154
+ yui_tabulator_relocalize(tb, t, {device_id: "Id dispositivo", value: "Valor"});
155
+ expect(tb.locale).toBeTruthy();
156
+ expect(tb.installed[tb.locale].columns).toEqual(
157
+ {device_id: "Id dispositivo", value: "Valor"});
158
+ expect(tb.installed[tb.locale].pagination).toBeTruthy();
159
+ });
160
+
161
+ it("without titles, the locale carries none, as before", () => {
162
+ const tb = table();
163
+ yui_tabulator_relocalize(tb, t);
164
+ expect(tb.installed[tb.locale].columns).toBe(undefined);
165
+ });
166
+ });
package/src/yui_text.js CHANGED
@@ -36,9 +36,19 @@ export function text_node(value)
36
36
  * Tabulator puts a STRING title in with innerHTML, so a title taken
37
37
  * from a schema (`header`, which the schema editor writes) is markup
38
38
  * unless the column carries a formatter that returns a Node.
39
+ *
40
+ * And it APPENDS that Node to the title's holder, which it never
41
+ * empties -- while it runs the formatter again on every setLocale()
42
+ * (yui_tabulator_relocalize()). Until 7.26.40 each change of language
43
+ * added one more copy of every title ("Id dispositivoId dispositivo").
44
+ * The holder (the mock cell's element) is emptied first.
39
45
  ************************************************************/
40
46
  export function text_title_formatter(cell)
41
47
  {
48
+ const $holder = (typeof cell.getElement === "function")? cell.getElement() : null;
49
+ if($holder) {
50
+ $holder.textContent = "";
51
+ }
42
52
  return text_node(cell.getValue());
43
53
  }
44
54
 
@@ -48,6 +48,19 @@ describe("text_node()", () => {
48
48
  expect($title.textContent).toBe(EVIL);
49
49
  });
50
50
 
51
+ test("a title formatted again (every setLocale) is not appended to the old one", () => {
52
+ /* What Tabulator does: it appends the Node into the title's
53
+ * holder, and on a change of locale runs the formatter again
54
+ * on the same holder. */
55
+ const $holder = document.createElement("div");
56
+ const cell = (title) => ({getValue: () => title, getElement: () => $holder});
57
+ $holder.appendChild(text_title_formatter(cell("Id dispositivo")));
58
+ $holder.appendChild(text_title_formatter(cell("Device id")));
59
+ $holder.appendChild(text_title_formatter(cell("Id dispositivo")));
60
+ expect($holder.textContent).toBe("Id dispositivo");
61
+ expect($holder.childNodes.length).toBe(1);
62
+ });
63
+
51
64
  test("the accordion nav shows a section named by a backend as text", async () => {
52
65
  const i18next = (await import("i18next")).default;
53
66
  await i18next.init({lng: "en", resources: {}});