@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
@@ -71,6 +71,25 @@ function modal_layer(shell)
71
71
  return priv && priv.layers && priv.layers.modal;
72
72
  }
73
73
 
74
+ /* What each shell has opened in its modal layer, modals and questions
75
+ * alike: a `before_close` that settles with undefined having opened
76
+ * nothing left the reader with a modal that does not close, and only
77
+ * this tells it from a question answered "no" (guarded_close). */
78
+ const __opened_by_shell__ = new WeakMap();
79
+
80
+ function note_opened(shell)
81
+ {
82
+ __opened_by_shell__.set(shell, opened_count(shell) + 1);
83
+ }
84
+
85
+ function opened_count(shell)
86
+ {
87
+ return __opened_by_shell__.get(shell) || 0;
88
+ }
89
+
90
+ /* Unique ids for the nodes a dialog is named and described by. */
91
+ let __dialog_seq__ = 0;
92
+
74
93
  /* Public: where a component should mount its own popup/dialog DOM
75
94
  * (e.g. the treedb edit dialog). The popup layer (z 20) sits below
76
95
  * the modal layer (z 99), so shell confirms always paint above the
@@ -248,8 +267,10 @@ export function yui_shell_show_modal(shell, content, opts)
248
267
  return { close: () => {} };
249
268
  }
250
269
 
270
+ let label_id = `yui-modal-${++__dialog_seq__}`;
251
271
  let inner = (typeof content === "string")
252
- ? ["div", {class: "box"}, [["p", {i18n: content}, content]]]
272
+ ? ["div", {class: "box"}, [["p", {class: "MODAL_MESSAGE", id: `${label_id}-msg`,
273
+ i18n: content}, content]]]
253
274
  : null;
254
275
 
255
276
  /* Adaptive DIALOG mode (`opts.dialog: true`): the standardized
@@ -270,6 +291,29 @@ export function yui_shell_show_modal(shell, content, opts)
270
291
  * nodes and would eat the spaces around it. */
271
292
  let title_prefix = (opts && opts.title_prefix) || "";
272
293
 
294
+ /* The halves of the title NAME the dialog (aria-labelledby), in
295
+ * the dialog's header -- or, with no dialog chrome, in a title
296
+ * only a reader sees: a reader joins them with a space, and the
297
+ * kind half changes language. With no title, a plain message
298
+ * names it; with nothing, it has no name, and that is said. */
299
+ let title_halves = (title_prefix
300
+ ? [["span", {class: "MODAL_TITLE_PREFIX", id: `${label_id}-prefix`},
301
+ text_node(title_prefix)]]
302
+ : []).concat(title
303
+ ? [["span", {class: "MODAL_TITLE_KIND", id: `${label_id}-kind`, i18n: title},
304
+ text_node(title)]]
305
+ : []);
306
+ let label_ids = [];
307
+ if(title_prefix) {
308
+ label_ids.push(`${label_id}-prefix`);
309
+ }
310
+ if(title) {
311
+ label_ids.push(`${label_id}-kind`);
312
+ }
313
+ if(label_ids.length === 0 && inner) {
314
+ label_ids.push(`${label_id}-msg`);
315
+ }
316
+
273
317
  /* The external Bulma `.modal-close is-large` sits at the
274
318
  * top-right of the viewport, outside the content box. Callers
275
319
  * whose content provides its own in-box close (e.g. a
@@ -282,11 +326,7 @@ export function yui_shell_show_modal(shell, content, opts)
282
326
  ["button", {class: "MODAL_BACK yui-dialog-back", type: "button", title: t("back"), "data-i18n-title": "back",
283
327
  "aria-label": t("back"), "data-i18n-aria-label": "back"},
284
328
  [["i", {class: "yi-arrow-left"}]]],
285
- ["span", {class: "MODAL_TITLE yui-dialog-title"},
286
- (title_prefix ? [["span", {class: "MODAL_TITLE_PREFIX"}, text_node(title_prefix)]] : [])
287
- .concat(title
288
- ? [["span", {class: "MODAL_TITLE_KIND", i18n: title}, text_node(title)]]
289
- : [])],
329
+ ["span", {class: "MODAL_TITLE yui-dialog-title"}, title_halves],
290
330
  ["button", {class: "MODAL_CLOSE yui-dialog-x", type: "button", title: t("close"), "data-i18n-title": "close",
291
331
  "aria-label": t("close"), "data-i18n-aria-label": "close"},
292
332
  [["i", {class: "yi-xmark"}]]],
@@ -305,6 +345,9 @@ export function yui_shell_show_modal(shell, content, opts)
305
345
  inner ? [inner] : []
306
346
  ]
307
347
  ];
348
+ if(title_halves.length > 0) {
349
+ modal_children.unshift(["span", {class: "MODAL_TITLE is-sr-only"}, title_halves]);
350
+ }
308
351
  if(with_close) {
309
352
  modal_children.push(
310
353
  ["button", {class: "MODAL_CLOSE modal-close is-large",
@@ -327,15 +370,21 @@ export function yui_shell_show_modal(shell, content, opts)
327
370
  * sheet already, and the media query below still wins. */
328
371
  let wide = !!(opts && opts.wide);
329
372
 
330
- let $modal = createElement2(
331
- ["div", {class: "MODAL" + (logical ? " " + logical : "") +
332
- " modal yui-modal" + (dialog ? " yui-dialog" : "") +
333
- (dialog && wide ? " yui-dialog-wide" : "") + " is-active",
334
- role: "dialog", "aria-modal": "true"},
335
- modal_children
336
- ]
337
- );
373
+ let modal_attrs = {class: "MODAL" + (logical ? " " + logical : "") +
374
+ " modal yui-modal" + (dialog ? " yui-dialog" : "") +
375
+ (dialog && wide ? " yui-dialog-wide" : "") + " is-active",
376
+ role: "dialog", "aria-modal": "true"};
377
+ if(label_ids.length > 0) {
378
+ modal_attrs["aria-labelledby"] = label_ids.join(" ");
379
+ } else {
380
+ log_warning(
381
+ `yui_shell_show_modal: a dialog with no title and no message has no name for a reader` +
382
+ (logical ? ` (${logical})` : "") + `: give it opts.title`
383
+ );
384
+ }
385
+ let $modal = createElement2(["div", modal_attrs, modal_children]);
338
386
  $layer.appendChild($modal);
387
+ note_opened(shell);
339
388
 
340
389
  if(!inner && content && typeof content.appendChild !== "undefined") {
341
390
  let $content = dialog
@@ -396,12 +445,26 @@ export function yui_shell_show_modal(shell, content, opts)
396
445
  * once, over the question's own, and the next Back -- the one meant
397
446
  * for the question -- reached the modal, which asked again: every
398
447
  * Back stacked one more question. Same contract as the `asking`
399
- * close of C_YUI_WINDOW. */
448
+ * close of C_YUI_WINDOW.
449
+ *
450
+ * What the promise SETTLES with is the answer: `true` closes the
451
+ * modal, as a `true` returned at once does; anything else -- what a
452
+ * question that closed the modal itself on "yes" settles with, a
453
+ * `false`, a rejection (said) -- is the veto, and a Back that asked
454
+ * gets its entry back then. Up to 7.26.41 any promise was a veto,
455
+ * so an `async () => true` left a modal nobody could close. A
456
+ * `true` that comes after the modal closed closes nothing twice.
457
+ *
458
+ * An undefined from a guard that opened nothing -- an `async`
459
+ * guard ending in `return;`, which closes when written without
460
+ * `async` -- is the veto too, but nothing on the screen says so:
461
+ * it is said in the log. From a guard that asked, it is its "no". */
400
462
  let guarded_close = function(on_veto) {
401
463
  if(closed) {
402
464
  return;
403
465
  }
404
466
  let allow = true;
467
+ let opened_before = opened_count(shell);
405
468
  if(opts && typeof opts.before_close === "function") {
406
469
  try {
407
470
  allow = opts.before_close();
@@ -411,9 +474,25 @@ export function yui_shell_show_modal(shell, content, opts)
411
474
  }
412
475
  }
413
476
  if(allow && typeof allow.then === "function") {
414
- if(typeof on_veto === "function") {
415
- allow.then(on_veto, on_veto);
416
- }
477
+ let vetoed = function() {
478
+ if(typeof on_veto === "function") {
479
+ on_veto();
480
+ }
481
+ };
482
+ allow.then(function(answer) {
483
+ if(answer === true) {
484
+ do_close();
485
+ return;
486
+ }
487
+ if(answer === undefined && !closed && opened_count(shell) === opened_before) {
488
+ log_warning("yui_shell_show_modal: before_close settled with undefined and " +
489
+ "asked nothing: the modal stays open (only true closes it)");
490
+ }
491
+ vetoed();
492
+ }, function(e) {
493
+ log_warning(`yui_shell_show_modal: before_close rejected: ${e}`);
494
+ vetoed();
495
+ });
417
496
  return;
418
497
  }
419
498
  if(allow === false) {
@@ -543,16 +622,18 @@ function build_dialog(shell, message, buttons, opts)
543
622
  [["i", {class: icon, "aria-hidden": "true"}]]
544
623
  ]
545
624
  ];
625
+ let label_id = `yui-confirm-${++__dialog_seq__}`;
546
626
  if(!empty_string(title)) {
547
627
  $card_children.push(
548
628
  ["p", {class: "CONFIRM_TITLE yui-confirm-title has-text-centered",
549
- i18n: title}, text_node(title)]
629
+ id: `${label_id}-title`, i18n: title}, text_node(title)]
550
630
  );
551
631
  }
552
632
  $card_children.push(
553
633
  ["button", {class: "CONFIRM_CLOSE delete yui-confirm-x", title: t("close"), "data-i18n-title": "close",
554
634
  "aria-label": t("close"), "data-i18n-aria-label": "close"}],
555
- ["section", {class: "CONFIRM_BODY modal-card-body has-text-centered"},
635
+ ["section", {class: "CONFIRM_BODY modal-card-body has-text-centered",
636
+ id: `${label_id}-body`},
556
637
  $body_children],
557
638
  ["footer", {class: "CONFIRM_FOOT modal-card-foot"}, $footer_children]
558
639
  );
@@ -561,9 +642,18 @@ function build_dialog(shell, message, buttons, opts)
561
642
  * yui_shell_show_modal's `logical_class`. */
562
643
  let logical = (opts && opts.logical_class) ? " " + opts.logical_class : "";
563
644
 
645
+ /* Named by its title and described by its message -- or, with no
646
+ * title, named by the message, which is then the whole of it. */
647
+ let confirm_attrs = {class: `CONFIRM${logical} modal yui-modal yui-confirm is-active is-${type}`,
648
+ role: "dialog", "aria-modal": "true"};
649
+ if(!empty_string(title)) {
650
+ confirm_attrs["aria-labelledby"] = `${label_id}-title`;
651
+ confirm_attrs["aria-describedby"] = `${label_id}-body`;
652
+ } else {
653
+ confirm_attrs["aria-labelledby"] = `${label_id}-body`;
654
+ }
564
655
  let $modal = createElement2(
565
- ["div", {class: `CONFIRM${logical} modal yui-modal yui-confirm is-active is-${type}`,
566
- role: "dialog", "aria-modal": "true"},
656
+ ["div", confirm_attrs,
567
657
  [
568
658
  ["div", {class: "CONFIRM_BACKDROP modal-background"}],
569
659
  ["div", {class: "CONFIRM_CARD modal-card"}, $card_children]
@@ -571,6 +661,7 @@ function build_dialog(shell, message, buttons, opts)
571
661
  ]
572
662
  );
573
663
  $layer.appendChild($modal);
664
+ note_opened(shell);
574
665
  maybe_apply_translator($modal, opts);
575
666
 
576
667
  return new Promise(resolve => {
@@ -88,8 +88,16 @@ function render_node(node)
88
88
  row.push(["span", {class: "icon ROUTEMAP_ICON"},
89
89
  [["i", {class: node.icon, "aria-hidden": "true"}]]]);
90
90
  }
91
- row.push(["span", {class: "ROUTEMAP_NAME", i18n: node.label},
92
- text_node(node.label)]);
91
+ /* The name is a KEY -- an item's, as its control is named
92
+ * (route_map_model.js) -- except a label the model marks as DATA:
93
+ * the id of a menu, which declares no name. A node no item names
94
+ * has no name of its own; its route is in its column. */
95
+ if(node.label && node.data_label) {
96
+ row.push(["span", {class: "ROUTEMAP_NAME"}, text_node(node.label)]);
97
+ } else if(node.label) {
98
+ row.push(["span", {class: "ROUTEMAP_NAME", i18n: node.label},
99
+ text_node(node.label)]);
100
+ }
93
101
  /* Documentation columns: route + implementing gclass + action event. */
94
102
  if(node.route) {
95
103
  row.push(["code", {class: "ROUTEMAP_ROUTE"}, text_node(node.route)]);
@@ -131,9 +139,13 @@ function render_node(node)
131
139
  let a_attrs = {class: "ROUTEMAP_LINK ROUTEMAP_ROW" + row_class,
132
140
  href: "#" + node.route,
133
141
  title: node.route};
134
- if(node.label) {
142
+ if(node.label && !node.data_label) {
135
143
  a_attrs["aria-label"] = node.label;
136
144
  a_attrs["data-i18n-aria-label"] = node.label;
145
+ } else {
146
+ /* Data, as it is: a menu's id, or the route of a row that no
147
+ * item names -- no key, so nothing to re-translate. */
148
+ a_attrs["aria-label"] = node.label || node.route;
137
149
  }
138
150
  if(node.current) {
139
151
  a_attrs["aria-current"] = "page";
@@ -55,7 +55,9 @@ export function section_index_target(menu_id, item)
55
55
  gclass: "C_YUI_NAV",
56
56
  kw: {
57
57
  menu_id: `index.${menu_id}.${item.id}`,
58
- nav_label: item.name || item.id || "",
58
+ /* The landing is named by its entry, as the nav names the
59
+ * entry: `name`, else `aria_label`, else id. */
60
+ nav_label: item.name || item.aria_label || item.id || "",
59
61
  menu_items: sub.items,
60
62
  layout: "cards",
61
63
  level: "secondary"
@@ -23,9 +23,12 @@ install_dom_double();
23
23
 
24
24
  if(typeof globalThis.ResizeObserver === "undefined") {
25
25
  globalThis.ResizeObserver = class {
26
- observe() {}
27
- unobserve() {}
28
- disconnect() {}
26
+ observe() {
27
+ }
28
+ unobserve() {
29
+ }
30
+ disconnect() {
31
+ }
29
32
  };
30
33
  }
31
34
 
@@ -70,8 +73,10 @@ vi.mock("vanilla-jsoneditor", () => ({
70
73
  get() {
71
74
  return {text: ""};
72
75
  },
73
- set() {},
74
- destroy() {},
76
+ set() {
77
+ },
78
+ destroy() {
79
+ },
75
80
  }),
76
81
  }));
77
82
 
@@ -30,9 +30,12 @@ install_dom_double();
30
30
 
31
31
  if(typeof globalThis.ResizeObserver === "undefined") {
32
32
  globalThis.ResizeObserver = class {
33
- observe() {}
34
- unobserve() {}
35
- disconnect() {}
33
+ observe() {
34
+ }
35
+ unobserve() {
36
+ }
37
+ disconnect() {
38
+ }
36
39
  };
37
40
  }
38
41
 
@@ -59,7 +62,8 @@ vi.mock("tabulator-tables", () => {
59
62
  off(ev) {
60
63
  delete this.externalEvents.events[ev];
61
64
  }
62
- destroy() {}
65
+ destroy() {
66
+ }
63
67
  }
64
68
  return {TabulatorFull: FakeTabulator, Tabulator: FakeTabulator};
65
69
  });
@@ -26,9 +26,12 @@ install_dom_double();
26
26
  * layout to watch. */
27
27
  if(!globalThis.ResizeObserver) {
28
28
  globalThis.ResizeObserver = class {
29
- observe() {}
30
- unobserve() {}
31
- disconnect() {}
29
+ observe() {
30
+ }
31
+ unobserve() {
32
+ }
33
+ disconnect() {
34
+ }
32
35
  };
33
36
  }
34
37
 
@@ -33,9 +33,12 @@ install_dom_double();
33
33
 
34
34
  if(!globalThis.ResizeObserver) {
35
35
  globalThis.ResizeObserver = class {
36
- observe() {}
37
- unobserve() {}
38
- disconnect() {}
36
+ observe() {
37
+ }
38
+ unobserve() {
39
+ }
40
+ disconnect() {
41
+ }
39
42
  };
40
43
  }
41
44
 
@@ -23,9 +23,12 @@ vi.mock("uplot", () => ({
23
23
  constructor() {
24
24
  this.series = [{}];
25
25
  }
26
- setSize() {}
27
- addSeries() {}
28
- destroy() {}
26
+ setSize() {
27
+ }
28
+ addSeries() {
29
+ }
30
+ destroy() {
31
+ }
29
32
  }
30
33
  }));
31
34
 
@@ -25,10 +25,14 @@ vi.mock("uplot", () => ({
25
25
  given = opts;
26
26
  this.series = [{}];
27
27
  }
28
- setSize() {}
29
- addSeries() {}
30
- redraw() {}
31
- destroy() {}
28
+ setSize() {
29
+ }
30
+ addSeries() {
31
+ }
32
+ redraw() {
33
+ }
34
+ destroy() {
35
+ }
32
36
  }
33
37
  }));
34
38