@yuneta/gobj-ui 7.26.45 → 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.
package/README.md CHANGED
@@ -214,6 +214,24 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
214
214
  > the dialog), and every Tab after that "wrapped" to it, did nothing and was
215
215
  > prevented -- the keyboard never got into a dialog. It now skips a control
216
216
  > that is not drawn.
217
+ >
218
+ > **A shell that stops closes what it has open (7.26.46).** A logout, or a
219
+ > session cut, with the drawer, a modal or a question up: the shell closes
220
+ > each one, the top first, as if it had been dismissed -- a modal's `on_close`
221
+ > runs (its `before_close` is not asked: that guard is for the reader), a
222
+ > question answers what Escape answers. Up to 7.26.45 only the toolbar
223
+ > dropdown was closed; the others kept their focus trap, and every window
224
+ > opened afterwards believed itself under an overlay and took no focus. An
225
+ > overlay of the app that uses the shell's Escape chain passes its
226
+ > unconditional close as the fourth argument, or it is left to its owner:
227
+ >
228
+ > ```js
229
+ > yui_shell_push_escape(shell, "modal", ask_then_close, close_now);
230
+ > ```
231
+ >
232
+ > And a trap whose panel left the document without being released is dropped,
233
+ > said in the log, the next time the stack is read: it no longer stands for an
234
+ > overlay that is gone.
217
235
 
218
236
  ## Two maintained lines
219
237
 
@@ -3630,6 +3648,21 @@ opened changed did not hear its tables at all, so closing it lost a table edit
3630
3648
  without a question. And the titles of those tables change language with the
3631
3649
  shell's `EV_LANGUAGE_CHANGED` (7.26.41+), like the rest of the form.
3632
3650
 
3651
+ What the reader TYPES in a cell editor is `edited` at once (7.26.46+), as in a
3652
+ field of the form: Tabulator says `dataChanged` only when the editor commits,
3653
+ so up to 7.26.45 a half-typed cell was not edited, and a host that asks
3654
+ `edited` before it reloads or closes the form by code dropped it without a
3655
+ question. A reload or a close by code still discards the open editor (it is
3656
+ cancelled before the rows go): asking is the host's part, and `edited` is
3657
+ what tells it to.
3658
+
3659
+ A `time` / `now` column of a table is edited in a `datetime-local` box, to the
3660
+ second, read and written as the form's own time field is (`form_time_value.js`:
3661
+ an epoch in seconds, or an ISO text for a string column). Up to 7.26.45 it was
3662
+ Tabulator's `datetime` editor with a luxon `format`, and nothing gives gobj-ui
3663
+ luxon: it opened empty and threw when committed. Luxon is not taken in for one
3664
+ editor.
3665
+
3633
3666
  A table hears the reader through Tabulator's `dataChanged`, which Tabulator
3634
3667
  does not say for `setData()` / `replaceData()`, nor when its `history` module
3635
3668
  undoes or redoes a cell edit or a row move (`Ctrl+Z`; a row added or deleted
@@ -3706,6 +3739,12 @@ so it governs the row's own click, which toggles the row (a row drawn while it
3706
3739
  was `false` stays unselectable until it is drawn again). With the defaults
3707
3740
  nothing is selected.
3708
3741
 
3742
+ The checkbox column (`with_checkbox`) asks `selectable` too, and is not drawn
3743
+ when the form is not selectable (7.26.46): Tabulator's row box ticks before its
3744
+ toggle is refused, and its header box selects every row without asking. A
3745
+ click in a NESTED table selects in that table only; it bubbled up to the row
3746
+ holding the table, which toggled too.
3747
+
3709
3748
  ```js
3710
3749
  gobj_create("form", "C_YUI_FORM", {
3711
3750
  template: template,
@@ -4001,14 +4040,24 @@ range raised by hand), and leaves it when it did (the round run twice, a
4001
4040
  package.json two apps share): the package.json's git history says which, and
4002
4041
  one whose history cannot be read is refused (since `7.26.43`; up to `7.26.42`
4003
4042
  a refused app kept the files raised before the refusal, `--no-wait` could
4004
- lower a range, and "already" deployed a new bundle under the old number). The
4005
- commit that brought the range is the newest one whose parent has ANOTHER
4006
- range, and a shallow clone is refused, since it may not hold that parent; its
4043
+ lower a range, and "already" deployed a new bundle under the old number). Its
4007
4044
  log line says `range already ^x.y.z, version raised` (since `7.26.45`; up to
4008
- `7.26.44` a commit that only reformatted the line was taken for the one, so a
4009
- round run again raised the version twice, a shallow clone whose HEAD raised
4010
- the range by hand was taken for "born with the range" and deployed under the
4011
- old number, and the line said `range raised`).
4045
+ `7.26.44` it said `range raised`, a commit that only reformatted the line made
4046
+ a round run again raise the version twice, and a shallow clone whose HEAD
4047
+ raised the range by hand deployed under the old number).
4048
+
4049
+ The history is read by its VALUES (since `7.26.46`): the version is raised when
4050
+ ANY state the package.json had -- every branch merged in, a merge that combines
4051
+ two sides, a rename followed to the old name -- carries it with another range,
4052
+ since a number that stood beside another range may have gone out with it. A
4053
+ shallow clone is read as far as it goes when the oldest state it holds does not
4054
+ carry the range yet (a clone of depth 2 holding the commit before the raise);
4055
+ one cut where the range was already raised is refused, and the message says
4056
+ `git fetch --unshallow`. Up to `7.26.45` the round read ONE commit, the one
4057
+ that brought the range, so a merge of a branch that raised the range by hand,
4058
+ next to a version raised on main with the old range, deployed under that
4059
+ version, and a package.json MOVED after a hand raise was taken for one born
4060
+ with the range; and `7.26.45` refused every shallow clone.
4012
4061
 
4013
4062
  ### Colour: a brand token as INK takes `-on-scheme`, as a FILL it does not
4014
4063
 
@@ -4372,6 +4421,12 @@ reader reads --, called as `t(k)`, `t?.(k)`, `t.call(x, k)` or
4372
4421
  `t.apply(x, [k])`, and `.call`, `.apply` and `.bind` written as computed
4373
4422
  members too (`t["call"](x, k)`, `t["bind"](null, k)`, since `7.26.45`; up to
4374
4423
  `7.26.44` those forms were not read, and a key handed that way went unasked).
4424
+ Since `7.26.46` a computed member is read by a const name and by a template as
4425
+ well (``t[`call`](x, k)``, `t[M](x, k)` with `const M = "call"`, `i18next[T](k)`
4426
+ with `const T = "t"`), and so is a SPREAD of an array the source writes out:
4427
+ `t(...["k"])`, `t.call(x, ...["k"])`, `t(...KEYS)` and `t.apply(x, KEYS)` with
4428
+ `const KEYS = ["k"]` -- each element of the const read as `KEYS[0]`,
4429
+ `KEYS[1]`... (up to `7.26.45` none of them was read, and nothing failed).
4375
4430
  An ARRAY given to it is i18next's list of fallback keys, and
4376
4431
  each one is a key: `t([specific, "generic"])` asks for "generic". A `.bind()`
4377
4432
  that binds a KEY makes a translator whose calls hand i18next its options or its
@@ -4595,7 +4650,11 @@ member): an import under any name, a re-export from a file of the app
4595
4650
  a const alias (`const show = yui_shell_show_info`), a map in a const
4596
4651
  (`const API = {info: yui_shell_show_info}; API.info(...)`, imported too),
4597
4652
  `.call(x, ...)` and `.apply(x, [...])` (also as computed members,
4598
- `f["call"](x, ...)`, since `7.26.45`); and a `.bind()` of it is read as the
4653
+ `f["call"](x, ...)`, since `7.26.45`; by a const name or a template, `f[M](x,
4654
+ ...)`, and with a spread or an `.apply()` of an array the source writes out,
4655
+ `f(shell, ...["k"])`, `f.apply(x, ARGS)` with `const ARGS = [shell, "k"]`,
4656
+ since `7.26.46` -- up to `7.26.45` such a spread failed the rule per call, and
4657
+ `f[M](...)` was not read); and a `.bind()` of it is read as the
4599
4658
  call it prepares, at the positions it binds (since `7.26.43`):
4600
4659
  `yui_shell_show_info.bind(null, shell, "k")` asks for "k", and a parameter
4601
4660
  bound there fails the rule per call as it does when it is handed directly. Up
@@ -5068,7 +5127,13 @@ reading the page in another language:
5068
5127
  that no const or import makes an alias of -- a parameter `translate`, a
5069
5128
  `let` alias, `opts.translate(k)`, `i18next.getFixedT()` --, or one called
5070
5129
  through what is no name of it: `(0, t)(k)`, `[t][0](k)`,
5071
- `Reflect.apply(t, x, [k])`, `Function.prototype.call.call(t, x, k)`;
5130
+ `Reflect.apply(t, x, [k])`, `Function.prototype.call.call(t, x, k)`, or by
5131
+ a computed name the reader does not follow to ONE string (`t[m](x, k)` with
5132
+ `m` a parameter or a `let`, `t[c()? "call" : "apply"]`);
5133
+ - a key handed to a translator in a spread of what is no array the source
5134
+ writes out (`t(...args)`, `t.apply(x, args)` with `args` a parameter, a
5135
+ `let`, or a const whose array holds a spread or a hole): from the spread on,
5136
+ no position is known;
5072
5137
  - a translator handed to a FUNCTION (`{t: t}`, `yui_tabulator_lang(t)`,
5073
5138
  `run(t)`) or to any method but those listed above (`keys.reduce(t)`,
5074
5139
  `keys.sort(t)`, an alias of a method, `Reflect.apply()`): only those
@@ -5081,8 +5146,10 @@ reading the page in another language:
5081
5146
  not, and so does one a `const` holds (below);
5082
5147
  - a key function reached through a parameter (`apply(fn)` calling
5083
5148
  `fn(shell, "k")`), a `let` given more than one function, a map in a `let`,
5084
- a computed member (`API[name](...)`), or `.apply()` of an array the source
5085
- does not write out;
5149
+ or a computed member whose name the reader does not follow to one string
5150
+ (`API[name](...)` with `name` a parameter or a `let`). An `.apply()` of an
5151
+ array the source does not write out, or a spread of one, is not invisible:
5152
+ it FAILS the rule per call, since no position from it on is known;
5086
5153
  - a `data-i18n*` attribute written through an alias of `dataset`
5087
5154
  (`const ds = el.dataset; ds.i18nTitle = k`), by `Object.assign()` into it,
5088
5155
  or named by a `let`;
@@ -5148,8 +5215,11 @@ reading the page in another language:
5148
5215
 
5149
5216
  Since `7.26.45` the line said is the one of the READ, with the place the
5150
5217
  count went past 24 (`src/main.js:30: the reader gave up on \`J16\` (past
5151
- \`K10\`, src/main.js:12), ...`), and the verdict does not depend on the
5152
- order of the code: a const, a property, an element and the returns of a
5218
+ \`K2\`, src/main.js:4), ...`): the first node the read reaches at step 25,
5219
+ the same whatever was read before (since `7.26.46`; in `7.26.45` it was the
5220
+ const read before, kept, when the count went past inside it -- `K10` with
5221
+ `t(K10)` above the read, `K2` without). The verdict does not depend on the
5222
+ order of the code either: a const, a property, an element and the returns of a
5153
5223
  function are read once and keep the steps they took, so a later read of them
5154
5224
  counts those steps too. Up to `7.26.44` a const kept what its FIRST read had
5155
5225
  reached -- with `J0 = K10` and `J16` 28 consts away from the key, `t(J16);
@@ -5166,7 +5236,10 @@ validated, and nobody told. A file of the locales directory with a locale's
5166
5236
  name that does not look like one (`app.js`, a helper that needs a browser to
5167
5237
  load) is said and skipped, as before. The script runs the same when it is
5168
5238
  reached through a symlinked package with `--preserve-symlinks-main` (also from
5169
- `NODE_OPTIONS`): both sides of its "am I the script?" test are resolved.
5239
+ `NODE_OPTIONS`): both sides of its "am I the script?" test are resolved. A
5240
+ locale is IMPORTED, so its code runs: the script ends itself once what it wrote
5241
+ has left, and a timer a locale leaves running does not hold the build (since
5242
+ `7.26.46`; up to `7.26.45` it held it for ever, a failing run included).
5170
5243
 
5171
5244
  Up to `7.26.24` each app carried its own copy, and the copies had drifted into
5172
5245
  three families: only one read the codes of the schema editor, only the other
@@ -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;
@@ -189,6 +206,9 @@ function activate_focus_trap_on($panel, doc) {
189
206
  }
190
207
  };
191
208
  trap.$panel = $panel;
209
+ trap.detach = function() {
210
+ doc.removeEventListener("keydown", trap, true);
211
+ };
192
212
  doc.addEventListener("keydown", trap, true);
193
213
  __trap_stack__.push(trap);
194
214
  let firstFocusable = focusables_of($panel)[0];
@@ -210,6 +230,7 @@ function activate_focus_trap_on($panel, doc) {
210
230
  * where it cannot be seen, and the next Tab would give it back.
211
231
  ***************************************************************/
212
232
  function focus_trap_panel() {
233
+ drop_detached_traps();
213
234
  let top = __trap_stack__[__trap_stack__.length - 1];
214
235
  return top ? top.$panel : null;
215
236
  }
@@ -1416,6 +1437,7 @@ function mt_start$21(gobj) {
1416
1437
  function mt_stop$20(gobj) {
1417
1438
  let priv = gobj.priv;
1418
1439
  if (!priv) return 0;
1440
+ close_overlays(gobj);
1419
1441
  close_toolbar_dropdown(gobj);
1420
1442
  if (priv.hash_handler) {
1421
1443
  window.removeEventListener("hashchange", priv.hash_handler);
@@ -1470,6 +1492,7 @@ function mt_stop$20(gobj) {
1470
1492
  * Framework Method: Destroy
1471
1493
  ***************************************************************/
1472
1494
  function mt_destroy$22(gobj) {
1495
+ close_overlays(gobj);
1473
1496
  close_toolbar_dropdown(gobj);
1474
1497
  let live_idx = __live_shells__.indexOf(gobj);
1475
1498
  if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
@@ -2570,7 +2593,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger) {
2570
2593
  $panel.__yui_backdrop_handler__ = backdrop;
2571
2594
  $panel.__yui_dismiss_handler__ = dismiss;
2572
2595
  $panel.__yui_trigger__ = $trigger || null;
2573
- push_escape(gobj, "popup", close_fn);
2596
+ push_escape(gobj, "popup", close_fn, close_fn);
2574
2597
  $panel.__yui_focus_release__ = activate_focus_trap_on($panel);
2575
2598
  if ($trigger) $trigger.setAttribute("aria-expanded", "true");
2576
2599
  priv.active_dropdown = $panel;
@@ -2735,8 +2758,12 @@ function take_back_focus(ev) {
2735
2758
  * only and consumes the event; LIFO ordering naturally matches
2736
2759
  * the z-index layering most apps use (drawer at the bottom,
2737
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).
2738
2765
  ************************************************************/
2739
- function push_escape(gobj, layer, handler) {
2766
+ function push_escape(gobj, layer, handler, teardown) {
2740
2767
  let priv = gobj.priv;
2741
2768
  if (!priv || !priv.escape_stack) {
2742
2769
  (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: push_escape('${layer}') on a shell that is gone: Escape will not close it`);
@@ -2746,9 +2773,34 @@ function push_escape(gobj, layer, handler) {
2746
2773
  priv.escape_stack.push({
2747
2774
  layer,
2748
2775
  handler,
2776
+ teardown: typeof teardown === "function" ? teardown : null,
2749
2777
  seq: priv.escape_seq
2750
2778
  });
2751
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
+ }
2752
2804
  function pop_escape(gobj, handler) {
2753
2805
  let priv = gobj.priv;
2754
2806
  if (!priv || !priv.escape_stack) return;
@@ -2958,7 +3010,7 @@ function open_drawer_one(gobj, $c) {
2958
3010
  if ($c.classList.contains("is-active")) return;
2959
3011
  let close_fn = () => close_drawer_one(gobj, $c);
2960
3012
  $c.__yui_close_handler__ = close_fn;
2961
- push_escape(gobj, "overlay", close_fn);
3013
+ push_escape(gobj, "overlay", close_fn, close_fn);
2962
3014
  $c.classList.add("is-active");
2963
3015
  $c.__yui_focus_release__ = activate_focus_trap_on($c.querySelector(".yui-drawer-panel") || $c);
2964
3016
  }
@@ -3660,8 +3712,8 @@ function yui_shell_close_drawer(shell_gobj, menu_id) {
3660
3712
  function yui_shell_toggle_drawer(shell_gobj, menu_id) {
3661
3713
  toggle_drawer(shell_gobj, menu_id);
3662
3714
  }
3663
- function yui_shell_push_escape(shell_gobj, layer, handler) {
3664
- 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);
3665
3717
  }
3666
3718
  function yui_shell_pop_escape(shell_gobj, handler) {
3667
3719
  pop_escape(shell_gobj, handler);
@@ -4270,7 +4322,7 @@ function yui_shell_show_modal(shell, content, opts) {
4270
4322
  });
4271
4323
  };
4272
4324
  escape_handler = request_close;
4273
- yui_shell_push_escape(shell, "modal", request_close);
4325
+ yui_shell_push_escape(shell, "modal", request_close, do_close);
4274
4326
  overlay = yui_shell_register_overlay(shell, on_back);
4275
4327
  release_focus = activate_focus_trap_on($modal);
4276
4328
  if (opts == null || opts.dismiss_on_background !== false) $modal.querySelector(".modal-background").addEventListener("click", request_close);
@@ -4425,7 +4477,7 @@ function build_dialog(shell, message, buttons, opts) {
4425
4477
  resolve(value);
4426
4478
  };
4427
4479
  close_fn = () => close(dismiss_value);
4428
- yui_shell_push_escape(shell, "modal", close_fn);
4480
+ yui_shell_push_escape(shell, "modal", close_fn, close_fn);
4429
4481
  overlay = yui_shell_register_overlay(shell, close_fn);
4430
4482
  release_focus = activate_focus_trap_on($modal.querySelector(".modal-card"));
4431
4483
  $modal.querySelector(".modal-background").addEventListener("click", () => close(dismiss_value));
@@ -5039,7 +5091,14 @@ function build_ui$18(gobj) {
5039
5091
  let key = `${(0, _yuneta_gobj_js.gobj_name)(gobj)}-rect`;
5040
5092
  let stored = (0, _yuneta_gobj_js.kw_get_local_storage_value)(key);
5041
5093
  let rect = whole_rect(stored);
5042
- if (!rect && stored != null) (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`);
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
+ }
5043
5102
  if (rect) {
5044
5103
  rect.x = rect.x < 0 ? 0 : rect.x;
5045
5104
  rect.y = rect.y < 0 ? 0 : rect.y;
@@ -9678,6 +9737,117 @@ function datetime_local_to_epoch(value) {
9678
9737
  return Math.floor(date.getTime() / 1e3);
9679
9738
  }
9680
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
9681
9851
  //#region src/form_json_field.js
9682
9852
  /***********************************************************************
9683
9853
  * form_json_field.js
@@ -10103,7 +10273,7 @@ var attrs_table$17 = [
10103
10273
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
10104
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"),
10105
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)"),
10106
- (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"),
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`)"),
10107
10277
  (0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
10108
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"),
10109
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"),
@@ -10520,10 +10690,28 @@ function destroy_widget(gobj, what, widget) {
10520
10690
  * walks the rows already wiped: a reload, a Clear or a destroy
10521
10691
  * with an editor open in any row but the first threw, and left
10522
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.
10523
10699
  ************************************************************/
10524
- function close_table_editor(tabulator) {
10700
+ function close_table_editor(gobj, tabulator) {
10525
10701
  let edit = tabulator.modules ? tabulator.modules.edit : null;
10526
- if (edit && edit.currentCell) edit.cancelEdit();
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;
10527
10715
  }
10528
10716
  /************************************************************
10529
10717
  * A table element that is gone: its identity is no table now,
@@ -10546,7 +10734,7 @@ function destroy_row_tables(gobj, $row) {
10546
10734
  $row.yui_nested = null;
10547
10735
  for (let $nested of nested) {
10548
10736
  if ($nested.tabulator) {
10549
- close_table_editor($nested.tabulator);
10737
+ close_table_editor(gobj, $nested.tabulator);
10550
10738
  destroy_rows_tables(gobj, $nested.tabulator);
10551
10739
  destroy_widget(gobj, "nested table", $nested.tabulator);
10552
10740
  $nested.tabulator = null;
@@ -10579,7 +10767,7 @@ function destroy_widgets(gobj, $container) {
10579
10767
  $el.jsoneditor = null;
10580
10768
  }
10581
10769
  if ($el.tabulator) {
10582
- close_table_editor($el.tabulator);
10770
+ close_table_editor(gobj, $el.tabulator);
10583
10771
  destroy_rows_tables(gobj, $el.tabulator);
10584
10772
  destroy_widget(gobj, "table", $el.tabulator);
10585
10773
  $el.tabulator = null;
@@ -11844,13 +12032,25 @@ function create_coordinates(gobj, attrs) {
11844
12032
  * the form's `selectable` -- first. Up to 7.26.44 the form toggled
11845
12033
  * the row again in `rowClick`, which undid every click. The default
11846
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.
11847
12046
  ******************************************************************/
11848
12047
  function create_tabulator$1(gobj, $extend, name, template, rows) {
11849
12048
  $extend.template = template;
11850
12049
  let tabulator_settings = (0, _yuneta_gobj_js.json_deep_copy)((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator_settings"));
11851
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");
11852
12052
  let selectable_rows = tabulator_settings.selectableRows;
11853
- if (selectable_rows === true || typeof selectable_rows === "number") tabulator_settings.selectableRowsCheck = function() {
12053
+ if (selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) tabulator_settings.selectableRowsCheck = function() {
11854
12054
  return (0, _yuneta_gobj_js.gobj_read_bool_attr)(gobj, "selectable");
11855
12055
  };
11856
12056
  let columns = [];
@@ -11877,6 +12077,12 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
11877
12077
  "name": sub_element.name
11878
12078
  }];
11879
12079
  let $extend = (0, _yuneta_gobj_js.createElement2)(extend);
12080
+ $extend.addEventListener("click", function(ev) {
12081
+ ev.stopPropagation();
12082
+ });
12083
+ $extend.addEventListener("mousedown", function(ev) {
12084
+ if (ev.shiftKey) ev.stopPropagation();
12085
+ });
11880
12086
  let rows = data[sub_element.name];
11881
12087
  $extend.tabulator = create_tabulator$1(gobj, $extend, sub_element.name, sub_element.template, rows);
11882
12088
  $row.appendChild($extend);
@@ -11898,7 +12104,7 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
11898
12104
  cell.getRow().delete();
11899
12105
  }
11900
12106
  });
11901
- 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 = {
11902
12108
  formatter: "rowSelection",
11903
12109
  titleFormatter: "rowSelection",
11904
12110
  headerSort: false,
@@ -11912,6 +12118,11 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
11912
12118
  if (gobj.priv.loading_rows > 0) return;
11913
12119
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", {}, gobj);
11914
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
+ });
11915
12126
  $extend.yui_pending_rows = null;
11916
12127
  tabulator.on("tableBuilt", function() {
11917
12128
  let rows = $extend.yui_pending_rows;
@@ -12066,13 +12277,8 @@ function template2columns(gobj, columns, template, sub_elements) {
12066
12277
  break;
12067
12278
  case "now":
12068
12279
  case "time":
12069
- column.editor = "datetime";
12070
- column.editorParams = {
12071
- format: "dd/MM/yyyy hh:mm",
12072
- verticalNavigation: "table",
12073
- elementAttributes: { title: (0, i18next.t)("slide bar to choose option") }
12074
- };
12075
- field_desc.real_type;
12280
+ column.editor = form_time_cell_editor(field_desc.real_type);
12281
+ column.editorParams = { verticalNavigation: "table" };
12076
12282
  break;
12077
12283
  case "color":
12078
12284
  column.editor = "input";
@@ -12363,7 +12569,7 @@ function clear_data(gobj, $form) {
12363
12569
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
12364
12570
  $table.yui_pending_rows = null;
12365
12571
  if ($table.tabulator.initialized) {
12366
- close_table_editor($table.tabulator);
12572
+ close_table_editor(gobj, $table.tabulator);
12367
12573
  destroy_rows_tables(gobj, $table.tabulator);
12368
12574
  $table.tabulator.clearData();
12369
12575
  }