@yuneta/gobj-ui 7.26.42 → 7.26.44

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 (47) hide show
  1. package/README.md +227 -36
  2. package/dist/gobj-ui.cjs.js +770 -192
  3. package/dist/gobj-ui.es.js +770 -192
  4. package/package.json +2 -2
  5. package/scripts/validate-locales.mjs +355 -63
  6. package/src/c_yui_form.js +268 -155
  7. package/src/c_yui_node.js +51 -7
  8. package/src/c_yui_schema_editor.js +49 -3
  9. package/src/c_yui_shell.css +4 -1
  10. package/src/c_yui_shell.js +28 -2
  11. package/src/c_yui_window.js +373 -62
  12. package/src/c_yui_window_manager.js +74 -2
  13. package/src/escape_taken.js +58 -0
  14. package/src/form_close_asks_for_edits.wiring.test.js +6 -3
  15. package/src/form_json_editor_names.js +3 -1
  16. package/src/form_json_editor_names.wiring.test.js +8 -4
  17. package/src/form_json_expand.wiring.test.js +6 -3
  18. package/src/form_json_field.wiring.test.js +8 -4
  19. package/src/form_label_i18n.wiring.test.js +10 -5
  20. package/src/form_table_edits_ask.wiring.test.js +18 -8
  21. package/src/form_table_rearm.wiring.test.js +13 -5
  22. package/src/form_table_rows.wiring.test.js +533 -0
  23. package/src/form_table_validator.wiring.test.js +8 -4
  24. package/src/form_template_field.wiring.test.js +6 -3
  25. package/src/g6_long_press_clock.test.js +8 -3
  26. package/src/i18n_key_functions.js +63 -25
  27. package/src/i18n_key_functions.test.js +230 -8
  28. package/src/modal_guard_back.wiring.test.js +53 -0
  29. package/src/named_controls.wiring.test.js +53 -13
  30. package/src/node_nav_events.wiring.test.js +93 -1
  31. package/src/schema_editor_diagram_click.wiring.test.js +277 -0
  32. package/src/shell_dialog_names.wiring.test.js +149 -0
  33. package/src/shell_escape_taken.wiring.test.js +142 -0
  34. package/src/shell_focus_trap.js +30 -2
  35. package/src/shell_focus_trap.test.js +90 -6
  36. package/src/shell_modals.js +90 -19
  37. package/src/table_editor_name.wiring.test.js +10 -5
  38. package/src/treedb_column_title.wiring.test.js +8 -4
  39. package/src/treedb_graph_writes.wiring.test.js +6 -3
  40. package/src/treedb_json_drill.wiring.test.js +6 -3
  41. package/src/uplot_add_serie.test.js +6 -3
  42. package/src/uplot_ink.test.js +8 -4
  43. package/src/window_dialog.wiring.test.js +486 -0
  44. package/src/window_dock_band.wiring.test.js +189 -0
  45. package/src/window_rect_rounding.wiring.test.js +121 -0
  46. package/src/yui_tabulator_i18n.js +31 -1
  47. package/src/yui_tabulator_i18n.test.js +46 -0
package/src/c_yui_node.js CHANGED
@@ -112,6 +112,7 @@ import {
112
112
  gobj_subscribe_event,
113
113
  gobj_unsubscribe_event,
114
114
  gobj_send_event,
115
+ gobj_post_event,
115
116
  gobj_change_state,
116
117
  gobj_current_state,
117
118
  createElement2,
@@ -186,6 +187,7 @@ SDATA_END()
186
187
  let PRIVATE_DATA = {
187
188
  children: null, /* child NODE gobjs, in order */
188
189
  navs: null, /* live C_YUI_NAV gobjs inside my own body */
190
+ retired_navs: null, /* navs a render left, destroyed on the next turn */
189
191
  zone_navs: null, /* navs projected into the SPACE, by key */
190
192
  zone_sig: null, /* their last item signature */
191
193
  content_gobj: null,
@@ -230,6 +232,7 @@ function mt_create(gobj)
230
232
  priv.children = [];
231
233
  priv.remembered = {};
232
234
  priv.navs = [];
235
+ priv.retired_navs = [];
233
236
  priv.zone_navs = {};
234
237
  priv.zone_sig = {};
235
238
 
@@ -309,6 +312,7 @@ function mt_stop(gobj)
309
312
  }
310
313
 
311
314
  deactivate(gobj);
315
+ destroy_retired_navs(gobj);
312
316
 
313
317
  /* Symmetric with mt_start: what this node started, it stops —
314
318
  * the framework destroys children, and destroying a RUNNING gobj
@@ -342,6 +346,7 @@ function mt_destroy(gobj)
342
346
  * references and own nothing but the DOM. */
343
347
  priv.content_gobj = null;
344
348
  priv.navs = [];
349
+ priv.retired_navs = [];
345
350
  priv.zone_navs = {};
346
351
  priv.zone_sig = {};
347
352
  priv.active_child = null;
@@ -613,18 +618,42 @@ function translate_own_dom(gobj, $el)
613
618
  }
614
619
 
615
620
  /************************************************************
616
- * Destroy the C_YUI_NAV gobjs rendering this node's projection.
621
+ * Take down the C_YUI_NAV gobjs rendering this node's projection:
622
+ * off the page now, destroyed on the next turn (EV_DESTROY_NAVS).
623
+ * A render can come from a click on one of them -- the active item
624
+ * clicked again is a navigation to the same hash, done in the same
625
+ * turn -- and that nav is still inside its publication of
626
+ * EV_NAV_CLICKED.
617
627
  ************************************************************/
618
628
  function clear_navs(gobj)
619
629
  {
620
630
  let priv = gobj.priv;
631
+ if(!priv.navs.length) {
632
+ return;
633
+ }
634
+ let none_waiting = (priv.retired_navs.length === 0);
621
635
  for(let nav of priv.navs) {
636
+ let $nav = gobj_read_attr(nav, "$container");
637
+ if($nav && $nav.parentNode) {
638
+ $nav.parentNode.removeChild($nav);
639
+ }
640
+ priv.retired_navs.push(nav);
641
+ }
642
+ priv.navs = [];
643
+ if(none_waiting) {
644
+ gobj_post_event(gobj, "EV_DESTROY_NAVS", {}, gobj);
645
+ }
646
+ }
647
+
648
+ function destroy_retired_navs(gobj)
649
+ {
650
+ let priv = gobj.priv;
651
+ for(let nav of priv.retired_navs.splice(0)) {
622
652
  if(gobj_is_running(nav)) {
623
653
  gobj_stop(nav);
624
654
  }
625
655
  gobj_destroy(nav);
626
656
  }
627
- priv.navs = [];
628
657
  }
629
658
 
630
659
  /************************************************************
@@ -971,7 +1000,8 @@ function render_path(gobj, $where)
971
1000
  "C_YUI_NAV",
972
1001
  {
973
1002
  menu_id: `node.path.${route_of(gobj)}`,
974
- nav_label: gobj_read_attr(gobj, "label") || "",
1003
+ /* As its other navs: a "submenu" heads the nav with it, as a key */
1004
+ nav_label: gobj_read_attr(gobj, "label") || gobj_read_attr(gobj, "node_id"),
975
1005
  menu_items: items,
976
1006
  layout: render.layout,
977
1007
  icon_pos: render.icon_pos || "left",
@@ -1583,6 +1613,15 @@ function ac_set_content(gobj, event, kw, src)
1583
1613
  return 0;
1584
1614
  }
1585
1615
 
1616
+ /************************************************************
1617
+ * The navs a render left on the previous turn (clear_navs()).
1618
+ ************************************************************/
1619
+ function ac_destroy_navs(gobj, event, kw, src)
1620
+ {
1621
+ destroy_retired_navs(gobj);
1622
+ return 0;
1623
+ }
1624
+
1586
1625
  /************************************************************
1587
1626
  * A descendant changed shape; keep bubbling to the root, which
1588
1627
  * owns the site-map contribution.
@@ -1737,7 +1776,8 @@ function create_gclass(gclass_name)
1737
1776
  ["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
1738
1777
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1739
1778
  ["EV_SET_CONTENT", ac_set_content, null],
1740
- ["EV_NODE_TREE_CHANGED", ac_tree_changed, null]
1779
+ ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1780
+ ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1741
1781
  ]],
1742
1782
  ["ST_SELF", [
1743
1783
  ["EV_ROUTE_CHANGED", ac_route_changed, null],
@@ -1752,7 +1792,8 @@ function create_gclass(gclass_name)
1752
1792
  ["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
1753
1793
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1754
1794
  ["EV_SET_CONTENT", ac_set_content, null],
1755
- ["EV_NODE_TREE_CHANGED", ac_tree_changed, null]
1795
+ ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1796
+ ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1756
1797
  ]],
1757
1798
  ["ST_CHILD", [
1758
1799
  ["EV_ROUTE_CHANGED", ac_route_changed, null],
@@ -1767,7 +1808,8 @@ function create_gclass(gclass_name)
1767
1808
  ["EV_SET_CHROME_DEPTH", ac_set_chrome_depth, null],
1768
1809
  ["EV_SET_NAV_MODE", ac_set_nav_mode, null],
1769
1810
  ["EV_SET_CONTENT", ac_set_content, null],
1770
- ["EV_NODE_TREE_CHANGED", ac_tree_changed, null]
1811
+ ["EV_NODE_TREE_CHANGED", ac_tree_changed, null],
1812
+ ["EV_DESTROY_NAVS", ac_destroy_navs, null]
1771
1813
  ]]
1772
1814
  ];
1773
1815
 
@@ -1787,7 +1829,9 @@ function create_gclass(gclass_name)
1787
1829
  ["EV_SET_CHROME_DEPTH", 0],
1788
1830
  ["EV_SET_NAV_MODE", 0],
1789
1831
  ["EV_SET_CONTENT", 0],
1790
- ["EV_NODE_TREE_CHANGED", 0]
1832
+ ["EV_NODE_TREE_CHANGED", 0],
1833
+ /* internal: posted to itself, the navs a render left */
1834
+ ["EV_DESTROY_NAVS", 0]
1791
1835
  ];
1792
1836
 
1793
1837
  __gclass__ = gclass_create(
@@ -102,8 +102,10 @@ import {
102
102
  gobj_start,
103
103
  gobj_stop,
104
104
  gobj_destroy,
105
+ gobj_is_running,
105
106
  gobj_is_destroying,
106
107
  gobj_send_event,
108
+ gobj_post_event,
107
109
  gobj_publish_event,
108
110
  gobj_subscribe_event,
109
111
  gobj_unsubscribe_event,
@@ -259,6 +261,7 @@ let PRIVATE_DATA = {
259
261
 
260
262
  /* Children and overlays */
261
263
  diagram_gobj: null,
264
+ retired_diagrams: null, /* drawings left, destroyed on the next turn */
262
265
  dialog: null,
263
266
  dialog_gen: 0, /* the model_gen the open dialog was built on */
264
267
  dialog_kind: "", /* the logical class of the open dialog */
@@ -317,6 +320,7 @@ function mt_create(gobj)
317
320
  priv.host_drafts = {}; /* what the host says is a draft, {treedb: [topics]} (EV_DRAFTS) */
318
321
  priv.host_ids = {}; /* the same, as {topic id: true} of the model */
319
322
  priv.save_queue = [];
323
+ priv.retired_diagrams = [];
320
324
 
321
325
  build_ui(gobj);
322
326
 
@@ -358,6 +362,7 @@ function mt_stop(gobj)
358
362
  }
359
363
  close_dialog(gobj);
360
364
  destroy_diagram(gobj);
365
+ destroy_retired_diagrams(gobj);
361
366
  }
362
367
 
363
368
  /***************************************************************
@@ -1911,6 +1916,13 @@ function render_diagram(gobj)
1911
1916
  gobj_send_event(diagram, "EV_SHOW", {}, gobj);
1912
1917
  }
1913
1918
 
1919
+ /***************************************************************
1920
+ * The drawing leaves the screen at once and is destroyed on the
1921
+ * next turn (EV_DESTROY_DIAGRAMS). It can be leaving because of
1922
+ * its own node click, which it publishes from inside G6's dispatch
1923
+ * of that click: stopped there, the gobj went from under its own
1924
+ * publication and the G6 graph from under its own event.
1925
+ ***************************************************************/
1914
1926
  function destroy_diagram(gobj)
1915
1927
  {
1916
1928
  let priv = gobj.priv;
@@ -1918,9 +1930,29 @@ function destroy_diagram(gobj)
1918
1930
  if(!priv.diagram_gobj) {
1919
1931
  return;
1920
1932
  }
1921
- gobj_stop(priv.diagram_gobj);
1922
- gobj_destroy(priv.diagram_gobj);
1933
+ let diagram = priv.diagram_gobj;
1923
1934
  priv.diagram_gobj = null;
1935
+
1936
+ let $d = gobj_read_attr(diagram, "$container");
1937
+ if($d && $d.parentNode) {
1938
+ $d.parentNode.removeChild($d);
1939
+ }
1940
+ priv.retired_diagrams.push(diagram);
1941
+ if(priv.retired_diagrams.length === 1) {
1942
+ gobj_post_event(gobj, "EV_DESTROY_DIAGRAMS", {}, gobj);
1943
+ }
1944
+ }
1945
+
1946
+ function destroy_retired_diagrams(gobj)
1947
+ {
1948
+ let priv = gobj.priv;
1949
+
1950
+ for(let diagram of priv.retired_diagrams.splice(0)) {
1951
+ if(gobj_is_running(diagram)) {
1952
+ gobj_stop(diagram);
1953
+ }
1954
+ gobj_destroy(diagram);
1955
+ }
1924
1956
  }
1925
1957
 
1926
1958
 
@@ -3996,6 +4028,15 @@ function ac_node_click(gobj, event, kw, src)
3996
4028
  return reload_after_move(gobj);
3997
4029
  }
3998
4030
 
4031
+ /***************************************************************
4032
+ * The drawings left on the previous turn (destroy_diagram()).
4033
+ ***************************************************************/
4034
+ function ac_destroy_diagrams(gobj, event, kw, src)
4035
+ {
4036
+ destroy_retired_diagrams(gobj);
4037
+ return 0;
4038
+ }
4039
+
3999
4040
  function ac_show_orphans(gobj, event, kw, src)
4000
4041
  {
4001
4042
  if(reload_first(gobj, event)) {
@@ -4778,7 +4819,9 @@ function create_gclass(gclass_name)
4778
4819
  ["EV_REFRESH", ac_refresh, null],
4779
4820
  ["EV_DRAFTS", ac_drafts, null],
4780
4821
  /* The export dialog outlives the screen it was opened from. */
4781
- ["EV_EXPORT_VIEW", ac_export_view, null]
4822
+ ["EV_EXPORT_VIEW", ac_export_view, null],
4823
+ /* Posted to itself: a drawing left on any screen goes a turn later. */
4824
+ ["EV_DESTROY_DIAGRAMS", ac_destroy_diagrams, null]
4782
4825
  ];
4783
4826
 
4784
4827
  /* What a treedb is open for: reading it whole, and writing it
@@ -4905,6 +4948,9 @@ function create_gclass(gclass_name)
4905
4948
  /* From the drawing, which is a child of this gobj. */
4906
4949
  ["EV_NODE_CLICK", 0],
4907
4950
 
4951
+ /* To itself: the drawings left, destroyed a turn later. */
4952
+ ["EV_DESTROY_DIAGRAMS", 0],
4953
+
4908
4954
  /* Outwards. The host mirrors the position into the url and
4909
4955
  * carries the write up to whoever owns the Apply — both are
4910
4956
  * optional, so neither warns when nobody listens. */
@@ -862,9 +862,12 @@ textarea::placeholder {
862
862
  font-weight: 600;
863
863
  }
864
864
  /* Separator between the data half and the translated kind half. CSS,
865
- * not a text node: createElement2 trims text nodes and eats the spaces. */
865
+ * not a text node: createElement2 trims text nodes and eats the spaces.
866
+ * Decorative ("/ ''"): the halves NAME the dialog, and a reader would
867
+ * read the dot into the kind half. */
866
868
  .MODAL_TITLE_PREFIX + .MODAL_TITLE_KIND::before {
867
869
  content: "·";
870
+ content: "·" / "";
868
871
  padding: 0 0.4em;
869
872
  color: var(--bulma-text-weak);
870
873
  font-weight: 400;
@@ -60,6 +60,7 @@ import {
60
60
  import {
61
61
  activate_focus_trap_on,
62
62
  } from "./shell_focus_trap.js";
63
+ import {escape_is_taken} from "./escape_taken.js";
63
64
 
64
65
  import {
65
66
  classify_toolbar_item,
@@ -519,7 +520,10 @@ function mt_start(gobj)
519
520
  /* Global Escape: route to the top handler of the escape stack,
520
521
  * not to a hardcoded "close all drawers". Modals and popups
521
522
  * push themselves on top of drawers, so Escape closes them
522
- * first; second Escape closes the drawer underneath; etc. */
523
+ * first; second Escape closes the drawer underneath; etc.
524
+ * An Escape that what it was typed in took first is not the
525
+ * overlay's (escape_is_taken()): up to 7.26.42 one typed in a
526
+ * table cell being edited closed the whole dialog. */
523
527
  priv.keydown_handler = ev => {
524
528
  if(ev.key !== "Escape" && ev.keyCode !== 27) {
525
529
  return;
@@ -527,6 +531,9 @@ function mt_start(gobj)
527
531
  if(priv.escape_stack.length === 0) {
528
532
  return;
529
533
  }
534
+ if(escape_is_taken(ev)) {
535
+ return;
536
+ }
530
537
  let top = priv.escape_stack[priv.escape_stack.length - 1];
531
538
  ev.preventDefault();
532
539
  ev.stopPropagation();
@@ -2196,6 +2203,10 @@ function refresh_avatars(gobj)
2196
2203
  * Wire an optional secondary (right-click) action on a
2197
2204
  * toolbar item. Same action shape as `action`; used e.g. by
2198
2205
  * the connection indicator to open a dev panel on right-click.
2206
+ * The item goes along whole, with the secondary action in place
2207
+ * of its own: a menu it opens is named as its trigger is (up to
2208
+ * 7.26.42 it went as `{id, action}`, and the menu was named by
2209
+ * the raw id whatever the item declared).
2199
2210
  ************************************************************/
2200
2211
  function attach_context_action(gobj, $item, it)
2201
2212
  {
@@ -2205,7 +2216,7 @@ function attach_context_action(gobj, $item, it)
2205
2216
  $item.addEventListener("contextmenu", ev => {
2206
2217
  ev.preventDefault();
2207
2218
  handle_toolbar_action(
2208
- gobj, {id: it.id, action: it.context_action}, $item
2219
+ gobj, {...it, action: it.context_action}, $item
2209
2220
  );
2210
2221
  });
2211
2222
  }
@@ -4193,6 +4204,20 @@ function yui_shell_window_layer(shell_gobj)
4193
4204
  return priv.window_layer || (priv.layers && priv.layers.overlay) || null;
4194
4205
  }
4195
4206
 
4207
+ /************************************************************
4208
+ * The DOM where a MODAL C_YUI_WINDOW lives when its host names
4209
+ * no `$parent`: the shell's dialog layer, with the dialogs of
4210
+ * shell_modals.js -- above the drawer, the dock and every other
4211
+ * window, below the toasts. Null with no shell.
4212
+ ************************************************************/
4213
+ function yui_shell_modal_layer(shell_gobj)
4214
+ {
4215
+ if(!shell_gobj || !shell_gobj.priv || !shell_gobj.priv.layers) {
4216
+ return null;
4217
+ }
4218
+ return shell_gobj.priv.layers.modal || null;
4219
+ }
4220
+
4196
4221
  /************************************************************
4197
4222
  * Put a window on top of the others: the next number of ONE
4198
4223
  * counter, the same for a window of the dock and for a floating
@@ -4778,6 +4803,7 @@ export {
4778
4803
  yui_shell_of,
4779
4804
  yui_shell_zone,
4780
4805
  yui_shell_window_layer,
4806
+ yui_shell_modal_layer,
4781
4807
  yui_shell_raise_window,
4782
4808
  yui_shell_watch_changes,
4783
4809
  yui_shell_unwatch_changes,