@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.
@@ -1,4 +1,4 @@
1
- import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, delete_from_list, duplicate_objects, empty_json, empty_string, escapeHtml, event_flag_t, flat_diff, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_get_gclass_trace_level2, gobj_global_trace_level, gobj_global_trace_no_level, gobj_has_event, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, html_markup, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json2flat, json_deep_copy, json_is_identical, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_level_t, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
1
+ import { SDATA, SDATA_END, clean_name, createElement2, createOneHtml, create_template_record, data_type_t, debounce, delete_from_list, duplicate_objects, empty_json, empty_string, escapeHtml, event_flag_t, flat_diff, gclass_create, gclass_find_by_name, gclass_flag_t, getPositionRelativeToBody, gobj_bottom_gobj, gobj_change_state, gobj_command, gobj_create, gobj_create_pure_child, gobj_create_service, gobj_current_state, gobj_destroy, gobj_find_child, gobj_find_service, gobj_full_name, gobj_gclass_name, gobj_get_gclass_trace_level2, gobj_global_trace_level, gobj_global_trace_no_level, gobj_has_event, gobj_is_destroying, gobj_is_playing, gobj_is_pure_child, gobj_is_running, gobj_is_service, gobj_is_volatil, gobj_match_children, gobj_name, gobj_parent, gobj_post_event, gobj_publish_event, gobj_read_attr, gobj_read_bool_attr, gobj_read_integer_attr, gobj_read_pointer_attr, gobj_read_str_attr, gobj_save_persistent_attrs, gobj_send_event, gobj_set_trace_machine_format, gobj_short_name, gobj_start, gobj_start_tree, gobj_stop, gobj_stop_children, gobj_subscribe_event, gobj_unsubscribe_event, gobj_write_attr, gobj_write_bool_attr, gobj_write_integer_attr, gobj_write_str_attr, gobj_yuno, gobj_yuno_name, html_markup, is_array, is_boolean, is_date, is_gobj, is_null, is_number, is_object, is_string, json2flat, json_deep_copy, json_is_identical, json_object_size, json_object_update, json_object_update_missing, json_size, kw_clone_by_keys, kw_flag_t, kw_get_dict, kw_get_dict_value, kw_get_int, kw_get_local_storage_value, kw_get_str, kw_has_key, kw_remove_local_storage_value, kw_set_dict_value, kw_set_local_storage_value, kwid_find_one_record, kwid_new_dict, log_error, log_warning, msg_iev_get_stack, parseBoolean, parseSVG, refresh_language, safeSrc, sdata_flag_t, set_console_log_enabled, set_log_callback, sprintf, str_in_list, template_get_field_desc, trace_level_t, trace_msg, treedb_decoder_fkey, treedb_encoder_fkey, treedb_get_field_desc, treedb_hook_data_size } from "@yuneta/gobj-js";
2
2
  import i18next, { t } from "i18next";
3
3
  import TomSelect from "tom-select";
4
4
  import { createJSONEditor } from "vanilla-jsoneditor";
@@ -134,7 +134,14 @@ function yui_tint(colour) {
134
134
  * that wrapped to it, did nothing and was prevented -- the
135
135
  * keyboard never got into the dialog.
136
136
  *
137
- * Pure module — no gobj / Yuneta dependencies. The optional
137
+ * A trap whose panel left the document without being released
138
+ * (its owner was torn down with it) is dropped, with its
139
+ * listener, the next time the stack is read, and said. Up to
140
+ * gobj-ui 7.26.45 it stayed the top: every window opened later
141
+ * believed itself under an overlay and took no focus, and a
142
+ * live trap under it no longer heard Tab.
143
+ *
144
+ * No gobj dependency: only gobj-js's logger. The optional
138
145
  * second argument lets callers inject a mock document object
139
146
  * for unit tests.
140
147
  *
@@ -143,6 +150,15 @@ function yui_tint(colour) {
143
150
  ***********************************************************************/
144
151
  var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
145
152
  var __trap_stack__ = [];
153
+ function drop_detached_traps() {
154
+ for (let i = __trap_stack__.length - 1; i >= 0; i--) {
155
+ let trap = __trap_stack__[i];
156
+ if (trap.$panel.isConnected !== false) continue;
157
+ __trap_stack__.splice(i, 1);
158
+ trap.detach();
159
+ log_warning("focus trap: its panel left the document without releasing it; dropped (the overlay's owner was torn down with it open)");
160
+ }
161
+ }
146
162
  function is_drawn(el) {
147
163
  if (typeof el.checkVisibility === "function") return el.checkVisibility();
148
164
  if (typeof el.getClientRects === "function") return el.getClientRects().length > 0;
@@ -167,6 +183,7 @@ function activate_focus_trap_on($panel, doc) {
167
183
  let released = false;
168
184
  let trap = function(ev) {
169
185
  if (ev.key !== "Tab" && ev.keyCode !== 9) return;
186
+ drop_detached_traps();
170
187
  if (__trap_stack__[__trap_stack__.length - 1] !== trap) return;
171
188
  let nodes = focusables_of($panel);
172
189
  if (nodes.length === 0) return;
@@ -183,6 +200,10 @@ function activate_focus_trap_on($panel, doc) {
183
200
  ev.preventDefault();
184
201
  }
185
202
  };
203
+ trap.$panel = $panel;
204
+ trap.detach = function() {
205
+ doc.removeEventListener("keydown", trap, true);
206
+ };
186
207
  doc.addEventListener("keydown", trap, true);
187
208
  __trap_stack__.push(trap);
188
209
  let firstFocusable = focusables_of($panel)[0];
@@ -196,6 +217,18 @@ function activate_focus_trap_on($panel, doc) {
196
217
  if (saved && typeof saved.focus === "function" && (!doc.body || !doc.body.contains || doc.body.contains(saved))) saved.focus();
197
218
  };
198
219
  }
220
+ /***************************************************************
221
+ * The panel of the trap that holds the focus now (the top of the
222
+ * stack), or null when none is up. What holds one -- a modal, a
223
+ * dialog, a drawer, a menu -- is drawn above every window that is
224
+ * not modal: such a window that took the focus would take it
225
+ * where it cannot be seen, and the next Tab would give it back.
226
+ ***************************************************************/
227
+ function focus_trap_panel() {
228
+ drop_detached_traps();
229
+ let top = __trap_stack__[__trap_stack__.length - 1];
230
+ return top ? top.$panel : null;
231
+ }
199
232
  //#endregion
200
233
  //#region src/shell_show_on.js
201
234
  /***********************************************************************
@@ -1233,6 +1266,7 @@ var PRIVATE_DATA$22 = {
1233
1266
  hash_handler: null,
1234
1267
  keydown_handler: null,
1235
1268
  escape_stack: [],
1269
+ escape_seq: 0,
1236
1270
  overlay_stack: [],
1237
1271
  expected_pops: 0,
1238
1272
  expected_pop_hash: "",
@@ -1374,7 +1408,10 @@ function mt_start$21(gobj) {
1374
1408
  priv.keydown_handler = (ev) => {
1375
1409
  if (ev.key !== "Escape" && ev.keyCode !== 27) return;
1376
1410
  if (priv.escape_stack.length === 0) return;
1377
- if (escape_is_taken(ev)) return;
1411
+ if (escape_is_taken(ev)) {
1412
+ take_back_focus(ev);
1413
+ return;
1414
+ }
1378
1415
  let top = priv.escape_stack[priv.escape_stack.length - 1];
1379
1416
  ev.preventDefault();
1380
1417
  ev.stopPropagation();
@@ -1395,6 +1432,7 @@ function mt_start$21(gobj) {
1395
1432
  function mt_stop$20(gobj) {
1396
1433
  let priv = gobj.priv;
1397
1434
  if (!priv) return 0;
1435
+ close_overlays(gobj);
1398
1436
  close_toolbar_dropdown(gobj);
1399
1437
  if (priv.hash_handler) {
1400
1438
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -1449,6 +1487,7 @@ function mt_stop$20(gobj) {
1449
1487
  * Framework Method: Destroy
1450
1488
  ***************************************************************/
1451
1489
  function mt_destroy$22(gobj) {
1490
+ close_overlays(gobj);
1452
1491
  close_toolbar_dropdown(gobj);
1453
1492
  let live_idx = __live_shells__.indexOf(gobj);
1454
1493
  if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
@@ -2549,7 +2588,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger) {
2549
2588
  $panel.__yui_backdrop_handler__ = backdrop;
2550
2589
  $panel.__yui_dismiss_handler__ = dismiss;
2551
2590
  $panel.__yui_trigger__ = $trigger || null;
2552
- push_escape(gobj, "popup", close_fn);
2591
+ push_escape(gobj, "popup", close_fn, close_fn);
2553
2592
  $panel.__yui_focus_release__ = activate_focus_trap_on($panel);
2554
2593
  if ($trigger) $trigger.setAttribute("aria-expanded", "true");
2555
2594
  priv.active_dropdown = $panel;
@@ -2694,23 +2733,69 @@ function drawers(gobj, menu_id) {
2694
2733
  return out;
2695
2734
  }
2696
2735
  /************************************************************
2736
+ * An Escape that closed an inline editor (a table cell) took the
2737
+ * focus with it, to <body>: the overlay that holds the focus (the
2738
+ * top trap: a dialog, a drawer) takes it back, as a window does --
2739
+ * a reader was left on the page, outside the dialog it was in.
2740
+ ************************************************************/
2741
+ function take_back_focus(ev) {
2742
+ if (!ev.target || ev.target.isConnected !== false) return;
2743
+ let active = document.activeElement;
2744
+ if (active && active !== document.body) return;
2745
+ let $panel = focus_trap_panel();
2746
+ if (!$panel || $panel.isConnected === false) return;
2747
+ if (!$panel.hasAttribute("tabindex")) $panel.setAttribute("tabindex", "-1");
2748
+ $panel.focus();
2749
+ }
2750
+ /************************************************************
2697
2751
  * Escape priority chain helpers — push/pop a {layer, handler}
2698
2752
  * record on `priv.escape_stack`. Escape calls the top entry
2699
2753
  * only and consumes the event; LIFO ordering naturally matches
2700
2754
  * the z-index layering most apps use (drawer at the bottom,
2701
2755
  * modal on top, popup on top of that).
2756
+ *
2757
+ * `teardown` is the overlay's UNCONDITIONAL close, what the shell
2758
+ * runs when it stops with the overlay still up (close_overlays);
2759
+ * `handler` may be a guarded one (a modal's before_close).
2702
2760
  ************************************************************/
2703
- function push_escape(gobj, layer, handler) {
2761
+ function push_escape(gobj, layer, handler, teardown) {
2704
2762
  let priv = gobj.priv;
2705
2763
  if (!priv || !priv.escape_stack) {
2706
2764
  log_warning(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
2707
2765
  return;
2708
2766
  }
2767
+ priv.escape_seq += 1;
2709
2768
  priv.escape_stack.push({
2710
2769
  layer,
2711
- handler
2770
+ handler,
2771
+ teardown: typeof teardown === "function" ? teardown : null,
2772
+ seq: priv.escape_seq
2712
2773
  });
2713
2774
  }
2775
+ /************************************************************
2776
+ * Close every overlay still up, the top first, as if each had
2777
+ * been dismissed: a shell that stops -- a logout, a session cut
2778
+ * -- with a drawer, a modal or a question open. Up to gobj-ui
2779
+ * 7.26.45 only the toolbar dropdown was closed: the others kept
2780
+ * their focus trap, and every window opened afterwards believed
2781
+ * itself under an overlay and took no focus; a question never
2782
+ * answered. Run before the views stop, so what an overlay's
2783
+ * on_close calls is still alive. An overlay pushed with no
2784
+ * teardown is left to its owner.
2785
+ ************************************************************/
2786
+ function close_overlays(gobj) {
2787
+ let priv = gobj.priv;
2788
+ if (!priv || !priv.escape_stack) return;
2789
+ let entries = priv.escape_stack.slice().reverse();
2790
+ for (let entry of entries) {
2791
+ if (!entry.teardown) continue;
2792
+ try {
2793
+ entry.teardown();
2794
+ } catch (e) {
2795
+ log_warning(`C_YUI_SHELL: closing the '${entry.layer}' overlay at stop failed: ${e}`);
2796
+ }
2797
+ }
2798
+ }
2714
2799
  function pop_escape(gobj, handler) {
2715
2800
  let priv = gobj.priv;
2716
2801
  if (!priv || !priv.escape_stack) return;
@@ -2920,7 +3005,7 @@ function open_drawer_one(gobj, $c) {
2920
3005
  if ($c.classList.contains("is-active")) return;
2921
3006
  let close_fn = () => close_drawer_one(gobj, $c);
2922
3007
  $c.__yui_close_handler__ = close_fn;
2923
- push_escape(gobj, "overlay", close_fn);
3008
+ push_escape(gobj, "overlay", close_fn, close_fn);
2924
3009
  $c.classList.add("is-active");
2925
3010
  $c.__yui_focus_release__ = activate_focus_trap_on($c.querySelector(".yui-drawer-panel") || $c);
2926
3011
  }
@@ -3622,12 +3707,17 @@ function yui_shell_close_drawer(shell_gobj, menu_id) {
3622
3707
  function yui_shell_toggle_drawer(shell_gobj, menu_id) {
3623
3708
  toggle_drawer(shell_gobj, menu_id);
3624
3709
  }
3625
- function yui_shell_push_escape(shell_gobj, layer, handler) {
3626
- push_escape(shell_gobj, layer, handler);
3710
+ function yui_shell_push_escape(shell_gobj, layer, handler, teardown) {
3711
+ push_escape(shell_gobj, layer, handler, teardown);
3627
3712
  }
3628
3713
  function yui_shell_pop_escape(shell_gobj, handler) {
3629
3714
  pop_escape(shell_gobj, handler);
3630
3715
  }
3716
+ function yui_shell_escape_order(shell_gobj) {
3717
+ let priv = shell_gobj && shell_gobj.priv;
3718
+ if (!priv || !priv.escape_stack || priv.escape_stack.length === 0) return 0;
3719
+ return priv.escape_stack[priv.escape_stack.length - 1].seq;
3720
+ }
3631
3721
  function yui_shell_register_overlay(shell_gobj, close_fn, opts) {
3632
3722
  return push_overlay_history(shell_gobj, close_fn, opts);
3633
3723
  }
@@ -4227,7 +4317,7 @@ function yui_shell_show_modal(shell, content, opts) {
4227
4317
  });
4228
4318
  };
4229
4319
  escape_handler = request_close;
4230
- yui_shell_push_escape(shell, "modal", request_close);
4320
+ yui_shell_push_escape(shell, "modal", request_close, do_close);
4231
4321
  overlay = yui_shell_register_overlay(shell, on_back);
4232
4322
  release_focus = activate_focus_trap_on($modal);
4233
4323
  if (opts == null || opts.dismiss_on_background !== false) $modal.querySelector(".modal-background").addEventListener("click", request_close);
@@ -4382,7 +4472,7 @@ function build_dialog(shell, message, buttons, opts) {
4382
4472
  resolve(value);
4383
4473
  };
4384
4474
  close_fn = () => close(dismiss_value);
4385
- yui_shell_push_escape(shell, "modal", close_fn);
4475
+ yui_shell_push_escape(shell, "modal", close_fn, close_fn);
4386
4476
  overlay = yui_shell_register_overlay(shell, close_fn);
4387
4477
  release_focus = activate_focus_trap_on($modal.querySelector(".modal-card"));
4388
4478
  $modal.querySelector(".modal-background").addEventListener("click", () => close(dismiss_value));
@@ -4581,7 +4671,8 @@ var PRIVATE_DATA$21 = {
4581
4671
  back_shell: null,
4582
4672
  opener: null,
4583
4673
  $lock: null,
4584
- release_focus: null
4674
+ release_focus: null,
4675
+ escape_order: 0
4585
4676
  };
4586
4677
  var __gclass__$21 = null;
4587
4678
  /******************************
@@ -4646,6 +4737,12 @@ function mt_create$21(gobj) {
4646
4737
  * the first Tab of a keyboard reader landed in a window they had
4647
4738
  * not opened. A modal window takes it all the same: nothing else
4648
4739
  * can be used while it is up.
4740
+ *
4741
+ * Nor does one opened under an overlay that holds the focus (a
4742
+ * modal window, a dialog, a drawer, a menu: all are drawn above
4743
+ * the window layer). Up to gobj-ui 7.26.44 it took the focus where
4744
+ * it could not be seen, and the next Tab gave it back to the
4745
+ * overlay; it opens under it now, and is there when it goes.
4649
4746
  ***************************************************************/
4650
4747
  function mt_start$20(gobj) {
4651
4748
  let priv = gobj.priv;
@@ -4656,9 +4753,12 @@ function mt_start$20(gobj) {
4656
4753
  }
4657
4754
  let active = document.activeElement;
4658
4755
  if (active && active !== document.body && !$container.contains(active)) priv.opener = active;
4756
+ priv.escape_order = yui_shell_escape_order(yui_shell_of(gobj));
4659
4757
  let modal = gobj_read_bool_attr(gobj, "modal");
4758
+ let $trap = focus_trap_panel();
4759
+ let under_an_overlay = !!$trap && !$trap.contains($container);
4660
4760
  if (modal && !priv.release_focus) priv.release_focus = activate_focus_trap_on($container);
4661
- if (modal || opened_by_the_reader()) focus_target(gobj, $container).focus();
4761
+ if (modal || opened_by_the_reader() && !under_an_overlay) focus_target(gobj, $container).focus();
4662
4762
  }
4663
4763
  /***************************************************************
4664
4764
  * Framework Method: Destroy
@@ -4912,8 +5012,9 @@ function window_root(gobj) {
4912
5012
  /************************************************************
4913
5013
  * An Escape typed in the window. The callback only decides
4914
5014
  * whether the key is the window's -- not when `keyboard` is
4915
- * off, nor one that what it was typed in took -- and sends
4916
- * the event: the close is the ✕'s, in the action.
5015
+ * off, nor one that what it was typed in took, nor while an
5016
+ * overlay of the shell opened after the window is up -- and
5017
+ * sends the event: the close is the ✕'s, in the action.
4917
5018
  ************************************************************/
4918
5019
  function on_escape_key(gobj, evt) {
4919
5020
  if (evt.key !== "Escape" && evt.keyCode !== 27) return;
@@ -4924,6 +5025,7 @@ function on_escape_key(gobj, evt) {
4924
5025
  if (evt.target && evt.target.isConnected === false && $container && (!active || active === document.body)) $container.focus();
4925
5026
  return;
4926
5027
  }
5028
+ if (yui_shell_escape_order(yui_shell_of(gobj)) > gobj.priv.escape_order) return;
4927
5029
  evt.preventDefault();
4928
5030
  evt.stopPropagation();
4929
5031
  gobj_send_event(gobj, "EV_CLOSE_WINDOW", { key: "Escape" }, gobj);
@@ -4981,7 +5083,17 @@ function build_ui$18(gobj) {
4981
5083
  if (is_gobj(footer)) footer = gobj_read_attr(footer, "$container");
4982
5084
  if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
4983
5085
  if (gobj_is_service(gobj)) {
4984
- let rect = whole_rect(kw_get_local_storage_value(`${gobj_name(gobj)}-rect`));
5086
+ let key = `${gobj_name(gobj)}-rect`;
5087
+ let stored = kw_get_local_storage_value(key);
5088
+ let rect = whole_rect(stored);
5089
+ if (!rect && stored != null) {
5090
+ log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
5091
+ kw_remove_local_storage_value(key);
5092
+ } else if (rect && (rect.width <= 0 || rect.height <= 0)) {
5093
+ log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' has no size (${rect.width} x ${rect.height}): ignored`);
5094
+ kw_remove_local_storage_value(key);
5095
+ rect = null;
5096
+ }
4985
5097
  if (rect) {
4986
5098
  rect.x = rect.x < 0 ? 0 : rect.x;
4987
5099
  rect.y = rect.y < 0 ? 0 : rect.y;
@@ -5683,6 +5795,7 @@ function ac_shell_changed$1(gobj, event, kw, src) {
5683
5795
  gobj_write_attr(gobj, "back_overlay", null);
5684
5796
  priv.back_shell = null;
5685
5797
  }
5798
+ priv.escape_order = going ? 0 : yui_shell_escape_order(src);
5686
5799
  let $container = gobj_read_attr(gobj, "$container");
5687
5800
  if (!$container) {
5688
5801
  log_error(`${gobj_short_name(gobj)}: EV_SHELL_CHANGED without a container`);
@@ -9619,6 +9732,117 @@ function datetime_local_to_epoch(value) {
9619
9732
  return Math.floor(date.getTime() / 1e3);
9620
9733
  }
9621
9734
  //#endregion
9735
+ //#region src/form_time_cell_editor.js
9736
+ /****************************************************************************
9737
+ * form_time_cell_editor.js
9738
+ *
9739
+ * The cell editor of a `time` / `now` column in a table of
9740
+ * C_YUI_FORM: a `datetime-local` box, as the form's own time
9741
+ * field, converting with the same helpers (form_time_value.js)
9742
+ * -- an epoch in SECONDS for an integer column, an ISO text
9743
+ * for a string one -- and to the second (`step` 1).
9744
+ *
9745
+ * Up to gobj-ui 7.26.45 the column used Tabulator's `datetime`
9746
+ * editor with a `format`, which needs luxon, and nothing gives
9747
+ * gobj-ui luxon: the editor said "'date' editor 'format' param
9748
+ * is dependant on luxon.js" in the console, opened empty, and
9749
+ * threw when it was committed. Its format ("dd/MM/yyyy hh:mm",
9750
+ * 12-hour) could not have read an epoch either. Luxon is not
9751
+ * taken in for it: one editor is not worth a dependency every
9752
+ * app would have to dedupe, and the conversion it needs is the
9753
+ * one the form already makes.
9754
+ *
9755
+ * It behaves as Tabulator's own: `elementAttributes` are
9756
+ * written on the box (the column's name, see
9757
+ * yui_tabulator_name_editor), a true blur or Enter commits,
9758
+ * Escape cancels, `verticalNavigation: "editor"` keeps the
9759
+ * arrows, and a value that did not change is a cancel.
9760
+ *
9761
+ * Copyright (c) 2026, ArtGins.
9762
+ * All Rights Reserved.
9763
+ ****************************************************************************/
9764
+ /************************************************************
9765
+ * A cell's value -> the text of the box ("" when empty).
9766
+ ************************************************************/
9767
+ function time_to_datetime_local(value, real_type) {
9768
+ if (value === null || value === void 0 || value === "") return "";
9769
+ if (real_type === "string") return date_to_datetime_local(new Date(String(value)));
9770
+ let seconds = Number(value);
9771
+ if (!Number.isFinite(seconds)) return "";
9772
+ return date_to_datetime_local(/* @__PURE__ */ new Date(seconds * 1e3));
9773
+ }
9774
+ /************************************************************
9775
+ * The text of the box -> the cell's value (null when empty).
9776
+ ************************************************************/
9777
+ function datetime_local_to_time(text, real_type) {
9778
+ let epoch = datetime_local_to_epoch(text);
9779
+ if (epoch === null) return null;
9780
+ if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
9781
+ return epoch;
9782
+ }
9783
+ /************************************************************
9784
+ * The editor of a time column whose values are `real_type`
9785
+ * ("integer": epoch seconds; "string": ISO text).
9786
+ ************************************************************/
9787
+ function form_time_cell_editor(real_type) {
9788
+ return function(cell, onRendered, success, cancel, editorParams) {
9789
+ let params = editorParams || {};
9790
+ let vertical = params.verticalNavigation || "editor";
9791
+ let original = cell.getValue();
9792
+ let original_text = time_to_datetime_local(original, real_type);
9793
+ let input = document.createElement("input");
9794
+ input.type = "datetime-local";
9795
+ input.setAttribute("step", "1");
9796
+ input.style.padding = "4px";
9797
+ input.style.width = "100%";
9798
+ input.style.boxSizing = "border-box";
9799
+ let attrs = params.elementAttributes;
9800
+ if (attrs && typeof attrs === "object") for (let key of Object.keys(attrs)) input.setAttribute(key, attrs[key]);
9801
+ input.value = original_text;
9802
+ onRendered(function() {
9803
+ if (cell.getType() === "cell") {
9804
+ input.focus({ preventScroll: true });
9805
+ input.style.height = "100%";
9806
+ }
9807
+ });
9808
+ let commit = function() {
9809
+ if (input.value === original_text) {
9810
+ cancel();
9811
+ return;
9812
+ }
9813
+ let value = datetime_local_to_time(input.value, real_type);
9814
+ if (value === original || value === null && original_text === "") {
9815
+ cancel();
9816
+ return;
9817
+ }
9818
+ success(value);
9819
+ };
9820
+ input.addEventListener("blur", function(e) {
9821
+ if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit();
9822
+ });
9823
+ input.addEventListener("keydown", function(e) {
9824
+ switch (e.key) {
9825
+ case "Enter":
9826
+ commit();
9827
+ break;
9828
+ case "Escape":
9829
+ cancel();
9830
+ break;
9831
+ case "End":
9832
+ case "Home":
9833
+ e.stopPropagation();
9834
+ break;
9835
+ case "ArrowUp":
9836
+ case "ArrowDown": if (vertical === "editor") {
9837
+ e.stopImmediatePropagation();
9838
+ e.stopPropagation();
9839
+ }
9840
+ }
9841
+ });
9842
+ return input;
9843
+ };
9844
+ }
9845
+ //#endregion
9622
9846
  //#region src/form_json_field.js
9623
9847
  /***********************************************************************
9624
9848
  * form_json_field.js
@@ -10043,8 +10267,8 @@ var attrs_table$17 = [
10043
10267
  SDATA(data_type_t.DTP_STRING, "topic_name", 0, "", "Treedb topic name: labels use the i18n cascade '<topic>.<col>' -> '<col>' -> header (like table headers)"),
10044
10268
  SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
10045
10269
  SDATA(data_type_t.DTP_BOOLEAN, "readonly", 0, false, "Show EVERY field read-only, whatever its schema says: a record being LOOKED at, not edited. Independent of `editable`, which drives the TABLE rendering; this one drives the FORM"),
10046
- SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "Rows selectable with 'click' (BAD with editable=true)"),
10047
- SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
10270
+ SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
10271
+ SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows (not drawn when the form is not `selectable`)"),
10048
10272
  SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
10049
10273
  SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
10050
10274
  SDATA(data_type_t.DTP_JSON, "toolbar", 0, DEFAULT_TOOLBAR.slice(), "Toolbar buttons to show. The order inside each group is the order given here; which side each group takes is form_toolbar_plan.js. [] hides the toolbar"),
@@ -10455,6 +10679,36 @@ function destroy_widget(gobj, what, widget) {
10455
10679
  }
10456
10680
  }
10457
10681
  /************************************************************
10682
+ * Close the cell editor a table has open, dropping what is
10683
+ * typed in it, before its rows are wiped. Tabulator 6.6.0
10684
+ * closes it while it wipes them, and the redraw that follows
10685
+ * walks the rows already wiped: a reload, a Clear or a destroy
10686
+ * with an editor open in any row but the first threw, and left
10687
+ * the table half wiped.
10688
+ *
10689
+ * Tabulator has no public way to ask which cell is edited: this
10690
+ * reads its edit module (`modules.edit`, `currentCell`,
10691
+ * `cancelEdit()`), names pinned against the installed Tabulator
10692
+ * by tabulator_edit_internals.test.js. A Tabulator without them
10693
+ * is said: the guard would do nothing, and the crash come back.
10694
+ ************************************************************/
10695
+ function close_table_editor(gobj, tabulator) {
10696
+ let edit = tabulator.modules ? tabulator.modules.edit : null;
10697
+ if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
10698
+ log_warning(`${gobj_short_name(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
10699
+ return;
10700
+ }
10701
+ if (edit.currentCell) edit.cancelEdit();
10702
+ }
10703
+ /************************************************************
10704
+ * The element of the table (`.tabulator` kept on it) that holds
10705
+ * $el, the innermost one.
10706
+ ************************************************************/
10707
+ function table_element_of($el) {
10708
+ for (let $n = $el; $n; $n = $n.parentNode) if ($n.tabulator) return $n;
10709
+ return null;
10710
+ }
10711
+ /************************************************************
10458
10712
  * A table element that is gone: its identity is no table now,
10459
10713
  * and what was waiting to be loaded in it never will be.
10460
10714
  ************************************************************/
@@ -10475,6 +10729,7 @@ function destroy_row_tables(gobj, $row) {
10475
10729
  $row.yui_nested = null;
10476
10730
  for (let $nested of nested) {
10477
10731
  if ($nested.tabulator) {
10732
+ close_table_editor(gobj, $nested.tabulator);
10478
10733
  destroy_rows_tables(gobj, $nested.tabulator);
10479
10734
  destroy_widget(gobj, "nested table", $nested.tabulator);
10480
10735
  $nested.tabulator = null;
@@ -10507,6 +10762,7 @@ function destroy_widgets(gobj, $container) {
10507
10762
  $el.jsoneditor = null;
10508
10763
  }
10509
10764
  if ($el.tabulator) {
10765
+ close_table_editor(gobj, $el.tabulator);
10510
10766
  destroy_rows_tables(gobj, $el.tabulator);
10511
10767
  destroy_widget(gobj, "table", $el.tabulator);
10512
10768
  $el.tabulator = null;
@@ -11747,7 +12003,8 @@ function create_coordinates(gobj, attrs) {
11747
12003
  * Create tabulator
11748
12004
  *
11749
12005
  * A row builds its nested tables the first time it is drawn, each
11750
- * loaded from the row's own data, and keeps them on its element
12006
+ * BUILT with the rows of the row's own data (`rows`, a copy: the
12007
+ * table keeps what it is given), and keeps them on its element
11751
12008
  * (`yui_nested`) until the row goes (destroy_row_tables). A row
11752
12009
  * drawn AGAIN -- a forced redraw, a column rebuilt -- has its
11753
12010
  * children taken off by Tabulator before its formatter runs: they
@@ -11758,15 +12015,39 @@ function create_coordinates(gobj, attrs) {
11758
12015
  * `tableBuilt`, ONE per table (`yui_pending_rows`): a later load
11759
12016
  * replaces it, a clear drops it. Each load used to hang a listener
11760
12017
  * of its own, so two loads before the build drew the rows twice.
12018
+ *
12019
+ * A nested table is not loaded after it is built, as the form's
12020
+ * own tables are (EV_LOAD_TABLE_ROWS): each such load laid it out
12021
+ * twice and redrew it once more, and with a nested table per row
12022
+ * that was most of the time of a load.
12023
+ *
12024
+ * A table selects rows only when a host sets `selectableRows` (true
12025
+ * or a number) in `tabulator_settings`. Tabulator's SelectRow then
12026
+ * toggles a row on its own click, asking `selectableRowsCheck` --
12027
+ * the form's `selectable` -- first. Up to 7.26.44 the form toggled
12028
+ * the row again in `rowClick`, which undid every click. The default
12029
+ * `"highlight"` is left as it is, hover and all.
12030
+ *
12031
+ * The checkbox column (`with_checkbox`) asks `selectable` too, and is
12032
+ * not drawn when the form is not selectable: Tabulator's row box ticks
12033
+ * before its toggle is refused (a ticked box over a row not selected),
12034
+ * and its header box selects every row asking nothing. Up to 7.26.45
12035
+ * the boxes were drawn and lied; with the default `selectableRows`
12036
+ * they selected whatever `selectable` said.
12037
+ *
12038
+ * A click in a nested table stays there: it bubbled to the row that
12039
+ * holds the table, whose own click listener (SelectRow's) toggled
12040
+ * that row too.
11761
12041
  ******************************************************************/
11762
- function create_tabulator$1(gobj, $extend, name, template) {
11763
- function get_selectable_state(row) {
11764
- let selectable_rows = tabulator.options.selectableRows;
11765
- return gobj_read_bool_attr(gobj, "selectable") && (selectable_rows === true || typeof selectable_rows === "number");
11766
- }
12042
+ function create_tabulator$1(gobj, $extend, name, template, rows) {
11767
12043
  $extend.template = template;
11768
12044
  let tabulator_settings = json_deep_copy(gobj_read_attr(gobj, "tabulator_settings"));
11769
- Object.assign(tabulator_settings, {});
12045
+ if (is_array(rows) && rows.length > 0) tabulator_settings.data = json_deep_copy(rows);
12046
+ let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
12047
+ let selectable_rows = tabulator_settings.selectableRows;
12048
+ if (selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) tabulator_settings.selectableRowsCheck = function() {
12049
+ return gobj_read_bool_attr(gobj, "selectable");
12050
+ };
11770
12051
  let columns = [];
11771
12052
  if (gobj_read_bool_attr(gobj, "with_rownum")) columns.push({
11772
12053
  formatter: "rownum",
@@ -11791,11 +12072,16 @@ function create_tabulator$1(gobj, $extend, name, template) {
11791
12072
  "name": sub_element.name
11792
12073
  }];
11793
12074
  let $extend = createElement2(extend);
11794
- $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template);
12075
+ $extend.addEventListener("click", function(ev) {
12076
+ ev.stopPropagation();
12077
+ });
12078
+ $extend.addEventListener("mousedown", function(ev) {
12079
+ if (ev.shiftKey) ev.stopPropagation();
12080
+ });
12081
+ let rows = data[sub_element.name];
12082
+ $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template, rows);
11795
12083
  $row.appendChild($extend);
11796
12084
  $row.yui_nested.push($extend);
11797
- let rows = data[sub_element.name];
11798
- load_tabulator_data(gobj, $extend, is_array(rows) ? rows : []);
11799
12085
  }
11800
12086
  };
11801
12087
  if (gobj_read_bool_attr(gobj, "with_delete_row_btn")) columns.push({
@@ -11813,7 +12099,7 @@ function create_tabulator$1(gobj, $extend, name, template) {
11813
12099
  cell.getRow().delete();
11814
12100
  }
11815
12101
  });
11816
- if (gobj_read_bool_attr(gobj, "with_checkbox")) tabulator_settings.rowHeader = {
12102
+ if (with_checkbox && gobj_read_bool_attr(gobj, "selectable")) tabulator_settings.rowHeader = {
11817
12103
  formatter: "rowSelection",
11818
12104
  titleFormatter: "rowSelection",
11819
12105
  headerSort: false,
@@ -11827,6 +12113,11 @@ function create_tabulator$1(gobj, $extend, name, template) {
11827
12113
  if (gobj.priv.loading_rows > 0) return;
11828
12114
  gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
11829
12115
  });
12116
+ $extend.addEventListener("input", function(ev) {
12117
+ let $target = ev.target;
12118
+ if (!$target || typeof $target.closest !== "function" || !$target.closest(".tabulator-cell.tabulator-editing") || table_element_of($target) !== $extend) return;
12119
+ gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
12120
+ });
11830
12121
  $extend.yui_pending_rows = null;
11831
12122
  tabulator.on("tableBuilt", function() {
11832
12123
  let rows = $extend.yui_pending_rows;
@@ -11847,11 +12138,9 @@ function create_tabulator$1(gobj, $extend, name, template) {
11847
12138
  });
11848
12139
  tabulator.on("rowClick", function(e, row) {
11849
12140
  e.preventDefault();
11850
- if (get_selectable_state(row)) row.toggleSelect();
11851
12141
  });
11852
12142
  tabulator.on("cellClick", function(e, cell) {
11853
12143
  e.preventDefault();
11854
- cell.getRow();
11855
12144
  });
11856
12145
  return tabulator;
11857
12146
  }
@@ -11983,13 +12272,8 @@ function template2columns(gobj, columns, template, sub_elements) {
11983
12272
  break;
11984
12273
  case "now":
11985
12274
  case "time":
11986
- column.editor = "datetime";
11987
- column.editorParams = {
11988
- format: "dd/MM/yyyy hh:mm",
11989
- verticalNavigation: "table",
11990
- elementAttributes: { title: t("slide bar to choose option") }
11991
- };
11992
- field_desc.real_type;
12275
+ column.editor = form_time_cell_editor(field_desc.real_type);
12276
+ column.editorParams = { verticalNavigation: "table" };
11993
12277
  break;
11994
12278
  case "color":
11995
12279
  column.editor = "input";
@@ -12280,6 +12564,7 @@ function clear_data(gobj, $form) {
12280
12564
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
12281
12565
  $table.yui_pending_rows = null;
12282
12566
  if ($table.tabulator.initialized) {
12567
+ close_table_editor(gobj, $table.tabulator);
12283
12568
  destroy_rows_tables(gobj, $table.tabulator);
12284
12569
  $table.tabulator.clearData();
12285
12570
  }
@@ -78966,6 +79251,8 @@ function render_diagram(gobj) {
78966
79251
  * its own node click, which it publishes from inside G6's dispatch
78967
79252
  * of that click: stopped there, the gobj went from under its own
78968
79253
  * publication and the G6 graph from under its own event.
79254
+ * It is not heard from the moment it leaves: what it published in
79255
+ * that turn reached the editor as the current drawing's.
78969
79256
  ***************************************************************/
78970
79257
  function destroy_diagram(gobj) {
78971
79258
  let priv = gobj.priv;
@@ -78974,6 +79261,7 @@ function destroy_diagram(gobj) {
78974
79261
  priv.diagram_gobj = null;
78975
79262
  let $d = gobj_read_attr(diagram, "$container");
78976
79263
  if ($d && $d.parentNode) $d.parentNode.removeChild($d);
79264
+ gobj_unsubscribe_event(diagram, null, {}, gobj);
78977
79265
  priv.retired_diagrams.push(diagram);
78978
79266
  if (priv.retired_diagrams.length === 1) gobj_post_event(gobj, "EV_DESTROY_DIAGRAMS", {}, gobj);
78979
79267
  }
@@ -85381,6 +85669,6 @@ function setup_json_pad(self) {
85381
85669
  return win;
85382
85670
  }
85383
85671
  //#endregion
85384
- export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_user_icon_class, yui_watch_theme };
85672
+ export { EditControl, ICONS_TOPIC, MarkerControl, USER_ICON_PREFIX, YUI_FILE_ACCEPT, YUI_PERIODS, YUI_PERIODS_DEFAULT, YUI_ROLLING, addClasses, apply_dev_traces, attach_clear, build_dev_panel, dev_window_was_open, disableElements, enableElements, epoch_to_local_input, epoch_to_ms, expose_view_container, fmt_epoch, getStrokeColor, infer_period, info_traffic, inject_svg_icons, is_current_period, iso_week, local_input_to_epoch, ms_to_epoch, period_bounds, period_bounds_epoch, period_label, period_name, period_shift, period_spec, period_start, refresh_clear, register_c_g6_nodes_tree, register_c_yui_form, register_c_yui_fsm_graph, register_c_yui_gclass, register_c_yui_gobj_tree_js, register_c_yui_json, register_c_yui_json_graph, register_c_yui_json_pad, register_c_yui_map, register_c_yui_nav, register_c_yui_pager, register_c_yui_period, register_c_yui_schema_editor, register_c_yui_service_view, register_c_yui_shell, register_c_yui_treedb_graph, register_c_yui_treedb_schema, register_c_yui_treedb_topic_with_form, register_c_yui_treedb_topics, register_c_yui_uplot, register_c_yui_window, register_c_yui_window_manager, register_c_yui_wizard, removeChildElements, removeClasses, rolling_bounds, safe_locale, set_active_state, set_cancel_state, set_pressed_state, set_submit_state, setup_dev, setup_frontend_view, setup_json_pad, toggleClasses, yui_array_buffer_to_base64, yui_asset_element, yui_asset_id, yui_asset_ids, yui_asset_missing, yui_asset_src, yui_file_control, yui_file_id_label, yui_file_read, yui_file_sha256, yui_file_size_label, yui_files_manifest, yui_icon_is_defined, yui_icons_list, yui_icons_put_user, yui_icons_remove_user, yui_icons_set_user, yui_is_dark, yui_mount_service_view, yui_shell_close_drawer, yui_shell_close_dropdown, yui_shell_confirm_danger, yui_shell_confirm_ok, yui_shell_confirm_yesno, yui_shell_confirm_yesnocancel, yui_shell_escape_order, yui_shell_navigate, yui_shell_open_drawer, yui_shell_overlay_dismissed, yui_shell_pop_escape, yui_shell_push_escape, yui_shell_refresh_avatars, yui_shell_register_event_handler, yui_shell_register_overlay, yui_shell_set_avatar_provider, yui_shell_set_connection_state, yui_shell_set_nav_item_badge, yui_shell_set_sub_routes, yui_shell_set_toolbar_item_badge, yui_shell_set_toolbar_item_icon, yui_shell_set_translator, yui_shell_show_error, yui_shell_show_info, yui_shell_show_modal, yui_shell_show_route_map, yui_shell_show_warning, yui_shell_toggle_drawer, yui_shell_unpark_route, yui_svg_icon_element, yui_svg_sanitize, yui_theme_now, yui_toolbar, yui_user_icon_class, yui_watch_theme };
85385
85673
 
85386
85674
  //# sourceMappingURL=gobj-ui.es.js.map
package/index.js CHANGED
@@ -48,6 +48,7 @@ export {
48
48
  yui_shell_toggle_drawer,
49
49
  yui_shell_push_escape,
50
50
  yui_shell_pop_escape,
51
+ yui_shell_escape_order,
51
52
  yui_shell_set_avatar_provider,
52
53
  yui_shell_refresh_avatars,
53
54
  yui_shell_set_translator,