@yuneta/gobj-ui 7.26.46 → 7.26.48

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,12 +139,15 @@ 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
- * 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.
142
+ * A trap whose panel is out of the document is not the top:
143
+ * the top is the highest trap whose panel is in it. Up to
144
+ * gobj-ui 7.26.45 a trap left behind by an owner torn down with
145
+ * it stayed the top: every window opened later believed itself
146
+ * under an overlay and took no focus, and a live trap under it
147
+ * no longer heard Tab. 7.26.46 dropped such a trap from the
148
+ * stack, which was for good: a panel that only moved (taken out
149
+ * and put back, its trap never released) lost its trap. It is
150
+ * skipped now, and leaves the stack only by its release().
148
151
  *
149
152
  * No gobj dependency: only gobj-js's logger. The optional
150
153
  * second argument lets callers inject a mock document object
@@ -155,14 +158,12 @@ function yui_tint(colour) {
155
158
  ***********************************************************************/
156
159
  var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
157
160
  var __trap_stack__ = [];
158
- function drop_detached_traps() {
161
+ function top_trap() {
159
162
  for (let i = __trap_stack__.length - 1; i >= 0; i--) {
160
163
  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)");
164
+ if (trap.$panel.isConnected !== false) return trap;
165
165
  }
166
+ return null;
166
167
  }
167
168
  function is_drawn(el) {
168
169
  if (typeof el.checkVisibility === "function") return el.checkVisibility();
@@ -188,8 +189,7 @@ function activate_focus_trap_on($panel, doc) {
188
189
  let released = false;
189
190
  let trap = function(ev) {
190
191
  if (ev.key !== "Tab" && ev.keyCode !== 9) return;
191
- drop_detached_traps();
192
- if (__trap_stack__[__trap_stack__.length - 1] !== trap) return;
192
+ if (top_trap() !== trap) return;
193
193
  let nodes = focusables_of($panel);
194
194
  if (nodes.length === 0) return;
195
195
  let first = nodes[0];
@@ -206,9 +206,6 @@ function activate_focus_trap_on($panel, doc) {
206
206
  }
207
207
  };
208
208
  trap.$panel = $panel;
209
- trap.detach = function() {
210
- doc.removeEventListener("keydown", trap, true);
211
- };
212
209
  doc.addEventListener("keydown", trap, true);
213
210
  __trap_stack__.push(trap);
214
211
  let firstFocusable = focusables_of($panel)[0];
@@ -230,8 +227,7 @@ function activate_focus_trap_on($panel, doc) {
230
227
  * where it cannot be seen, and the next Tab would give it back.
231
228
  ***************************************************************/
232
229
  function focus_trap_panel() {
233
- drop_detached_traps();
234
- let top = __trap_stack__[__trap_stack__.length - 1];
230
+ let top = top_trap();
235
231
  return top ? top.$panel : null;
236
232
  }
237
233
  //#endregion
@@ -1219,6 +1215,7 @@ function secondary_nav_renders(item, layout) {
1219
1215
  ***************************************************************/
1220
1216
  var GCLASS_NAME$22 = "C_YUI_SHELL";
1221
1217
  var __live_shells__ = [];
1218
+ var __retiring_shell__ = null;
1222
1219
  var __shell_watchers__ = [];
1223
1220
  var __window_z__ = 10;
1224
1221
  var ZONE_IDS = [
@@ -1437,7 +1434,7 @@ function mt_start$21(gobj) {
1437
1434
  function mt_stop$20(gobj) {
1438
1435
  let priv = gobj.priv;
1439
1436
  if (!priv) return 0;
1440
- close_overlays(gobj);
1437
+ retire_overlays(gobj);
1441
1438
  close_toolbar_dropdown(gobj);
1442
1439
  if (priv.hash_handler) {
1443
1440
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -1492,7 +1489,7 @@ function mt_stop$20(gobj) {
1492
1489
  * Framework Method: Destroy
1493
1490
  ***************************************************************/
1494
1491
  function mt_destroy$22(gobj) {
1495
- close_overlays(gobj);
1492
+ retire_overlays(gobj);
1496
1493
  close_toolbar_dropdown(gobj);
1497
1494
  let live_idx = __live_shells__.indexOf(gobj);
1498
1495
  if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
@@ -2801,6 +2798,31 @@ function close_overlays(gobj) {
2801
2798
  }
2802
2799
  }
2803
2800
  }
2801
+ /************************************************************
2802
+ * What a shell that stops does with its overlays: their
2803
+ * history markers are left where they are, and then they are
2804
+ * closed (close_overlays). The overlay stack is emptied FIRST,
2805
+ * so no close -- of an overlay closed here, or of a window
2806
+ * closed later -- retires its marker with a history.back().
2807
+ * Such a back() is asynchronous and a stopped shell no longer
2808
+ * hears where it lands: up to gobj-ui 7.26.46 a logout followed
2809
+ * by a new shell in the same turn had it taken by the new
2810
+ * shell's first window (Chromium stepped back off that window's
2811
+ * marker, Firefox dropped the back()), and the next Back left
2812
+ * the page. A marker left in place is inert, as a drained one
2813
+ * is: a later Back lands on it and is absorbed.
2814
+ ************************************************************/
2815
+ function retire_overlays(gobj) {
2816
+ let priv = gobj.priv;
2817
+ if (priv && priv.overlay_stack) priv.overlay_stack.splice(0);
2818
+ let outer = __retiring_shell__;
2819
+ __retiring_shell__ = gobj;
2820
+ try {
2821
+ close_overlays(gobj);
2822
+ } finally {
2823
+ __retiring_shell__ = outer;
2824
+ }
2825
+ }
2804
2826
  function pop_escape(gobj, handler) {
2805
2827
  let priv = gobj.priv;
2806
2828
  if (!priv || !priv.escape_stack) return;
@@ -3741,9 +3763,39 @@ function yui_shell_overlay_dismissed(shell_gobj, overlay) {
3741
3763
  * stranded action entries and RE-FIRES the action, reopening
3742
3764
  * the overlay and hijacking the navigation the user asked
3743
3765
  * for. Only back() while the URL still sits on the route.
3766
+ *
3767
+ * A close that comes from a shell that STOPS (a logout with the
3768
+ * overlay up) does not go back: the URL is rewritten in place,
3769
+ * to the resting route under the overlay. A back() is
3770
+ * asynchronous and the stopped shell would never hear where it
3771
+ * lands -- the overlay's own marker is left in place, so a
3772
+ * single back() landed on the action entry, the URL stayed on
3773
+ * the action route, and a new shell built in the same turn read
3774
+ * it and opened the overlay again (up to gobj-ui 7.26.47).
3744
3775
  ************************************************************/
3745
3776
  function yui_shell_unpark_route(route) {
3746
- if (window.location.hash === route_to_hash(normalize_route(route))) window.history.back();
3777
+ let hash = route_to_hash(normalize_route(route));
3778
+ if (window.location.hash !== hash) return;
3779
+ let shell = __retiring_shell__;
3780
+ if (shell) {
3781
+ let resting = resting_route_of(shell);
3782
+ try {
3783
+ window.history.replaceState(window.history.state, "", route_to_hash(resting));
3784
+ } catch (e) {
3785
+ (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: unparking '${route}' at stop failed: ${e}`);
3786
+ }
3787
+ return;
3788
+ }
3789
+ window.history.back();
3790
+ }
3791
+ /************************************************************
3792
+ * The resting route a shell shows under its overlays: the
3793
+ * current one (only ever written for a RESTING route), else
3794
+ * the main stage's, else the default.
3795
+ ************************************************************/
3796
+ function resting_route_of(gobj) {
3797
+ let priv = gobj.priv || {};
3798
+ return (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "current_route") || priv.stages && priv.stages.main && priv.stages.main.active_route || (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "default_route") || "/";
3747
3799
  }
3748
3800
  /************************************************************
3749
3801
  * Avatar provider — toolbar items with type:"avatar" call the
@@ -5089,9 +5141,8 @@ function build_ui$18(gobj) {
5089
5141
  if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "auto_save_size_and_position")) {
5090
5142
  if ((0, _yuneta_gobj_js.gobj_is_service)(gobj)) {
5091
5143
  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) {
5144
+ let rect = whole_rect((0, _yuneta_gobj_js.kw_get_local_storage_value)(key));
5145
+ if (!rect && local_storage_holds(key)) {
5095
5146
  (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
5147
  (0, _yuneta_gobj_js.kw_remove_local_storage_value)(key);
5097
5148
  } else if (rect && (rect.width <= 0 || rect.height <= 0)) {
@@ -5538,6 +5589,17 @@ function min$1(gobj) {
5538
5589
  return rect;
5539
5590
  }
5540
5591
  /************************************************************
5592
+ * Whether localStorage holds anything under `key`, readable
5593
+ * or not.
5594
+ ************************************************************/
5595
+ function local_storage_holds(key) {
5596
+ try {
5597
+ return window.localStorage.getItem(key) !== null;
5598
+ } catch (e) {
5599
+ return false;
5600
+ }
5601
+ }
5602
+ /************************************************************
5541
5603
  * The rect of a window in whole pixels: x, y, width and height
5542
5604
  * are DTP_INTEGER, and getBoundingClientRect() answers fractions
5543
5605
  * under a zoom or a device pixel ratio (an integer attr refuses
@@ -7866,8 +7928,14 @@ function yui_tabulator_name_filters(table, t) {
7866
7928
  * from `yui_tabulator_relocalize()` so a language change
7867
7929
  * reaches them.
7868
7930
  *
7869
- * It matches Tabulator's OWN literal and only that, so a box a
7870
- * view named itself is left alone.
7931
+ * It matches Tabulator's OWN literal, and the boxes it named itself
7932
+ * (they carry `data-yui-row-select`), so a box a view named itself is
7933
+ * left alone. Up to 7.26.46 it matched only the literal: a box named
7934
+ * once was never found again, and a language change through
7935
+ * yui_tabulator_relocalize() left it in the old language.
7936
+ *
7937
+ * The box in the HEADER selects every row, and is named so
7938
+ * ("select all rows"); up to 7.26.46 it was "select row" too.
7871
7939
  ***************************************************************/
7872
7940
  var TABULATOR_ROW_SELECT_ARIA = "Select Row";
7873
7941
  function yui_tabulator_name_row_selects(table, t) {
@@ -7878,12 +7946,16 @@ function yui_tabulator_name_row_selects(table, t) {
7878
7946
  (0, _yuneta_gobj_js.log_warning)("yui_tabulator_name_row_selects: table has no element: its row-selection boxes keep Tabulator's English name");
7879
7947
  return;
7880
7948
  }
7881
- let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"]`);
7949
+ let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"], input[type=checkbox][data-yui-row-select]`);
7882
7950
  for (let $box of boxes) {
7883
- $box.setAttribute("aria-label", t("select row"));
7884
- $box.setAttribute("data-i18n-aria-label", "select row");
7885
- $box.setAttribute("title", t("select row"));
7886
- $box.setAttribute("data-i18n-title", "select row");
7951
+ let all = typeof $box.closest === "function" && !!$box.closest(".tabulator-header");
7952
+ let name = all ? t("select all rows") : t("select row");
7953
+ let key = all ? "select all rows" : "select row";
7954
+ $box.setAttribute("aria-label", name);
7955
+ $box.setAttribute("data-i18n-aria-label", key);
7956
+ $box.setAttribute("title", name);
7957
+ $box.setAttribute("data-i18n-title", key);
7958
+ $box.setAttribute("data-yui-row-select", "");
7887
7959
  }
7888
7960
  } catch (e) {}
7889
7961
  }
@@ -9736,6 +9808,44 @@ function datetime_local_to_epoch(value) {
9736
9808
  if (isNaN(date.getTime())) return null;
9737
9809
  return Math.floor(date.getTime() / 1e3);
9738
9810
  }
9811
+ /************************************************************
9812
+ * The value of a time column -> a Date, or null when it holds
9813
+ * none. A `string` column holds an ISO text, any other an epoch
9814
+ * in SECONDS. The form's time field and the cell editor of a
9815
+ * table read it here, so the two agree: up to gobj-ui 7.26.46 the
9816
+ * field read every column with parseInt -- an ISO text as the
9817
+ * year 2026 in SECONDS, in January 1970 -- and showed an empty
9818
+ * one as January 1970 too, which a save then wrote back as 0.
9819
+ ************************************************************/
9820
+ function time_value_to_date(value, real_type) {
9821
+ if (value === null || value === void 0 || value === "") return null;
9822
+ let date = real_type === "string" ? new Date(String(value)) : /* @__PURE__ */ new Date(Number(value) * 1e3);
9823
+ return isNaN(date.getTime()) ? null : date;
9824
+ }
9825
+ /************************************************************
9826
+ * An epoch in seconds (null: no time) -> the value of a time
9827
+ * column: an ISO text for a `string` column, the epoch for any
9828
+ * other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
9829
+ * `string` column too.
9830
+ ************************************************************/
9831
+ function epoch_to_time_value(epoch, real_type) {
9832
+ if (epoch === null || epoch === void 0) return null;
9833
+ if (typeof epoch !== "number" || !Number.isFinite(epoch)) return epoch;
9834
+ if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
9835
+ return epoch;
9836
+ }
9837
+ /************************************************************
9838
+ * The value of a time column as a table cell shows it: the
9839
+ * local clock the editor opens on, "YYYY-MM-DD HH:mm:ss", as
9840
+ * fmt_epoch() of yui_time.js writes a timestamp in a table. ""
9841
+ * for no time; a value that is not one is shown as it is, so the
9842
+ * reader sees what the column holds.
9843
+ ************************************************************/
9844
+ function time_value_to_text(value, real_type) {
9845
+ let date = time_value_to_date(value, real_type);
9846
+ if (!date) return value === null || value === void 0 ? "" : String(value);
9847
+ return date_to_datetime_local(date).replace("T", " ");
9848
+ }
9739
9849
  //#endregion
9740
9850
  //#region src/form_time_cell_editor.js
9741
9851
  /****************************************************************************
@@ -9763,6 +9873,17 @@ function datetime_local_to_epoch(value) {
9763
9873
  * Escape cancels, `verticalNavigation: "editor"` keeps the
9764
9874
  * arrows, and a value that did not change is a cancel.
9765
9875
  *
9876
+ * A date with a part cleared is NOT a value: the box answers
9877
+ * `value ""` for it, as for an empty box, and only
9878
+ * `validity.badInput` tells them apart. Enter leaves the
9879
+ * editor open with `aria-invalid` until the date is whole
9880
+ * again (or Escape); a blur cancels, and the cell keeps what
9881
+ * it had. Up to gobj-ui 7.26.46 both committed null: one
9882
+ * Backspace and Enter erased the stored time. To clear a time
9883
+ * on purpose, clear EVERY part of the box: an empty box
9884
+ * commits null. (Inside the box Tab moves between its parts,
9885
+ * as the browser does: it does not leave the cell.)
9886
+ *
9766
9887
  * Copyright (c) 2026, ArtGins.
9767
9888
  * All Rights Reserved.
9768
9889
  ****************************************************************************/
@@ -9770,20 +9891,13 @@ function datetime_local_to_epoch(value) {
9770
9891
  * A cell's value -> the text of the box ("" when empty).
9771
9892
  ************************************************************/
9772
9893
  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));
9894
+ return date_to_datetime_local(time_value_to_date(value, real_type));
9778
9895
  }
9779
9896
  /************************************************************
9780
9897
  * The text of the box -> the cell's value (null when empty).
9781
9898
  ************************************************************/
9782
9899
  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;
9900
+ return epoch_to_time_value(datetime_local_to_epoch(text), real_type);
9787
9901
  }
9788
9902
  /************************************************************
9789
9903
  * The editor of a time column whose values are `real_type`
@@ -9810,7 +9924,15 @@ function form_time_cell_editor(real_type) {
9810
9924
  input.style.height = "100%";
9811
9925
  }
9812
9926
  });
9813
- let commit = function() {
9927
+ let incomplete = function() {
9928
+ return !!(input.validity && input.validity.badInput);
9929
+ };
9930
+ let commit = function(from_blur) {
9931
+ if (incomplete()) {
9932
+ if (from_blur) cancel();
9933
+ else input.setAttribute("aria-invalid", "true");
9934
+ return;
9935
+ }
9814
9936
  if (input.value === original_text) {
9815
9937
  cancel();
9816
9938
  return;
@@ -9823,12 +9945,15 @@ function form_time_cell_editor(real_type) {
9823
9945
  success(value);
9824
9946
  };
9825
9947
  input.addEventListener("blur", function(e) {
9826
- if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit();
9948
+ if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit(true);
9949
+ });
9950
+ input.addEventListener("input", function() {
9951
+ if (!incomplete()) input.removeAttribute("aria-invalid");
9827
9952
  });
9828
9953
  input.addEventListener("keydown", function(e) {
9829
9954
  switch (e.key) {
9830
9955
  case "Enter":
9831
- commit();
9956
+ commit(false);
9832
9957
  break;
9833
9958
  case "Escape":
9834
9959
  cancel();
@@ -10273,7 +10398,7 @@ var attrs_table$17 = [
10273
10398
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
10274
10399
  (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"),
10275
10400
  (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`)"),
10401
+ (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 (hidden while the form is not `selectable`)"),
10277
10402
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
10278
10403
  (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"),
10279
10404
  (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"),
@@ -10295,7 +10420,9 @@ var PRIVATE_DATA$17 = {
10295
10420
  tables: null,
10296
10421
  table_seq: 0,
10297
10422
  json_names_posted: false,
10298
- lang_shell: null
10423
+ lang_shell: null,
10424
+ change_seq: 0,
10425
+ cell_edit: null
10299
10426
  };
10300
10427
  var __gclass__$17 = null;
10301
10428
  /***************************
@@ -10314,6 +10441,16 @@ function mt_create$17(gobj) {
10314
10441
  build_ui$15(gobj);
10315
10442
  }
10316
10443
  /************************************************************
10444
+ * Framework Method writing
10445
+ ************************************************************/
10446
+ function mt_writing$2(gobj, path) {
10447
+ if (path === "selectable") {
10448
+ let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
10449
+ if (!$container) return;
10450
+ for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) if ($table.tabulator) show_row_selection(gobj, $table.tabulator);
10451
+ }
10452
+ }
10453
+ /************************************************************
10317
10454
  * Framework Method destroy
10318
10455
  * In this point, all children
10319
10456
  * and subscriptions are already deleted.
@@ -10351,6 +10488,7 @@ function mt_stop$17(gobj) {
10351
10488
  * not switched here: they always say it (create_tabulator).
10352
10489
  ************************************************************/
10353
10490
  function set_changed_stated(gobj, changed) {
10491
+ gobj.priv.change_seq += 1;
10354
10492
  let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
10355
10493
  $container.querySelector("form");
10356
10494
  const enable = ($btn, on, color) => {
@@ -10915,6 +11053,9 @@ function build_form(gobj) {
10915
11053
  id: form_id,
10916
11054
  class: "yui-form"
10917
11055
  }]);
11056
+ $form.addEventListener("submit", function(ev) {
11057
+ ev.preventDefault();
11058
+ });
10918
11059
  let template = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "template");
10919
11060
  if (!(0, _yuneta_gobj_js.is_object)(template) && !(0, _yuneta_gobj_js.is_array)(template)) {
10920
11061
  $form.appendChild((0, _yuneta_gobj_js.createOneHtml)(template));
@@ -11426,6 +11567,7 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
11426
11567
  "button",
11427
11568
  {
11428
11569
  class: "button p-1",
11570
+ type: "button",
11429
11571
  title: (0, i18next.t)("add"),
11430
11572
  "data-i18n-title": "add",
11431
11573
  "aria-label": (0, i18next.t)("add"),
@@ -12005,6 +12147,22 @@ function create_coordinates(gobj, attrs) {
12005
12147
  return $extend;
12006
12148
  }
12007
12149
  /******************************************************************
12150
+ * Show the checkbox column of a table while the form is
12151
+ * `selectable`, hide it while it is not. The column is the table's
12152
+ * row header, the first of its structured columns. A table not
12153
+ * built yet does it when it is (tableBuilt).
12154
+ ******************************************************************/
12155
+ function show_row_selection(gobj, tabulator) {
12156
+ if (!(0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "with_checkbox") || !tabulator.initialized) return;
12157
+ let column = tabulator.getColumns(true).find((c) => c.getDefinition().formatter === "rowSelection");
12158
+ if (!column) {
12159
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the table has no checkbox column to show or hide`);
12160
+ return;
12161
+ }
12162
+ if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable")) column.show();
12163
+ else column.hide();
12164
+ }
12165
+ /******************************************************************
12008
12166
  * Create tabulator
12009
12167
  *
12010
12168
  * A row builds its nested tables the first time it is drawn, each
@@ -12034,11 +12192,13 @@ function create_coordinates(gobj, attrs) {
12034
12192
  * `"highlight"` is left as it is, hover and all.
12035
12193
  *
12036
12194
  * 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.
12195
+ * not shown while the form is not selectable: Tabulator's row box
12196
+ * ticks before its toggle is refused (a ticked box over a row not
12197
+ * selected), and its header box selects every row asking nothing. Up
12198
+ * to 7.26.45 the boxes were drawn and lied; with the default
12199
+ * `selectableRows` they selected whatever `selectable` said. Up to
12200
+ * 7.26.46 `selectable` was read when the table was built; the column
12201
+ * now follows every write of it (mt_writing, show_row_selection).
12042
12202
  *
12043
12203
  * A click in a nested table stays there: it bubbled to the row that
12044
12204
  * holds the table, whose own click listener (SelectRow's) toggled
@@ -12104,14 +12264,15 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
12104
12264
  cell.getRow().delete();
12105
12265
  }
12106
12266
  });
12107
- if (with_checkbox && (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable")) tabulator_settings.rowHeader = {
12267
+ if (with_checkbox) tabulator_settings.rowHeader = {
12108
12268
  formatter: "rowSelection",
12109
12269
  titleFormatter: "rowSelection",
12110
12270
  headerSort: false,
12111
12271
  resizable: false,
12112
12272
  frozen: true,
12113
12273
  headerHozAlign: "center",
12114
- hozAlign: "center"
12274
+ hozAlign: "center",
12275
+ visible: (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable")
12115
12276
  };
12116
12277
  let tabulator = new tabulator_tables.TabulatorFull($extend, tabulator_settings);
12117
12278
  tabulator.on("dataChanged", function() {
@@ -12121,10 +12282,19 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
12121
12282
  $extend.addEventListener("input", function(ev) {
12122
12283
  let $target = ev.target;
12123
12284
  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);
12285
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", { typed_in: table_identity(gobj, $extend) }, gobj);
12286
+ });
12287
+ tabulator.on("cellEditing", function() {
12288
+ if ((0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) return;
12289
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CELL_EDIT_OPENED", { table_id: table_identity(gobj, $extend) }, gobj);
12290
+ });
12291
+ tabulator.on("cellEditCancelled", function() {
12292
+ if ((0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) return;
12293
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_CELL_EDIT_CANCELLED", { table_id: table_identity(gobj, $extend) }, gobj);
12125
12294
  });
12126
12295
  $extend.yui_pending_rows = null;
12127
12296
  tabulator.on("tableBuilt", function() {
12297
+ show_row_selection(gobj, tabulator);
12128
12298
  let rows = $extend.yui_pending_rows;
12129
12299
  $extend.yui_pending_rows = null;
12130
12300
  if (rows && !(0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_LOAD_TABLE_ROWS", {
@@ -12279,6 +12449,9 @@ function template2columns(gobj, columns, template, sub_elements) {
12279
12449
  case "time":
12280
12450
  column.editor = form_time_cell_editor(field_desc.real_type);
12281
12451
  column.editorParams = { verticalNavigation: "table" };
12452
+ column.formatter = function(cell) {
12453
+ return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
12454
+ };
12282
12455
  break;
12283
12456
  case "color":
12284
12457
  column.editor = "input";
@@ -12766,7 +12939,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
12766
12939
  case "url": break;
12767
12940
  case "now":
12768
12941
  case "time":
12769
- value = /* @__PURE__ */ new Date((parseInt(value) || 0) * 1e3);
12942
+ value = time_value_to_date(value, field_desc.real_type);
12770
12943
  break;
12771
12944
  case "date":
12772
12945
  case "color":
@@ -12860,10 +13033,9 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
12860
13033
  case "time":
12861
13034
  switch (real_type) {
12862
13035
  case "string":
12863
- if (value && (0, _yuneta_gobj_js.is_date)(value)) value = value.toISOString();
12864
- break;
12865
13036
  case "integer":
12866
- if (value && (0, _yuneta_gobj_js.is_date)(value)) value = value.getTime() / 1e3;
13037
+ if ((0, _yuneta_gobj_js.is_date)(value)) value = Math.floor(value.getTime() / 1e3);
13038
+ value = epoch_to_time_value(value, real_type);
12867
13039
  break;
12868
13040
  default: (0, _yuneta_gobj_js.log_error)("incompatible type for time: " + real_type);
12869
13041
  }
@@ -13111,7 +13283,44 @@ function ac_load_table_rows(gobj, event, kw, src) {
13111
13283
  * Internal event
13112
13284
  ************************************************************/
13113
13285
  function ac_record_changed(gobj, event, kw, src) {
13114
- if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "initialized")) set_edited_by_reader(gobj);
13286
+ if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "initialized")) {
13287
+ let priv = gobj.priv;
13288
+ let open = priv.cell_edit;
13289
+ let own = !!(open && kw && kw.typed_in === open.table_id && open.seq === priv.change_seq);
13290
+ set_edited_by_reader(gobj);
13291
+ if (own) open.seq = priv.change_seq;
13292
+ }
13293
+ return 0;
13294
+ }
13295
+ /************************************************************
13296
+ * A cell editor opened, in the table `table_id`: what the form
13297
+ * says now is what a cancel of it gives back.
13298
+ ************************************************************/
13299
+ function ac_cell_edit_opened(gobj, event, kw, src) {
13300
+ let priv = gobj.priv;
13301
+ priv.cell_edit = {
13302
+ table_id: kw.table_id,
13303
+ edited: (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "edited"),
13304
+ changes: (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "changes"),
13305
+ seq: priv.change_seq
13306
+ };
13307
+ return 0;
13308
+ }
13309
+ /************************************************************
13310
+ * A cell editor cancelled -- Escape, or a box left as it was:
13311
+ * the value comes back, and so do the `edited` and `changes` the
13312
+ * form had when it opened. Up to gobj-ui 7.26.46 what was typed
13313
+ * in it still counted, and closing asked about a change that was
13314
+ * gone. Nothing is given back when anything but that editor's
13315
+ * own typing changed the form meanwhile: that change is real.
13316
+ ************************************************************/
13317
+ function ac_cell_edit_cancelled(gobj, event, kw, src) {
13318
+ let priv = gobj.priv;
13319
+ let open = priv.cell_edit;
13320
+ priv.cell_edit = null;
13321
+ if (!open || open.table_id !== kw.table_id || open.seq !== priv.change_seq) return 0;
13322
+ if ((0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "changes") !== open.changes) set_changed_stated(gobj, open.changes);
13323
+ (0, _yuneta_gobj_js.gobj_write_bool_attr)(gobj, "edited", open.edited);
13115
13324
  return 0;
13116
13325
  }
13117
13326
  /************************************************************
@@ -13255,6 +13464,7 @@ function cmd_get_picked_files(gobj, cmd, kw, src) {
13255
13464
  }
13256
13465
  var gmt$17 = {
13257
13466
  mt_create: mt_create$17,
13467
+ mt_writing: mt_writing$2,
13258
13468
  mt_start: mt_start$17,
13259
13469
  mt_stop: mt_stop$17,
13260
13470
  mt_destroy: mt_destroy$17,
@@ -13304,6 +13514,16 @@ function create_gclass$17(gclass_name) {
13304
13514
  ac_record_changed,
13305
13515
  null
13306
13516
  ],
13517
+ [
13518
+ "EV_CELL_EDIT_OPENED",
13519
+ ac_cell_edit_opened,
13520
+ null
13521
+ ],
13522
+ [
13523
+ "EV_CELL_EDIT_CANCELLED",
13524
+ ac_cell_edit_cancelled,
13525
+ null
13526
+ ],
13307
13527
  [
13308
13528
  "EV_COPY_RECORD",
13309
13529
  ac_copy_record,
@@ -13373,6 +13593,8 @@ function create_gclass$17(gclass_name) {
13373
13593
  ["EV_ADD_TABLE_ROW", 0],
13374
13594
  ["EV_LOAD_TABLE_ROWS", 0],
13375
13595
  ["EV_RECORD_CHANGED", 0],
13596
+ ["EV_CELL_EDIT_OPENED", 0],
13597
+ ["EV_CELL_EDIT_CANCELLED", 0],
13376
13598
  ["EV_COPY_RECORD", 0],
13377
13599
  ["EV_PASTE_RECORD", 0],
13378
13600
  ["EV_SET_FILE_PREVIEW", 0],
@@ -32482,8 +32704,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
32482
32704
  switch (field_desc.real_type) {
32483
32705
  case "string":
32484
32706
  case "integer":
32485
- value = parseInt(value) || 0;
32486
- value = /* @__PURE__ */ new Date(value * 1e3);
32707
+ value = time_value_to_date(value, field_desc.real_type);
32708
+ if (!value) {
32709
+ value = "";
32710
+ break;
32711
+ }
32487
32712
  const rawLocale = navigator.language;
32488
32713
  const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
32489
32714
  const formatter = new Intl.DateTimeFormat(userLocale, {