@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.
@@ -139,7 +139,14 @@ function yui_tint(colour) {
139
139
  * that wrapped to it, did nothing and was prevented -- the
140
140
  * keyboard never got into the dialog.
141
141
  *
142
- * Pure module — no gobj / Yuneta dependencies. The optional
142
+ * A trap whose panel left the document without being released
143
+ * (its owner was torn down with it) is dropped, with its
144
+ * listener, the next time the stack is read, and said. Up to
145
+ * gobj-ui 7.26.45 it stayed the top: every window opened later
146
+ * believed itself under an overlay and took no focus, and a
147
+ * live trap under it no longer heard Tab.
148
+ *
149
+ * No gobj dependency: only gobj-js's logger. The optional
143
150
  * second argument lets callers inject a mock document object
144
151
  * for unit tests.
145
152
  *
@@ -148,6 +155,15 @@ function yui_tint(colour) {
148
155
  ***********************************************************************/
149
156
  var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
150
157
  var __trap_stack__ = [];
158
+ function drop_detached_traps() {
159
+ for (let i = __trap_stack__.length - 1; i >= 0; i--) {
160
+ let trap = __trap_stack__[i];
161
+ if (trap.$panel.isConnected !== false) continue;
162
+ __trap_stack__.splice(i, 1);
163
+ trap.detach();
164
+ (0, _yuneta_gobj_js.log_warning)("focus trap: its panel left the document without releasing it; dropped (the overlay's owner was torn down with it open)");
165
+ }
166
+ }
151
167
  function is_drawn(el) {
152
168
  if (typeof el.checkVisibility === "function") return el.checkVisibility();
153
169
  if (typeof el.getClientRects === "function") return el.getClientRects().length > 0;
@@ -172,6 +188,7 @@ function activate_focus_trap_on($panel, doc) {
172
188
  let released = false;
173
189
  let trap = function(ev) {
174
190
  if (ev.key !== "Tab" && ev.keyCode !== 9) return;
191
+ drop_detached_traps();
175
192
  if (__trap_stack__[__trap_stack__.length - 1] !== trap) return;
176
193
  let nodes = focusables_of($panel);
177
194
  if (nodes.length === 0) return;
@@ -188,6 +205,10 @@ function activate_focus_trap_on($panel, doc) {
188
205
  ev.preventDefault();
189
206
  }
190
207
  };
208
+ trap.$panel = $panel;
209
+ trap.detach = function() {
210
+ doc.removeEventListener("keydown", trap, true);
211
+ };
191
212
  doc.addEventListener("keydown", trap, true);
192
213
  __trap_stack__.push(trap);
193
214
  let firstFocusable = focusables_of($panel)[0];
@@ -201,6 +222,18 @@ function activate_focus_trap_on($panel, doc) {
201
222
  if (saved && typeof saved.focus === "function" && (!doc.body || !doc.body.contains || doc.body.contains(saved))) saved.focus();
202
223
  };
203
224
  }
225
+ /***************************************************************
226
+ * The panel of the trap that holds the focus now (the top of the
227
+ * stack), or null when none is up. What holds one -- a modal, a
228
+ * dialog, a drawer, a menu -- is drawn above every window that is
229
+ * not modal: such a window that took the focus would take it
230
+ * where it cannot be seen, and the next Tab would give it back.
231
+ ***************************************************************/
232
+ function focus_trap_panel() {
233
+ drop_detached_traps();
234
+ let top = __trap_stack__[__trap_stack__.length - 1];
235
+ return top ? top.$panel : null;
236
+ }
204
237
  //#endregion
205
238
  //#region src/shell_show_on.js
206
239
  /***********************************************************************
@@ -1238,6 +1271,7 @@ var PRIVATE_DATA$22 = {
1238
1271
  hash_handler: null,
1239
1272
  keydown_handler: null,
1240
1273
  escape_stack: [],
1274
+ escape_seq: 0,
1241
1275
  overlay_stack: [],
1242
1276
  expected_pops: 0,
1243
1277
  expected_pop_hash: "",
@@ -1379,7 +1413,10 @@ function mt_start$21(gobj) {
1379
1413
  priv.keydown_handler = (ev) => {
1380
1414
  if (ev.key !== "Escape" && ev.keyCode !== 27) return;
1381
1415
  if (priv.escape_stack.length === 0) return;
1382
- if (escape_is_taken(ev)) return;
1416
+ if (escape_is_taken(ev)) {
1417
+ take_back_focus(ev);
1418
+ return;
1419
+ }
1383
1420
  let top = priv.escape_stack[priv.escape_stack.length - 1];
1384
1421
  ev.preventDefault();
1385
1422
  ev.stopPropagation();
@@ -1400,6 +1437,7 @@ function mt_start$21(gobj) {
1400
1437
  function mt_stop$20(gobj) {
1401
1438
  let priv = gobj.priv;
1402
1439
  if (!priv) return 0;
1440
+ close_overlays(gobj);
1403
1441
  close_toolbar_dropdown(gobj);
1404
1442
  if (priv.hash_handler) {
1405
1443
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -1454,6 +1492,7 @@ function mt_stop$20(gobj) {
1454
1492
  * Framework Method: Destroy
1455
1493
  ***************************************************************/
1456
1494
  function mt_destroy$22(gobj) {
1495
+ close_overlays(gobj);
1457
1496
  close_toolbar_dropdown(gobj);
1458
1497
  let live_idx = __live_shells__.indexOf(gobj);
1459
1498
  if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
@@ -2554,7 +2593,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger) {
2554
2593
  $panel.__yui_backdrop_handler__ = backdrop;
2555
2594
  $panel.__yui_dismiss_handler__ = dismiss;
2556
2595
  $panel.__yui_trigger__ = $trigger || null;
2557
- push_escape(gobj, "popup", close_fn);
2596
+ push_escape(gobj, "popup", close_fn, close_fn);
2558
2597
  $panel.__yui_focus_release__ = activate_focus_trap_on($panel);
2559
2598
  if ($trigger) $trigger.setAttribute("aria-expanded", "true");
2560
2599
  priv.active_dropdown = $panel;
@@ -2699,23 +2738,69 @@ function drawers(gobj, menu_id) {
2699
2738
  return out;
2700
2739
  }
2701
2740
  /************************************************************
2741
+ * An Escape that closed an inline editor (a table cell) took the
2742
+ * focus with it, to <body>: the overlay that holds the focus (the
2743
+ * top trap: a dialog, a drawer) takes it back, as a window does --
2744
+ * a reader was left on the page, outside the dialog it was in.
2745
+ ************************************************************/
2746
+ function take_back_focus(ev) {
2747
+ if (!ev.target || ev.target.isConnected !== false) return;
2748
+ let active = document.activeElement;
2749
+ if (active && active !== document.body) return;
2750
+ let $panel = focus_trap_panel();
2751
+ if (!$panel || $panel.isConnected === false) return;
2752
+ if (!$panel.hasAttribute("tabindex")) $panel.setAttribute("tabindex", "-1");
2753
+ $panel.focus();
2754
+ }
2755
+ /************************************************************
2702
2756
  * Escape priority chain helpers — push/pop a {layer, handler}
2703
2757
  * record on `priv.escape_stack`. Escape calls the top entry
2704
2758
  * only and consumes the event; LIFO ordering naturally matches
2705
2759
  * the z-index layering most apps use (drawer at the bottom,
2706
2760
  * modal on top, popup on top of that).
2761
+ *
2762
+ * `teardown` is the overlay's UNCONDITIONAL close, what the shell
2763
+ * runs when it stops with the overlay still up (close_overlays);
2764
+ * `handler` may be a guarded one (a modal's before_close).
2707
2765
  ************************************************************/
2708
- function push_escape(gobj, layer, handler) {
2766
+ function push_escape(gobj, layer, handler, teardown) {
2709
2767
  let priv = gobj.priv;
2710
2768
  if (!priv || !priv.escape_stack) {
2711
2769
  (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
2712
2770
  return;
2713
2771
  }
2772
+ priv.escape_seq += 1;
2714
2773
  priv.escape_stack.push({
2715
2774
  layer,
2716
- handler
2775
+ handler,
2776
+ teardown: typeof teardown === "function" ? teardown : null,
2777
+ seq: priv.escape_seq
2717
2778
  });
2718
2779
  }
2780
+ /************************************************************
2781
+ * Close every overlay still up, the top first, as if each had
2782
+ * been dismissed: a shell that stops -- a logout, a session cut
2783
+ * -- with a drawer, a modal or a question open. Up to gobj-ui
2784
+ * 7.26.45 only the toolbar dropdown was closed: the others kept
2785
+ * their focus trap, and every window opened afterwards believed
2786
+ * itself under an overlay and took no focus; a question never
2787
+ * answered. Run before the views stop, so what an overlay's
2788
+ * on_close calls is still alive. An overlay pushed with no
2789
+ * teardown is left to its owner.
2790
+ ************************************************************/
2791
+ function close_overlays(gobj) {
2792
+ let priv = gobj.priv;
2793
+ if (!priv || !priv.escape_stack) return;
2794
+ let entries = priv.escape_stack.slice().reverse();
2795
+ for (let entry of entries) {
2796
+ if (!entry.teardown) continue;
2797
+ try {
2798
+ entry.teardown();
2799
+ } catch (e) {
2800
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: closing the '${entry.layer}' overlay at stop failed: ${e}`);
2801
+ }
2802
+ }
2803
+ }
2719
2804
  function pop_escape(gobj, handler) {
2720
2805
  let priv = gobj.priv;
2721
2806
  if (!priv || !priv.escape_stack) return;
@@ -2925,7 +3010,7 @@ function open_drawer_one(gobj, $c) {
2925
3010
  if ($c.classList.contains("is-active")) return;
2926
3011
  let close_fn = () => close_drawer_one(gobj, $c);
2927
3012
  $c.__yui_close_handler__ = close_fn;
2928
- push_escape(gobj, "overlay", close_fn);
3013
+ push_escape(gobj, "overlay", close_fn, close_fn);
2929
3014
  $c.classList.add("is-active");
2930
3015
  $c.__yui_focus_release__ = activate_focus_trap_on($c.querySelector(".yui-drawer-panel") || $c);
2931
3016
  }
@@ -3627,12 +3712,17 @@ function yui_shell_close_drawer(shell_gobj, menu_id) {
3627
3712
  function yui_shell_toggle_drawer(shell_gobj, menu_id) {
3628
3713
  toggle_drawer(shell_gobj, menu_id);
3629
3714
  }
3630
- function yui_shell_push_escape(shell_gobj, layer, handler) {
3631
- push_escape(shell_gobj, layer, handler);
3715
+ function yui_shell_push_escape(shell_gobj, layer, handler, teardown) {
3716
+ push_escape(shell_gobj, layer, handler, teardown);
3632
3717
  }
3633
3718
  function yui_shell_pop_escape(shell_gobj, handler) {
3634
3719
  pop_escape(shell_gobj, handler);
3635
3720
  }
3721
+ function yui_shell_escape_order(shell_gobj) {
3722
+ let priv = shell_gobj && shell_gobj.priv;
3723
+ if (!priv || !priv.escape_stack || priv.escape_stack.length === 0) return 0;
3724
+ return priv.escape_stack[priv.escape_stack.length - 1].seq;
3725
+ }
3636
3726
  function yui_shell_register_overlay(shell_gobj, close_fn, opts) {
3637
3727
  return push_overlay_history(shell_gobj, close_fn, opts);
3638
3728
  }
@@ -4232,7 +4322,7 @@ function yui_shell_show_modal(shell, content, opts) {
4232
4322
  });
4233
4323
  };
4234
4324
  escape_handler = request_close;
4235
- yui_shell_push_escape(shell, "modal", request_close);
4325
+ yui_shell_push_escape(shell, "modal", request_close, do_close);
4236
4326
  overlay = yui_shell_register_overlay(shell, on_back);
4237
4327
  release_focus = activate_focus_trap_on($modal);
4238
4328
  if (opts == null || opts.dismiss_on_background !== false) $modal.querySelector(".modal-background").addEventListener("click", request_close);
@@ -4387,7 +4477,7 @@ function build_dialog(shell, message, buttons, opts) {
4387
4477
  resolve(value);
4388
4478
  };
4389
4479
  close_fn = () => close(dismiss_value);
4390
- yui_shell_push_escape(shell, "modal", close_fn);
4480
+ yui_shell_push_escape(shell, "modal", close_fn, close_fn);
4391
4481
  overlay = yui_shell_register_overlay(shell, close_fn);
4392
4482
  release_focus = activate_focus_trap_on($modal.querySelector(".modal-card"));
4393
4483
  $modal.querySelector(".modal-background").addEventListener("click", () => close(dismiss_value));
@@ -4586,7 +4676,8 @@ var PRIVATE_DATA$21 = {
4586
4676
  back_shell: null,
4587
4677
  opener: null,
4588
4678
  $lock: null,
4589
- release_focus: null
4679
+ release_focus: null,
4680
+ escape_order: 0
4590
4681
  };
4591
4682
  var __gclass__$21 = null;
4592
4683
  /******************************
@@ -4651,6 +4742,12 @@ function mt_create$21(gobj) {
4651
4742
  * the first Tab of a keyboard reader landed in a window they had
4652
4743
  * not opened. A modal window takes it all the same: nothing else
4653
4744
  * can be used while it is up.
4745
+ *
4746
+ * Nor does one opened under an overlay that holds the focus (a
4747
+ * modal window, a dialog, a drawer, a menu: all are drawn above
4748
+ * the window layer). Up to gobj-ui 7.26.44 it took the focus where
4749
+ * it could not be seen, and the next Tab gave it back to the
4750
+ * overlay; it opens under it now, and is there when it goes.
4654
4751
  ***************************************************************/
4655
4752
  function mt_start$20(gobj) {
4656
4753
  let priv = gobj.priv;
@@ -4661,9 +4758,12 @@ function mt_start$20(gobj) {
4661
4758
  }
4662
4759
  let active = document.activeElement;
4663
4760
  if (active && active !== document.body && !$container.contains(active)) priv.opener = active;
4761
+ priv.escape_order = yui_shell_escape_order(yui_shell_of(gobj));
4664
4762
  let modal = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "modal");
4763
+ let $trap = focus_trap_panel();
4764
+ let under_an_overlay = !!$trap && !$trap.contains($container);
4665
4765
  if (modal && !priv.release_focus) priv.release_focus = activate_focus_trap_on($container);
4666
- if (modal || opened_by_the_reader()) focus_target(gobj, $container).focus();
4766
+ if (modal || opened_by_the_reader() && !under_an_overlay) focus_target(gobj, $container).focus();
4667
4767
  }
4668
4768
  /***************************************************************
4669
4769
  * Framework Method: Destroy
@@ -4917,8 +5017,9 @@ function window_root(gobj) {
4917
5017
  /************************************************************
4918
5018
  * An Escape typed in the window. The callback only decides
4919
5019
  * whether the key is the window's -- not when `keyboard` is
4920
- * off, nor one that what it was typed in took -- and sends
4921
- * the event: the close is the ✕'s, in the action.
5020
+ * off, nor one that what it was typed in took, nor while an
5021
+ * overlay of the shell opened after the window is up -- and
5022
+ * sends the event: the close is the ✕'s, in the action.
4922
5023
  ************************************************************/
4923
5024
  function on_escape_key(gobj, evt) {
4924
5025
  if (evt.key !== "Escape" && evt.keyCode !== 27) return;
@@ -4929,6 +5030,7 @@ function on_escape_key(gobj, evt) {
4929
5030
  if (evt.target && evt.target.isConnected === false && $container && (!active || active === document.body)) $container.focus();
4930
5031
  return;
4931
5032
  }
5033
+ if (yui_shell_escape_order(yui_shell_of(gobj)) > gobj.priv.escape_order) return;
4932
5034
  evt.preventDefault();
4933
5035
  evt.stopPropagation();
4934
5036
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CLOSE_WINDOW", { key: "Escape" }, gobj);
@@ -4986,7 +5088,17 @@ function build_ui$18(gobj) {
4986
5088
  if ((0, _yuneta_gobj_js.is_gobj)(footer)) footer = (0, _yuneta_gobj_js.gobj_read_attr)(footer, "$container");
4987
5089
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "auto_save_size_and_position")) {
4988
5090
  if ((0, _yuneta_gobj_js.gobj_is_service)(gobj)) {
4989
- let rect = whole_rect((0, _yuneta_gobj_js.kw_get_local_storage_value)(`${(0, _yuneta_gobj_js.gobj_name)(gobj)}-rect`));
5091
+ let key = `${(0, _yuneta_gobj_js.gobj_name)(gobj)}-rect`;
5092
+ let stored = (0, _yuneta_gobj_js.kw_get_local_storage_value)(key);
5093
+ let rect = whole_rect(stored);
5094
+ if (!rect && stored != null) {
5095
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
5096
+ (0, _yuneta_gobj_js.kw_remove_local_storage_value)(key);
5097
+ } else if (rect && (rect.width <= 0 || rect.height <= 0)) {
5098
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the saved position '${key}' has no size (${rect.width} x ${rect.height}): ignored`);
5099
+ (0, _yuneta_gobj_js.kw_remove_local_storage_value)(key);
5100
+ rect = null;
5101
+ }
4990
5102
  if (rect) {
4991
5103
  rect.x = rect.x < 0 ? 0 : rect.x;
4992
5104
  rect.y = rect.y < 0 ? 0 : rect.y;
@@ -5688,6 +5800,7 @@ function ac_shell_changed$1(gobj, event, kw, src) {
5688
5800
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "back_overlay", null);
5689
5801
  priv.back_shell = null;
5690
5802
  }
5803
+ priv.escape_order = going ? 0 : yui_shell_escape_order(src);
5691
5804
  let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
5692
5805
  if (!$container) {
5693
5806
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: EV_SHELL_CHANGED without a container`);
@@ -9624,6 +9737,117 @@ function datetime_local_to_epoch(value) {
9624
9737
  return Math.floor(date.getTime() / 1e3);
9625
9738
  }
9626
9739
  //#endregion
9740
+ //#region src/form_time_cell_editor.js
9741
+ /****************************************************************************
9742
+ * form_time_cell_editor.js
9743
+ *
9744
+ * The cell editor of a `time` / `now` column in a table of
9745
+ * C_YUI_FORM: a `datetime-local` box, as the form's own time
9746
+ * field, converting with the same helpers (form_time_value.js)
9747
+ * -- an epoch in SECONDS for an integer column, an ISO text
9748
+ * for a string one -- and to the second (`step` 1).
9749
+ *
9750
+ * Up to gobj-ui 7.26.45 the column used Tabulator's `datetime`
9751
+ * editor with a `format`, which needs luxon, and nothing gives
9752
+ * gobj-ui luxon: the editor said "'date' editor 'format' param
9753
+ * is dependant on luxon.js" in the console, opened empty, and
9754
+ * threw when it was committed. Its format ("dd/MM/yyyy hh:mm",
9755
+ * 12-hour) could not have read an epoch either. Luxon is not
9756
+ * taken in for it: one editor is not worth a dependency every
9757
+ * app would have to dedupe, and the conversion it needs is the
9758
+ * one the form already makes.
9759
+ *
9760
+ * It behaves as Tabulator's own: `elementAttributes` are
9761
+ * written on the box (the column's name, see
9762
+ * yui_tabulator_name_editor), a true blur or Enter commits,
9763
+ * Escape cancels, `verticalNavigation: "editor"` keeps the
9764
+ * arrows, and a value that did not change is a cancel.
9765
+ *
9766
+ * Copyright (c) 2026, ArtGins.
9767
+ * All Rights Reserved.
9768
+ ****************************************************************************/
9769
+ /************************************************************
9770
+ * A cell's value -> the text of the box ("" when empty).
9771
+ ************************************************************/
9772
+ function time_to_datetime_local(value, real_type) {
9773
+ if (value === null || value === void 0 || value === "") return "";
9774
+ if (real_type === "string") return date_to_datetime_local(new Date(String(value)));
9775
+ let seconds = Number(value);
9776
+ if (!Number.isFinite(seconds)) return "";
9777
+ return date_to_datetime_local(/* @__PURE__ */ new Date(seconds * 1e3));
9778
+ }
9779
+ /************************************************************
9780
+ * The text of the box -> the cell's value (null when empty).
9781
+ ************************************************************/
9782
+ function datetime_local_to_time(text, real_type) {
9783
+ let epoch = datetime_local_to_epoch(text);
9784
+ if (epoch === null) return null;
9785
+ if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
9786
+ return epoch;
9787
+ }
9788
+ /************************************************************
9789
+ * The editor of a time column whose values are `real_type`
9790
+ * ("integer": epoch seconds; "string": ISO text).
9791
+ ************************************************************/
9792
+ function form_time_cell_editor(real_type) {
9793
+ return function(cell, onRendered, success, cancel, editorParams) {
9794
+ let params = editorParams || {};
9795
+ let vertical = params.verticalNavigation || "editor";
9796
+ let original = cell.getValue();
9797
+ let original_text = time_to_datetime_local(original, real_type);
9798
+ let input = document.createElement("input");
9799
+ input.type = "datetime-local";
9800
+ input.setAttribute("step", "1");
9801
+ input.style.padding = "4px";
9802
+ input.style.width = "100%";
9803
+ input.style.boxSizing = "border-box";
9804
+ let attrs = params.elementAttributes;
9805
+ if (attrs && typeof attrs === "object") for (let key of Object.keys(attrs)) input.setAttribute(key, attrs[key]);
9806
+ input.value = original_text;
9807
+ onRendered(function() {
9808
+ if (cell.getType() === "cell") {
9809
+ input.focus({ preventScroll: true });
9810
+ input.style.height = "100%";
9811
+ }
9812
+ });
9813
+ let commit = function() {
9814
+ if (input.value === original_text) {
9815
+ cancel();
9816
+ return;
9817
+ }
9818
+ let value = datetime_local_to_time(input.value, real_type);
9819
+ if (value === original || value === null && original_text === "") {
9820
+ cancel();
9821
+ return;
9822
+ }
9823
+ success(value);
9824
+ };
9825
+ input.addEventListener("blur", function(e) {
9826
+ if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit();
9827
+ });
9828
+ input.addEventListener("keydown", function(e) {
9829
+ switch (e.key) {
9830
+ case "Enter":
9831
+ commit();
9832
+ break;
9833
+ case "Escape":
9834
+ cancel();
9835
+ break;
9836
+ case "End":
9837
+ case "Home":
9838
+ e.stopPropagation();
9839
+ break;
9840
+ case "ArrowUp":
9841
+ case "ArrowDown": if (vertical === "editor") {
9842
+ e.stopImmediatePropagation();
9843
+ e.stopPropagation();
9844
+ }
9845
+ }
9846
+ });
9847
+ return input;
9848
+ };
9849
+ }
9850
+ //#endregion
9627
9851
  //#region src/form_json_field.js
9628
9852
  /***********************************************************************
9629
9853
  * form_json_field.js
@@ -10048,8 +10272,8 @@ var attrs_table$17 = [
10048
10272
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_STRING, "topic_name", 0, "", "Treedb topic name: labels use the i18n cascade '<topic>.<col>' -> '<col>' -> header (like table headers)"),
10049
10273
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
10050
10274
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.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"),
10051
- (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "selectable", 0, true, "Rows selectable with 'click' (BAD with editable=true)"),
10052
- (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
10275
+ (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
10276
+ (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.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`)"),
10053
10277
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
10054
10278
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
10055
10279
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.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"),
@@ -10460,6 +10684,36 @@ function destroy_widget(gobj, what, widget) {
10460
10684
  }
10461
10685
  }
10462
10686
  /************************************************************
10687
+ * Close the cell editor a table has open, dropping what is
10688
+ * typed in it, before its rows are wiped. Tabulator 6.6.0
10689
+ * closes it while it wipes them, and the redraw that follows
10690
+ * walks the rows already wiped: a reload, a Clear or a destroy
10691
+ * with an editor open in any row but the first threw, and left
10692
+ * the table half wiped.
10693
+ *
10694
+ * Tabulator has no public way to ask which cell is edited: this
10695
+ * reads its edit module (`modules.edit`, `currentCell`,
10696
+ * `cancelEdit()`), names pinned against the installed Tabulator
10697
+ * by tabulator_edit_internals.test.js. A Tabulator without them
10698
+ * is said: the guard would do nothing, and the crash come back.
10699
+ ************************************************************/
10700
+ function close_table_editor(gobj, tabulator) {
10701
+ let edit = tabulator.modules ? tabulator.modules.edit : null;
10702
+ if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
10703
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
10704
+ return;
10705
+ }
10706
+ if (edit.currentCell) edit.cancelEdit();
10707
+ }
10708
+ /************************************************************
10709
+ * The element of the table (`.tabulator` kept on it) that holds
10710
+ * $el, the innermost one.
10711
+ ************************************************************/
10712
+ function table_element_of($el) {
10713
+ for (let $n = $el; $n; $n = $n.parentNode) if ($n.tabulator) return $n;
10714
+ return null;
10715
+ }
10716
+ /************************************************************
10463
10717
  * A table element that is gone: its identity is no table now,
10464
10718
  * and what was waiting to be loaded in it never will be.
10465
10719
  ************************************************************/
@@ -10480,6 +10734,7 @@ function destroy_row_tables(gobj, $row) {
10480
10734
  $row.yui_nested = null;
10481
10735
  for (let $nested of nested) {
10482
10736
  if ($nested.tabulator) {
10737
+ close_table_editor(gobj, $nested.tabulator);
10483
10738
  destroy_rows_tables(gobj, $nested.tabulator);
10484
10739
  destroy_widget(gobj, "nested table", $nested.tabulator);
10485
10740
  $nested.tabulator = null;
@@ -10512,6 +10767,7 @@ function destroy_widgets(gobj, $container) {
10512
10767
  $el.jsoneditor = null;
10513
10768
  }
10514
10769
  if ($el.tabulator) {
10770
+ close_table_editor(gobj, $el.tabulator);
10515
10771
  destroy_rows_tables(gobj, $el.tabulator);
10516
10772
  destroy_widget(gobj, "table", $el.tabulator);
10517
10773
  $el.tabulator = null;
@@ -11752,7 +12008,8 @@ function create_coordinates(gobj, attrs) {
11752
12008
  * Create tabulator
11753
12009
  *
11754
12010
  * A row builds its nested tables the first time it is drawn, each
11755
- * loaded from the row's own data, and keeps them on its element
12011
+ * BUILT with the rows of the row's own data (`rows`, a copy: the
12012
+ * table keeps what it is given), and keeps them on its element
11756
12013
  * (`yui_nested`) until the row goes (destroy_row_tables). A row
11757
12014
  * drawn AGAIN -- a forced redraw, a column rebuilt -- has its
11758
12015
  * children taken off by Tabulator before its formatter runs: they
@@ -11763,15 +12020,39 @@ function create_coordinates(gobj, attrs) {
11763
12020
  * `tableBuilt`, ONE per table (`yui_pending_rows`): a later load
11764
12021
  * replaces it, a clear drops it. Each load used to hang a listener
11765
12022
  * of its own, so two loads before the build drew the rows twice.
12023
+ *
12024
+ * A nested table is not loaded after it is built, as the form's
12025
+ * own tables are (EV_LOAD_TABLE_ROWS): each such load laid it out
12026
+ * twice and redrew it once more, and with a nested table per row
12027
+ * that was most of the time of a load.
12028
+ *
12029
+ * A table selects rows only when a host sets `selectableRows` (true
12030
+ * or a number) in `tabulator_settings`. Tabulator's SelectRow then
12031
+ * toggles a row on its own click, asking `selectableRowsCheck` --
12032
+ * the form's `selectable` -- first. Up to 7.26.44 the form toggled
12033
+ * the row again in `rowClick`, which undid every click. The default
12034
+ * `"highlight"` is left as it is, hover and all.
12035
+ *
12036
+ * The checkbox column (`with_checkbox`) asks `selectable` too, and is
12037
+ * not drawn when the form is not selectable: Tabulator's row box ticks
12038
+ * before its toggle is refused (a ticked box over a row not selected),
12039
+ * and its header box selects every row asking nothing. Up to 7.26.45
12040
+ * the boxes were drawn and lied; with the default `selectableRows`
12041
+ * they selected whatever `selectable` said.
12042
+ *
12043
+ * A click in a nested table stays there: it bubbled to the row that
12044
+ * holds the table, whose own click listener (SelectRow's) toggled
12045
+ * that row too.
11766
12046
  ******************************************************************/
11767
- function create_tabulator$1(gobj, $extend, name, template) {
11768
- function get_selectable_state(row) {
11769
- let selectable_rows = tabulator.options.selectableRows;
11770
- return (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable") && (selectable_rows === true || typeof selectable_rows === "number");
11771
- }
12047
+ function create_tabulator$1(gobj, $extend, name, template, rows) {
11772
12048
  $extend.template = template;
11773
12049
  let tabulator_settings = (0, _yuneta_gobj_js.json_deep_copy)((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator_settings"));
11774
- Object.assign(tabulator_settings, {});
12050
+ if ((0, _yuneta_gobj_js.is_array)(rows) && rows.length > 0) tabulator_settings.data = (0, _yuneta_gobj_js.json_deep_copy)(rows);
12051
+ let with_checkbox = (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_checkbox");
12052
+ let selectable_rows = tabulator_settings.selectableRows;
12053
+ if (selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) tabulator_settings.selectableRowsCheck = function() {
12054
+ return (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable");
12055
+ };
11775
12056
  let columns = [];
11776
12057
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_rownum")) columns.push({
11777
12058
  formatter: "rownum",
@@ -11796,11 +12077,16 @@ function create_tabulator$1(gobj, $extend, name, template) {
11796
12077
  "name": sub_element.name
11797
12078
  }];
11798
12079
  let $extend = (0, _yuneta_gobj_js.createElement2)(extend);
11799
- $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template);
12080
+ $extend.addEventListener("click", function(ev) {
12081
+ ev.stopPropagation();
12082
+ });
12083
+ $extend.addEventListener("mousedown", function(ev) {
12084
+ if (ev.shiftKey) ev.stopPropagation();
12085
+ });
12086
+ let rows = data[sub_element.name];
12087
+ $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template, rows);
11800
12088
  $row.appendChild($extend);
11801
12089
  $row.yui_nested.push($extend);
11802
- let rows = data[sub_element.name];
11803
- load_tabulator_data(gobj, $extend, (0, _yuneta_gobj_js.is_array)(rows) ? rows : []);
11804
12090
  }
11805
12091
  };
11806
12092
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_delete_row_btn")) columns.push({
@@ -11818,7 +12104,7 @@ function create_tabulator$1(gobj, $extend, name, template) {
11818
12104
  cell.getRow().delete();
11819
12105
  }
11820
12106
  });
11821
- if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_checkbox")) tabulator_settings.rowHeader = {
12107
+ if (with_checkbox && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable")) tabulator_settings.rowHeader = {
11822
12108
  formatter: "rowSelection",
11823
12109
  titleFormatter: "rowSelection",
11824
12110
  headerSort: false,
@@ -11832,6 +12118,11 @@ function create_tabulator$1(gobj, $extend, name, template) {
11832
12118
  if (gobj.priv.loading_rows > 0) return;
11833
12119
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", {}, gobj);
11834
12120
  });
12121
+ $extend.addEventListener("input", function(ev) {
12122
+ let $target = ev.target;
12123
+ if (!$target || typeof $target.closest !== "function" || !$target.closest(".tabulator-cell.tabulator-editing") || table_element_of($target) !== $extend) return;
12124
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", {}, gobj);
12125
+ });
11835
12126
  $extend.yui_pending_rows = null;
11836
12127
  tabulator.on("tableBuilt", function() {
11837
12128
  let rows = $extend.yui_pending_rows;
@@ -11852,11 +12143,9 @@ function create_tabulator$1(gobj, $extend, name, template) {
11852
12143
  });
11853
12144
  tabulator.on("rowClick", function(e, row) {
11854
12145
  e.preventDefault();
11855
- if (get_selectable_state(row)) row.toggleSelect();
11856
12146
  });
11857
12147
  tabulator.on("cellClick", function(e, cell) {
11858
12148
  e.preventDefault();
11859
- cell.getRow();
11860
12149
  });
11861
12150
  return tabulator;
11862
12151
  }
@@ -11988,13 +12277,8 @@ function template2columns(gobj, columns, template, sub_elements) {
11988
12277
  break;
11989
12278
  case "now":
11990
12279
  case "time":
11991
- column.editor = "datetime";
11992
- column.editorParams = {
11993
- format: "dd/MM/yyyy hh:mm",
11994
- verticalNavigation: "table",
11995
- elementAttributes: { title: (0, i18next.t)("slide bar to choose option") }
11996
- };
11997
- field_desc.real_type;
12280
+ column.editor = form_time_cell_editor(field_desc.real_type);
12281
+ column.editorParams = { verticalNavigation: "table" };
11998
12282
  break;
11999
12283
  case "color":
12000
12284
  column.editor = "input";
@@ -12285,6 +12569,7 @@ function clear_data(gobj, $form) {
12285
12569
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
12286
12570
  $table.yui_pending_rows = null;
12287
12571
  if ($table.tabulator.initialized) {
12572
+ close_table_editor(gobj, $table.tabulator);
12288
12573
  destroy_rows_tables(gobj, $table.tabulator);
12289
12574
  $table.tabulator.clearData();
12290
12575
  }
@@ -78971,6 +79256,8 @@ function render_diagram(gobj) {
78971
79256
  * its own node click, which it publishes from inside G6's dispatch
78972
79257
  * of that click: stopped there, the gobj went from under its own
78973
79258
  * publication and the G6 graph from under its own event.
79259
+ * It is not heard from the moment it leaves: what it published in
79260
+ * that turn reached the editor as the current drawing's.
78974
79261
  ***************************************************************/
78975
79262
  function destroy_diagram(gobj) {
78976
79263
  let priv = gobj.priv;
@@ -78979,6 +79266,7 @@ function destroy_diagram(gobj) {
78979
79266
  priv.diagram_gobj = null;
78980
79267
  let $d = (0, _yuneta_gobj_js.gobj_read_attr)(diagram, "$container");
78981
79268
  if ($d && $d.parentNode) $d.parentNode.removeChild($d);
79269
+ (0, _yuneta_gobj_js.gobj_unsubscribe_event)(diagram, null, {}, gobj);
78982
79270
  priv.retired_diagrams.push(diagram);
78983
79271
  if (priv.retired_diagrams.length === 1) (0, _yuneta_gobj_js.gobj_post_event)(gobj, "EV_DESTROY_DIAGRAMS", {}, gobj);
78984
79272
  }
@@ -85481,6 +85769,7 @@ exports.yui_shell_confirm_danger = yui_shell_confirm_danger;
85481
85769
  exports.yui_shell_confirm_ok = yui_shell_confirm_ok;
85482
85770
  exports.yui_shell_confirm_yesno = yui_shell_confirm_yesno;
85483
85771
  exports.yui_shell_confirm_yesnocancel = yui_shell_confirm_yesnocancel;
85772
+ exports.yui_shell_escape_order = yui_shell_escape_order;
85484
85773
  exports.yui_shell_navigate = yui_shell_navigate;
85485
85774
  exports.yui_shell_open_drawer = yui_shell_open_drawer;
85486
85775
  exports.yui_shell_overlay_dismissed = yui_shell_overlay_dismissed;