@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.
@@ -134,12 +134,15 @@ 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
- * 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.
137
+ * A trap whose panel is out of the document is not the top:
138
+ * the top is the highest trap whose panel is in it. Up to
139
+ * gobj-ui 7.26.45 a trap left behind by an owner torn down with
140
+ * it stayed the top: every window opened later believed itself
141
+ * under an overlay and took no focus, and a live trap under it
142
+ * no longer heard Tab. 7.26.46 dropped such a trap from the
143
+ * stack, which was for good: a panel that only moved (taken out
144
+ * and put back, its trap never released) lost its trap. It is
145
+ * skipped now, and leaves the stack only by its release().
143
146
  *
144
147
  * No gobj dependency: only gobj-js's logger. The optional
145
148
  * second argument lets callers inject a mock document object
@@ -150,14 +153,12 @@ function yui_tint(colour) {
150
153
  ***********************************************************************/
151
154
  var FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
152
155
  var __trap_stack__ = [];
153
- function drop_detached_traps() {
156
+ function top_trap() {
154
157
  for (let i = __trap_stack__.length - 1; i >= 0; i--) {
155
158
  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)");
159
+ if (trap.$panel.isConnected !== false) return trap;
160
160
  }
161
+ return null;
161
162
  }
162
163
  function is_drawn(el) {
163
164
  if (typeof el.checkVisibility === "function") return el.checkVisibility();
@@ -183,8 +184,7 @@ function activate_focus_trap_on($panel, doc) {
183
184
  let released = false;
184
185
  let trap = function(ev) {
185
186
  if (ev.key !== "Tab" && ev.keyCode !== 9) return;
186
- drop_detached_traps();
187
- if (__trap_stack__[__trap_stack__.length - 1] !== trap) return;
187
+ if (top_trap() !== trap) return;
188
188
  let nodes = focusables_of($panel);
189
189
  if (nodes.length === 0) return;
190
190
  let first = nodes[0];
@@ -201,9 +201,6 @@ function activate_focus_trap_on($panel, doc) {
201
201
  }
202
202
  };
203
203
  trap.$panel = $panel;
204
- trap.detach = function() {
205
- doc.removeEventListener("keydown", trap, true);
206
- };
207
204
  doc.addEventListener("keydown", trap, true);
208
205
  __trap_stack__.push(trap);
209
206
  let firstFocusable = focusables_of($panel)[0];
@@ -225,8 +222,7 @@ function activate_focus_trap_on($panel, doc) {
225
222
  * where it cannot be seen, and the next Tab would give it back.
226
223
  ***************************************************************/
227
224
  function focus_trap_panel() {
228
- drop_detached_traps();
229
- let top = __trap_stack__[__trap_stack__.length - 1];
225
+ let top = top_trap();
230
226
  return top ? top.$panel : null;
231
227
  }
232
228
  //#endregion
@@ -1214,6 +1210,7 @@ function secondary_nav_renders(item, layout) {
1214
1210
  ***************************************************************/
1215
1211
  var GCLASS_NAME$22 = "C_YUI_SHELL";
1216
1212
  var __live_shells__ = [];
1213
+ var __retiring_shell__ = null;
1217
1214
  var __shell_watchers__ = [];
1218
1215
  var __window_z__ = 10;
1219
1216
  var ZONE_IDS = [
@@ -1432,7 +1429,7 @@ function mt_start$21(gobj) {
1432
1429
  function mt_stop$20(gobj) {
1433
1430
  let priv = gobj.priv;
1434
1431
  if (!priv) return 0;
1435
- close_overlays(gobj);
1432
+ retire_overlays(gobj);
1436
1433
  close_toolbar_dropdown(gobj);
1437
1434
  if (priv.hash_handler) {
1438
1435
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -1487,7 +1484,7 @@ function mt_stop$20(gobj) {
1487
1484
  * Framework Method: Destroy
1488
1485
  ***************************************************************/
1489
1486
  function mt_destroy$22(gobj) {
1490
- close_overlays(gobj);
1487
+ retire_overlays(gobj);
1491
1488
  close_toolbar_dropdown(gobj);
1492
1489
  let live_idx = __live_shells__.indexOf(gobj);
1493
1490
  if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
@@ -2796,6 +2793,31 @@ function close_overlays(gobj) {
2796
2793
  }
2797
2794
  }
2798
2795
  }
2796
+ /************************************************************
2797
+ * What a shell that stops does with its overlays: their
2798
+ * history markers are left where they are, and then they are
2799
+ * closed (close_overlays). The overlay stack is emptied FIRST,
2800
+ * so no close -- of an overlay closed here, or of a window
2801
+ * closed later -- retires its marker with a history.back().
2802
+ * Such a back() is asynchronous and a stopped shell no longer
2803
+ * hears where it lands: up to gobj-ui 7.26.46 a logout followed
2804
+ * by a new shell in the same turn had it taken by the new
2805
+ * shell's first window (Chromium stepped back off that window's
2806
+ * marker, Firefox dropped the back()), and the next Back left
2807
+ * the page. A marker left in place is inert, as a drained one
2808
+ * is: a later Back lands on it and is absorbed.
2809
+ ************************************************************/
2810
+ function retire_overlays(gobj) {
2811
+ let priv = gobj.priv;
2812
+ if (priv && priv.overlay_stack) priv.overlay_stack.splice(0);
2813
+ let outer = __retiring_shell__;
2814
+ __retiring_shell__ = gobj;
2815
+ try {
2816
+ close_overlays(gobj);
2817
+ } finally {
2818
+ __retiring_shell__ = outer;
2819
+ }
2820
+ }
2799
2821
  function pop_escape(gobj, handler) {
2800
2822
  let priv = gobj.priv;
2801
2823
  if (!priv || !priv.escape_stack) return;
@@ -3736,9 +3758,39 @@ function yui_shell_overlay_dismissed(shell_gobj, overlay) {
3736
3758
  * stranded action entries and RE-FIRES the action, reopening
3737
3759
  * the overlay and hijacking the navigation the user asked
3738
3760
  * for. Only back() while the URL still sits on the route.
3761
+ *
3762
+ * A close that comes from a shell that STOPS (a logout with the
3763
+ * overlay up) does not go back: the URL is rewritten in place,
3764
+ * to the resting route under the overlay. A back() is
3765
+ * asynchronous and the stopped shell would never hear where it
3766
+ * lands -- the overlay's own marker is left in place, so a
3767
+ * single back() landed on the action entry, the URL stayed on
3768
+ * the action route, and a new shell built in the same turn read
3769
+ * it and opened the overlay again (up to gobj-ui 7.26.47).
3739
3770
  ************************************************************/
3740
3771
  function yui_shell_unpark_route(route) {
3741
- if (window.location.hash === route_to_hash(normalize_route(route))) window.history.back();
3772
+ let hash = route_to_hash(normalize_route(route));
3773
+ if (window.location.hash !== hash) return;
3774
+ let shell = __retiring_shell__;
3775
+ if (shell) {
3776
+ let resting = resting_route_of(shell);
3777
+ try {
3778
+ window.history.replaceState(window.history.state, "", route_to_hash(resting));
3779
+ } catch (e) {
3780
+ log_warning(`C_YUI_SHELL: unparking '${route}' at stop failed: ${e}`);
3781
+ }
3782
+ return;
3783
+ }
3784
+ window.history.back();
3785
+ }
3786
+ /************************************************************
3787
+ * The resting route a shell shows under its overlays: the
3788
+ * current one (only ever written for a RESTING route), else
3789
+ * the main stage's, else the default.
3790
+ ************************************************************/
3791
+ function resting_route_of(gobj) {
3792
+ let priv = gobj.priv || {};
3793
+ return gobj_read_attr(gobj, "current_route") || priv.stages && priv.stages.main && priv.stages.main.active_route || gobj_read_attr(gobj, "default_route") || "/";
3742
3794
  }
3743
3795
  /************************************************************
3744
3796
  * Avatar provider — toolbar items with type:"avatar" call the
@@ -5084,9 +5136,8 @@ function build_ui$18(gobj) {
5084
5136
  if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
5085
5137
  if (gobj_is_service(gobj)) {
5086
5138
  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) {
5139
+ let rect = whole_rect(kw_get_local_storage_value(key));
5140
+ if (!rect && local_storage_holds(key)) {
5090
5141
  log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
5091
5142
  kw_remove_local_storage_value(key);
5092
5143
  } else if (rect && (rect.width <= 0 || rect.height <= 0)) {
@@ -5533,6 +5584,17 @@ function min$1(gobj) {
5533
5584
  return rect;
5534
5585
  }
5535
5586
  /************************************************************
5587
+ * Whether localStorage holds anything under `key`, readable
5588
+ * or not.
5589
+ ************************************************************/
5590
+ function local_storage_holds(key) {
5591
+ try {
5592
+ return window.localStorage.getItem(key) !== null;
5593
+ } catch (e) {
5594
+ return false;
5595
+ }
5596
+ }
5597
+ /************************************************************
5536
5598
  * The rect of a window in whole pixels: x, y, width and height
5537
5599
  * are DTP_INTEGER, and getBoundingClientRect() answers fractions
5538
5600
  * under a zoom or a device pixel ratio (an integer attr refuses
@@ -7861,8 +7923,14 @@ function yui_tabulator_name_filters(table, t) {
7861
7923
  * from `yui_tabulator_relocalize()` so a language change
7862
7924
  * reaches them.
7863
7925
  *
7864
- * It matches Tabulator's OWN literal and only that, so a box a
7865
- * view named itself is left alone.
7926
+ * It matches Tabulator's OWN literal, and the boxes it named itself
7927
+ * (they carry `data-yui-row-select`), so a box a view named itself is
7928
+ * left alone. Up to 7.26.46 it matched only the literal: a box named
7929
+ * once was never found again, and a language change through
7930
+ * yui_tabulator_relocalize() left it in the old language.
7931
+ *
7932
+ * The box in the HEADER selects every row, and is named so
7933
+ * ("select all rows"); up to 7.26.46 it was "select row" too.
7866
7934
  ***************************************************************/
7867
7935
  var TABULATOR_ROW_SELECT_ARIA = "Select Row";
7868
7936
  function yui_tabulator_name_row_selects(table, t) {
@@ -7873,12 +7941,16 @@ function yui_tabulator_name_row_selects(table, t) {
7873
7941
  log_warning("yui_tabulator_name_row_selects: table has no element: its row-selection boxes keep Tabulator's English name");
7874
7942
  return;
7875
7943
  }
7876
- let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"]`);
7944
+ let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"], input[type=checkbox][data-yui-row-select]`);
7877
7945
  for (let $box of boxes) {
7878
- $box.setAttribute("aria-label", t("select row"));
7879
- $box.setAttribute("data-i18n-aria-label", "select row");
7880
- $box.setAttribute("title", t("select row"));
7881
- $box.setAttribute("data-i18n-title", "select row");
7946
+ let all = typeof $box.closest === "function" && !!$box.closest(".tabulator-header");
7947
+ let name = all ? t("select all rows") : t("select row");
7948
+ let key = all ? "select all rows" : "select row";
7949
+ $box.setAttribute("aria-label", name);
7950
+ $box.setAttribute("data-i18n-aria-label", key);
7951
+ $box.setAttribute("title", name);
7952
+ $box.setAttribute("data-i18n-title", key);
7953
+ $box.setAttribute("data-yui-row-select", "");
7882
7954
  }
7883
7955
  } catch (e) {}
7884
7956
  }
@@ -9731,6 +9803,44 @@ function datetime_local_to_epoch(value) {
9731
9803
  if (isNaN(date.getTime())) return null;
9732
9804
  return Math.floor(date.getTime() / 1e3);
9733
9805
  }
9806
+ /************************************************************
9807
+ * The value of a time column -> a Date, or null when it holds
9808
+ * none. A `string` column holds an ISO text, any other an epoch
9809
+ * in SECONDS. The form's time field and the cell editor of a
9810
+ * table read it here, so the two agree: up to gobj-ui 7.26.46 the
9811
+ * field read every column with parseInt -- an ISO text as the
9812
+ * year 2026 in SECONDS, in January 1970 -- and showed an empty
9813
+ * one as January 1970 too, which a save then wrote back as 0.
9814
+ ************************************************************/
9815
+ function time_value_to_date(value, real_type) {
9816
+ if (value === null || value === void 0 || value === "") return null;
9817
+ let date = real_type === "string" ? new Date(String(value)) : /* @__PURE__ */ new Date(Number(value) * 1e3);
9818
+ return isNaN(date.getTime()) ? null : date;
9819
+ }
9820
+ /************************************************************
9821
+ * An epoch in seconds (null: no time) -> the value of a time
9822
+ * column: an ISO text for a `string` column, the epoch for any
9823
+ * other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
9824
+ * `string` column too.
9825
+ ************************************************************/
9826
+ function epoch_to_time_value(epoch, real_type) {
9827
+ if (epoch === null || epoch === void 0) return null;
9828
+ if (typeof epoch !== "number" || !Number.isFinite(epoch)) return epoch;
9829
+ if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
9830
+ return epoch;
9831
+ }
9832
+ /************************************************************
9833
+ * The value of a time column as a table cell shows it: the
9834
+ * local clock the editor opens on, "YYYY-MM-DD HH:mm:ss", as
9835
+ * fmt_epoch() of yui_time.js writes a timestamp in a table. ""
9836
+ * for no time; a value that is not one is shown as it is, so the
9837
+ * reader sees what the column holds.
9838
+ ************************************************************/
9839
+ function time_value_to_text(value, real_type) {
9840
+ let date = time_value_to_date(value, real_type);
9841
+ if (!date) return value === null || value === void 0 ? "" : String(value);
9842
+ return date_to_datetime_local(date).replace("T", " ");
9843
+ }
9734
9844
  //#endregion
9735
9845
  //#region src/form_time_cell_editor.js
9736
9846
  /****************************************************************************
@@ -9758,6 +9868,17 @@ function datetime_local_to_epoch(value) {
9758
9868
  * Escape cancels, `verticalNavigation: "editor"` keeps the
9759
9869
  * arrows, and a value that did not change is a cancel.
9760
9870
  *
9871
+ * A date with a part cleared is NOT a value: the box answers
9872
+ * `value ""` for it, as for an empty box, and only
9873
+ * `validity.badInput` tells them apart. Enter leaves the
9874
+ * editor open with `aria-invalid` until the date is whole
9875
+ * again (or Escape); a blur cancels, and the cell keeps what
9876
+ * it had. Up to gobj-ui 7.26.46 both committed null: one
9877
+ * Backspace and Enter erased the stored time. To clear a time
9878
+ * on purpose, clear EVERY part of the box: an empty box
9879
+ * commits null. (Inside the box Tab moves between its parts,
9880
+ * as the browser does: it does not leave the cell.)
9881
+ *
9761
9882
  * Copyright (c) 2026, ArtGins.
9762
9883
  * All Rights Reserved.
9763
9884
  ****************************************************************************/
@@ -9765,20 +9886,13 @@ function datetime_local_to_epoch(value) {
9765
9886
  * A cell's value -> the text of the box ("" when empty).
9766
9887
  ************************************************************/
9767
9888
  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));
9889
+ return date_to_datetime_local(time_value_to_date(value, real_type));
9773
9890
  }
9774
9891
  /************************************************************
9775
9892
  * The text of the box -> the cell's value (null when empty).
9776
9893
  ************************************************************/
9777
9894
  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;
9895
+ return epoch_to_time_value(datetime_local_to_epoch(text), real_type);
9782
9896
  }
9783
9897
  /************************************************************
9784
9898
  * The editor of a time column whose values are `real_type`
@@ -9805,7 +9919,15 @@ function form_time_cell_editor(real_type) {
9805
9919
  input.style.height = "100%";
9806
9920
  }
9807
9921
  });
9808
- let commit = function() {
9922
+ let incomplete = function() {
9923
+ return !!(input.validity && input.validity.badInput);
9924
+ };
9925
+ let commit = function(from_blur) {
9926
+ if (incomplete()) {
9927
+ if (from_blur) cancel();
9928
+ else input.setAttribute("aria-invalid", "true");
9929
+ return;
9930
+ }
9809
9931
  if (input.value === original_text) {
9810
9932
  cancel();
9811
9933
  return;
@@ -9818,12 +9940,15 @@ function form_time_cell_editor(real_type) {
9818
9940
  success(value);
9819
9941
  };
9820
9942
  input.addEventListener("blur", function(e) {
9821
- if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit();
9943
+ if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit(true);
9944
+ });
9945
+ input.addEventListener("input", function() {
9946
+ if (!incomplete()) input.removeAttribute("aria-invalid");
9822
9947
  });
9823
9948
  input.addEventListener("keydown", function(e) {
9824
9949
  switch (e.key) {
9825
9950
  case "Enter":
9826
- commit();
9951
+ commit(false);
9827
9952
  break;
9828
9953
  case "Escape":
9829
9954
  cancel();
@@ -10268,7 +10393,7 @@ var attrs_table$17 = [
10268
10393
  SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
10269
10394
  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"),
10270
10395
  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`)"),
10396
+ SDATA(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`)"),
10272
10397
  SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
10273
10398
  SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
10274
10399
  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"),
@@ -10290,7 +10415,9 @@ var PRIVATE_DATA$17 = {
10290
10415
  tables: null,
10291
10416
  table_seq: 0,
10292
10417
  json_names_posted: false,
10293
- lang_shell: null
10418
+ lang_shell: null,
10419
+ change_seq: 0,
10420
+ cell_edit: null
10294
10421
  };
10295
10422
  var __gclass__$17 = null;
10296
10423
  /***************************
@@ -10309,6 +10436,16 @@ function mt_create$17(gobj) {
10309
10436
  build_ui$15(gobj);
10310
10437
  }
10311
10438
  /************************************************************
10439
+ * Framework Method writing
10440
+ ************************************************************/
10441
+ function mt_writing$2(gobj, path) {
10442
+ if (path === "selectable") {
10443
+ let $container = gobj_read_attr(gobj, "$container");
10444
+ if (!$container) return;
10445
+ for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) if ($table.tabulator) show_row_selection(gobj, $table.tabulator);
10446
+ }
10447
+ }
10448
+ /************************************************************
10312
10449
  * Framework Method destroy
10313
10450
  * In this point, all children
10314
10451
  * and subscriptions are already deleted.
@@ -10346,6 +10483,7 @@ function mt_stop$17(gobj) {
10346
10483
  * not switched here: they always say it (create_tabulator).
10347
10484
  ************************************************************/
10348
10485
  function set_changed_stated(gobj, changed) {
10486
+ gobj.priv.change_seq += 1;
10349
10487
  let $container = gobj_read_attr(gobj, "$container");
10350
10488
  $container.querySelector("form");
10351
10489
  const enable = ($btn, on, color) => {
@@ -10910,6 +11048,9 @@ function build_form(gobj) {
10910
11048
  id: form_id,
10911
11049
  class: "yui-form"
10912
11050
  }]);
11051
+ $form.addEventListener("submit", function(ev) {
11052
+ ev.preventDefault();
11053
+ });
10913
11054
  let template = gobj_read_attr(gobj, "template");
10914
11055
  if (!is_object(template) && !is_array(template)) {
10915
11056
  $form.appendChild(createOneHtml(template));
@@ -11421,6 +11562,7 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
11421
11562
  "button",
11422
11563
  {
11423
11564
  class: "button p-1",
11565
+ type: "button",
11424
11566
  title: t("add"),
11425
11567
  "data-i18n-title": "add",
11426
11568
  "aria-label": t("add"),
@@ -12000,6 +12142,22 @@ function create_coordinates(gobj, attrs) {
12000
12142
  return $extend;
12001
12143
  }
12002
12144
  /******************************************************************
12145
+ * Show the checkbox column of a table while the form is
12146
+ * `selectable`, hide it while it is not. The column is the table's
12147
+ * row header, the first of its structured columns. A table not
12148
+ * built yet does it when it is (tableBuilt).
12149
+ ******************************************************************/
12150
+ function show_row_selection(gobj, tabulator) {
12151
+ if (!gobj_read_bool_attr(gobj, "with_checkbox") || !tabulator.initialized) return;
12152
+ let column = tabulator.getColumns(true).find((c) => c.getDefinition().formatter === "rowSelection");
12153
+ if (!column) {
12154
+ log_error(`${gobj_short_name(gobj)}: the table has no checkbox column to show or hide`);
12155
+ return;
12156
+ }
12157
+ if (gobj_read_bool_attr(gobj, "selectable")) column.show();
12158
+ else column.hide();
12159
+ }
12160
+ /******************************************************************
12003
12161
  * Create tabulator
12004
12162
  *
12005
12163
  * A row builds its nested tables the first time it is drawn, each
@@ -12029,11 +12187,13 @@ function create_coordinates(gobj, attrs) {
12029
12187
  * `"highlight"` is left as it is, hover and all.
12030
12188
  *
12031
12189
  * 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.
12190
+ * not shown while the form is not selectable: Tabulator's row box
12191
+ * ticks before its toggle is refused (a ticked box over a row not
12192
+ * selected), and its header box selects every row asking nothing. Up
12193
+ * to 7.26.45 the boxes were drawn and lied; with the default
12194
+ * `selectableRows` they selected whatever `selectable` said. Up to
12195
+ * 7.26.46 `selectable` was read when the table was built; the column
12196
+ * now follows every write of it (mt_writing, show_row_selection).
12037
12197
  *
12038
12198
  * A click in a nested table stays there: it bubbled to the row that
12039
12199
  * holds the table, whose own click listener (SelectRow's) toggled
@@ -12099,14 +12259,15 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
12099
12259
  cell.getRow().delete();
12100
12260
  }
12101
12261
  });
12102
- if (with_checkbox && gobj_read_bool_attr(gobj, "selectable")) tabulator_settings.rowHeader = {
12262
+ if (with_checkbox) tabulator_settings.rowHeader = {
12103
12263
  formatter: "rowSelection",
12104
12264
  titleFormatter: "rowSelection",
12105
12265
  headerSort: false,
12106
12266
  resizable: false,
12107
12267
  frozen: true,
12108
12268
  headerHozAlign: "center",
12109
- hozAlign: "center"
12269
+ hozAlign: "center",
12270
+ visible: gobj_read_bool_attr(gobj, "selectable")
12110
12271
  };
12111
12272
  let tabulator = new TabulatorFull($extend, tabulator_settings);
12112
12273
  tabulator.on("dataChanged", function() {
@@ -12116,10 +12277,19 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
12116
12277
  $extend.addEventListener("input", function(ev) {
12117
12278
  let $target = ev.target;
12118
12279
  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);
12280
+ gobj_send_event(gobj, "EV_RECORD_CHANGED", { typed_in: table_identity(gobj, $extend) }, gobj);
12281
+ });
12282
+ tabulator.on("cellEditing", function() {
12283
+ if (gobj_is_destroying(gobj)) return;
12284
+ gobj_send_event(gobj, "EV_CELL_EDIT_OPENED", { table_id: table_identity(gobj, $extend) }, gobj);
12285
+ });
12286
+ tabulator.on("cellEditCancelled", function() {
12287
+ if (gobj_is_destroying(gobj)) return;
12288
+ gobj_send_event(gobj, "EV_CELL_EDIT_CANCELLED", { table_id: table_identity(gobj, $extend) }, gobj);
12120
12289
  });
12121
12290
  $extend.yui_pending_rows = null;
12122
12291
  tabulator.on("tableBuilt", function() {
12292
+ show_row_selection(gobj, tabulator);
12123
12293
  let rows = $extend.yui_pending_rows;
12124
12294
  $extend.yui_pending_rows = null;
12125
12295
  if (rows && !gobj_is_destroying(gobj)) gobj_send_event(gobj, "EV_LOAD_TABLE_ROWS", {
@@ -12274,6 +12444,9 @@ function template2columns(gobj, columns, template, sub_elements) {
12274
12444
  case "time":
12275
12445
  column.editor = form_time_cell_editor(field_desc.real_type);
12276
12446
  column.editorParams = { verticalNavigation: "table" };
12447
+ column.formatter = function(cell) {
12448
+ return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
12449
+ };
12277
12450
  break;
12278
12451
  case "color":
12279
12452
  column.editor = "input";
@@ -12761,7 +12934,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
12761
12934
  case "url": break;
12762
12935
  case "now":
12763
12936
  case "time":
12764
- value = /* @__PURE__ */ new Date((parseInt(value) || 0) * 1e3);
12937
+ value = time_value_to_date(value, field_desc.real_type);
12765
12938
  break;
12766
12939
  case "date":
12767
12940
  case "color":
@@ -12855,10 +13028,9 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
12855
13028
  case "time":
12856
13029
  switch (real_type) {
12857
13030
  case "string":
12858
- if (value && is_date(value)) value = value.toISOString();
12859
- break;
12860
13031
  case "integer":
12861
- if (value && is_date(value)) value = value.getTime() / 1e3;
13032
+ if (is_date(value)) value = Math.floor(value.getTime() / 1e3);
13033
+ value = epoch_to_time_value(value, real_type);
12862
13034
  break;
12863
13035
  default: log_error("incompatible type for time: " + real_type);
12864
13036
  }
@@ -13106,7 +13278,44 @@ function ac_load_table_rows(gobj, event, kw, src) {
13106
13278
  * Internal event
13107
13279
  ************************************************************/
13108
13280
  function ac_record_changed(gobj, event, kw, src) {
13109
- if (gobj_read_bool_attr(gobj, "initialized")) set_edited_by_reader(gobj);
13281
+ if (gobj_read_bool_attr(gobj, "initialized")) {
13282
+ let priv = gobj.priv;
13283
+ let open = priv.cell_edit;
13284
+ let own = !!(open && kw && kw.typed_in === open.table_id && open.seq === priv.change_seq);
13285
+ set_edited_by_reader(gobj);
13286
+ if (own) open.seq = priv.change_seq;
13287
+ }
13288
+ return 0;
13289
+ }
13290
+ /************************************************************
13291
+ * A cell editor opened, in the table `table_id`: what the form
13292
+ * says now is what a cancel of it gives back.
13293
+ ************************************************************/
13294
+ function ac_cell_edit_opened(gobj, event, kw, src) {
13295
+ let priv = gobj.priv;
13296
+ priv.cell_edit = {
13297
+ table_id: kw.table_id,
13298
+ edited: gobj_read_bool_attr(gobj, "edited"),
13299
+ changes: gobj_read_bool_attr(gobj, "changes"),
13300
+ seq: priv.change_seq
13301
+ };
13302
+ return 0;
13303
+ }
13304
+ /************************************************************
13305
+ * A cell editor cancelled -- Escape, or a box left as it was:
13306
+ * the value comes back, and so do the `edited` and `changes` the
13307
+ * form had when it opened. Up to gobj-ui 7.26.46 what was typed
13308
+ * in it still counted, and closing asked about a change that was
13309
+ * gone. Nothing is given back when anything but that editor's
13310
+ * own typing changed the form meanwhile: that change is real.
13311
+ ************************************************************/
13312
+ function ac_cell_edit_cancelled(gobj, event, kw, src) {
13313
+ let priv = gobj.priv;
13314
+ let open = priv.cell_edit;
13315
+ priv.cell_edit = null;
13316
+ if (!open || open.table_id !== kw.table_id || open.seq !== priv.change_seq) return 0;
13317
+ if (gobj_read_bool_attr(gobj, "changes") !== open.changes) set_changed_stated(gobj, open.changes);
13318
+ gobj_write_bool_attr(gobj, "edited", open.edited);
13110
13319
  return 0;
13111
13320
  }
13112
13321
  /************************************************************
@@ -13250,6 +13459,7 @@ function cmd_get_picked_files(gobj, cmd, kw, src) {
13250
13459
  }
13251
13460
  var gmt$17 = {
13252
13461
  mt_create: mt_create$17,
13462
+ mt_writing: mt_writing$2,
13253
13463
  mt_start: mt_start$17,
13254
13464
  mt_stop: mt_stop$17,
13255
13465
  mt_destroy: mt_destroy$17,
@@ -13299,6 +13509,16 @@ function create_gclass$17(gclass_name) {
13299
13509
  ac_record_changed,
13300
13510
  null
13301
13511
  ],
13512
+ [
13513
+ "EV_CELL_EDIT_OPENED",
13514
+ ac_cell_edit_opened,
13515
+ null
13516
+ ],
13517
+ [
13518
+ "EV_CELL_EDIT_CANCELLED",
13519
+ ac_cell_edit_cancelled,
13520
+ null
13521
+ ],
13302
13522
  [
13303
13523
  "EV_COPY_RECORD",
13304
13524
  ac_copy_record,
@@ -13368,6 +13588,8 @@ function create_gclass$17(gclass_name) {
13368
13588
  ["EV_ADD_TABLE_ROW", 0],
13369
13589
  ["EV_LOAD_TABLE_ROWS", 0],
13370
13590
  ["EV_RECORD_CHANGED", 0],
13591
+ ["EV_CELL_EDIT_OPENED", 0],
13592
+ ["EV_CELL_EDIT_CANCELLED", 0],
13371
13593
  ["EV_COPY_RECORD", 0],
13372
13594
  ["EV_PASTE_RECORD", 0],
13373
13595
  ["EV_SET_FILE_PREVIEW", 0],
@@ -32477,8 +32699,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
32477
32699
  switch (field_desc.real_type) {
32478
32700
  case "string":
32479
32701
  case "integer":
32480
- value = parseInt(value) || 0;
32481
- value = /* @__PURE__ */ new Date(value * 1e3);
32702
+ value = time_value_to_date(value, field_desc.real_type);
32703
+ if (!value) {
32704
+ value = "";
32705
+ break;
32706
+ }
32482
32707
  const rawLocale = navigator.language;
32483
32708
  const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
32484
32709
  const formatter = new Intl.DateTimeFormat(userLocale, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.46",
3
+ "version": "7.26.48",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",