@yuneta/gobj-ui 7.26.56 → 7.26.58

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
@@ -4199,10 +4199,14 @@ and reads back the bundle each host serves (`--check` only reads back,
4199
4199
  `--only <name>` does one app, `--no-wait` skips the registry). The private
4200
4200
  consumers are listed in `~/.yuneta/gobj-ui-consumers.json` (see
4201
4201
  `scripts/gobj-ui-consumers.example.json`); the demo (`test-app/`) is built in.
4202
- It is built from the working tree, so it goes out only from a clean tree whose
4203
- HEAD is the commit `origin/main` holds on the remote; otherwise it is `NOT
4204
- DEPLOYED`, with the reason, and the round exits 1 (since `7.26.55`; up to
4205
- `7.26.54` any copy of the repo, on any commit, deployed the public demo).
4202
+ It is built from the working trees of this repo and of the sibling `gobj-js`
4203
+ (`test-app/vite.config.js` bundles `../../gobj-js/src`), so it goes out only
4204
+ when each is a clean tree of its own (untracked files count; a copy with no
4205
+ `.git` inside another repo is refused) whose HEAD is the commit `origin/main`
4206
+ holds on the remote; otherwise it is `NOT DEPLOYED`, with the reason, and the
4207
+ round exits 1 (since `7.26.55`, the sibling `gobj-js` since `7.26.57`; up to
4208
+ `7.26.54` any copy of the repo, on any commit, deployed the public demo). The
4209
+ demo's target is named `test-app` (`--only test-app`).
4206
4210
 
4207
4211
  An app whose range cannot be raised safely is refused and left as it was --
4208
4212
  every package.json of it, since all are checked before any is written: a
@@ -9916,7 +9916,7 @@ function is_time_field(field) {
9916
9916
  /************************************************************
9917
9917
  * Format an epoch value as a local wall-clock string, 24
9918
9918
  * hours, in the APP's language `locale` (fmt_date_time() of
9919
- * yui_time.js, as the time cells of the forms and tables;
9919
+ * yui_date_text.js, as the time cells of the forms and tables;
9920
9920
  * up to gobj-ui 7.26.51 it was toLocaleString(): the
9921
9921
  * browser's language, and 12 hours in English).
9922
9922
  * Accepts seconds or milliseconds; returns null when the
@@ -10196,7 +10196,7 @@ function epoch_to_time_value(epoch, real_type) {
10196
10196
  /************************************************************
10197
10197
  * The value of a time column as a table cell shows it: the
10198
10198
  * local clock, 24 hours, in the APP's language `locale`
10199
- * (fmt_date_time() of yui_time.js: es "14 oct 2026, 15:05:09").
10199
+ * (fmt_date_time() of yui_date_text.js: es "14 oct 2026, 15:05:09").
10200
10200
  * Up to gobj-ui 7.26.51 the form wrote "2026-10-14 15:05:09" and
10201
10201
  * the treedb table "14 oct 2026, 03:05:09 p. m.", in the
10202
10202
  * browser's language. "" for no time; a value that is not one is
@@ -10360,22 +10360,58 @@ function form_time_cell_editor(real_type) {
10360
10360
  * (form_time_cell_editor.js) or Tabulator's own.
10361
10361
  *
10362
10362
  * `setColumns()` (a language change of
10363
- * C_YUI_TREEDB_TOPIC_WITH_FORM runs it) and `setHeight`,
10364
- * `setMaxHeight` and `setMinHeight` build the cells again the
10365
- * same way, and Tabulator throws the same.
10363
+ * C_YUI_TREEDB_TOPIC_WITH_FORM runs it), `setHeight`,
10364
+ * `setMaxHeight`, `setMinHeight`, `addColumn`,
10365
+ * `updateColumnDefinition` and `moveColumn` build the cells
10366
+ * again the same way, and Tabulator throws the same.
10366
10367
  *
10367
10368
  * So the edit is ended BEFORE each of those calls, while its cell
10368
10369
  * is alive, and opened again on the new cell of the same row
10369
- * and column after it. What was typed in the box is lost; the
10370
- * editor stays open under the reader.
10370
+ * and column after it (after the promise, for the calls that
10371
+ * answer one). What was typed in the box is lost; the editor
10372
+ * stays open under the reader. It is NOT opened again, and the
10373
+ * log says why, when: the cell is out of the page (a row the
10374
+ * virtual DOM does not render, or a filter hides), its column is
10375
+ * gone or has no editor any more, the call answered a REFUSAL
10376
+ * (it rebuilt nothing), or -- before a promise answers -- the
10377
+ * table was destroyed or another cell's editor was opened.
10378
+ *
10379
+ * A call that WIPES the rows (setData, replaceData, clearData,
10380
+ * destroy) cancels the edit first with
10381
+ * `yui_tabulator_close_editor()`: there is no cell to open it
10382
+ * on again.
10371
10383
  *
10372
10384
  * Copyright (c) 2026, ArtGins.
10373
10385
  * All Rights Reserved.
10374
10386
  ****************************************************************************/
10375
10387
  /************************************************************
10388
+ * Close the cell editor a table has open, dropping what is
10389
+ * typed in it, before its rows are wiped (setData, replaceData,
10390
+ * clearData, destroy). Tabulator 6.6.0 closes it while it wipes
10391
+ * them, and the redraw that follows walks the rows already
10392
+ * wiped: with an editor open in any row but the first it threw
10393
+ * ("reading 'add'"), and left the table half wiped.
10394
+ *
10395
+ * Tabulator has no public way to ask which cell is edited: this
10396
+ * reads its edit module (`modules.edit`, `currentCell`,
10397
+ * `cancelEdit()`), names pinned against the installed Tabulator
10398
+ * by tabulator_edit_internals.test.js. A Tabulator without them
10399
+ * is said: the guard would do nothing, and the crash come back.
10400
+ * `who` names the owner in that warning.
10401
+ ************************************************************/
10402
+ function yui_tabulator_close_editor(tabulator, who) {
10403
+ let edit = tabulator.modules ? tabulator.modules.edit : null;
10404
+ if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
10405
+ (0, _yuneta_gobj_js.log_warning)(`${who}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
10406
+ return;
10407
+ }
10408
+ if (edit.currentCell) edit.cancelEdit();
10409
+ }
10410
+ /************************************************************
10376
10411
  * Wrap the calls of `tabulator` that build the cells again --
10377
- * a forced `redraw`, `setColumns` and the three height setters
10378
- * -- so that each ends the open edit first and opens it again
10412
+ * a forced `redraw`, `setColumns`, the three height setters
10413
+ * and `addColumn`, `updateColumnDefinition`, `moveColumn` --
10414
+ * so that each ends the open edit first and opens it again
10379
10415
  * after.
10380
10416
  ************************************************************/
10381
10417
  function yui_tabulator_keep_edit_on_redraw(tabulator) {
@@ -10389,6 +10425,43 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10389
10425
  tabulator.on("cellEditCancelled", function() {
10390
10426
  editing = null;
10391
10427
  });
10428
+ function stays_closed(field, why) {
10429
+ (0, _yuneta_gobj_js.log_warning)(`yui_tabulator_keep_edit_on_redraw: the edit of '${field}' stays closed: ${why}`);
10430
+ }
10431
+ function has_column(field) {
10432
+ return tabulator.getColumns().some((c) => c.getField() === field);
10433
+ }
10434
+ function edit_again(row, field, name) {
10435
+ if (tabulator.destroyed) {
10436
+ stays_closed(field, `the table was destroyed after ${name}()`);
10437
+ return;
10438
+ }
10439
+ let $open = editing ? editing.getElement() : null;
10440
+ if ($open && $open.classList.contains("tabulator-editing")) {
10441
+ stays_closed(field, `another cell ('${editing.getField()}') was opened after ${name}()`);
10442
+ return;
10443
+ }
10444
+ let again = row.getCell(field);
10445
+ if (!again) {
10446
+ if (has_column(field)) stays_closed(field, `its row is not in the page after ${name}()`);
10447
+ else stays_closed(field, `no column '${field}' after ${name}()`);
10448
+ return;
10449
+ }
10450
+ let $again = again.getElement();
10451
+ if (!$again || !$again.isConnected) {
10452
+ stays_closed(field, `its row is not in the page after ${name}()`);
10453
+ return;
10454
+ }
10455
+ if (!again.getColumn().getDefinition().editor) {
10456
+ stays_closed(field, `the column has no editor after ${name}()`);
10457
+ return;
10458
+ }
10459
+ try {
10460
+ again.edit(true);
10461
+ } catch (e) {
10462
+ stays_closed(field, `Tabulator refused to open it after ${name}(): ${e}`);
10463
+ }
10464
+ }
10392
10465
  function keep_edit_around(name, rebuilds) {
10393
10466
  let original = tabulator[name].bind(tabulator);
10394
10467
  tabulator[name] = function(...args) {
@@ -10399,12 +10472,14 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10399
10472
  let field = cell.getField();
10400
10473
  cell.cancelEdit();
10401
10474
  let ret = original(...args);
10402
- let again = row.getCell(field);
10403
- if (!again) {
10404
- (0, _yuneta_gobj_js.log_warning)(`yui_tabulator_keep_edit_on_redraw: no cell '${field}' after ${name}()`);
10405
- return ret;
10406
- }
10407
- again.edit(true);
10475
+ if (ret && typeof ret.then === "function") return ret.then((value) => {
10476
+ edit_again(row, field, name);
10477
+ return value;
10478
+ }, (reason) => {
10479
+ stays_closed(field, `${name}() was refused: ${reason}`);
10480
+ throw reason;
10481
+ });
10482
+ edit_again(row, field, name);
10408
10483
  return ret;
10409
10484
  };
10410
10485
  }
@@ -10413,7 +10488,10 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10413
10488
  "setColumns",
10414
10489
  "setHeight",
10415
10490
  "setMaxHeight",
10416
- "setMinHeight"
10491
+ "setMinHeight",
10492
+ "addColumn",
10493
+ "updateColumnDefinition",
10494
+ "moveColumn"
10417
10495
  ]) keep_edit_around(name, () => true);
10418
10496
  }
10419
10497
  //#endregion
@@ -11270,28 +11348,6 @@ function destroy_widget(gobj, what, widget) {
11270
11348
  }
11271
11349
  }
11272
11350
  /************************************************************
11273
- * Close the cell editor a table has open, dropping what is
11274
- * typed in it, before its rows are wiped. Tabulator 6.6.0
11275
- * closes it while it wipes them, and the redraw that follows
11276
- * walks the rows already wiped: a reload, a Clear or a destroy
11277
- * with an editor open in any row but the first threw, and left
11278
- * the table half wiped.
11279
- *
11280
- * Tabulator has no public way to ask which cell is edited: this
11281
- * reads its edit module (`modules.edit`, `currentCell`,
11282
- * `cancelEdit()`), names pinned against the installed Tabulator
11283
- * by tabulator_edit_internals.test.js. A Tabulator without them
11284
- * is said: the guard would do nothing, and the crash come back.
11285
- ************************************************************/
11286
- function close_table_editor(gobj, tabulator) {
11287
- let edit = tabulator.modules ? tabulator.modules.edit : null;
11288
- if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
11289
- (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`);
11290
- return;
11291
- }
11292
- if (edit.currentCell) edit.cancelEdit();
11293
- }
11294
- /************************************************************
11295
11351
  * The element of the table (`.tabulator` kept on it) that holds
11296
11352
  * $el, the innermost one.
11297
11353
  ************************************************************/
@@ -11320,7 +11376,7 @@ function destroy_row_tables(gobj, $row) {
11320
11376
  $row.yui_nested = null;
11321
11377
  for (let $nested of nested) {
11322
11378
  if ($nested.tabulator) {
11323
- close_table_editor(gobj, $nested.tabulator);
11379
+ yui_tabulator_close_editor($nested.tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
11324
11380
  destroy_rows_tables(gobj, $nested.tabulator);
11325
11381
  destroy_widget(gobj, "nested table", $nested.tabulator);
11326
11382
  $nested.tabulator = null;
@@ -11353,7 +11409,7 @@ function destroy_widgets(gobj, $container) {
11353
11409
  $el.jsoneditor = null;
11354
11410
  }
11355
11411
  if ($el.tabulator) {
11356
- close_table_editor(gobj, $el.tabulator);
11412
+ yui_tabulator_close_editor($el.tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
11357
11413
  destroy_rows_tables(gobj, $el.tabulator);
11358
11414
  destroy_widget(gobj, "table", $el.tabulator);
11359
11415
  $el.tabulator = null;
@@ -12792,7 +12848,7 @@ function table_column_titles(template) {
12792
12848
  var TIME_CELL_FORMATTERS = /* @__PURE__ */ new WeakSet();
12793
12849
  /******************************************************************
12794
12850
  * The formatter of a time cell: the local clock, 24 hours, in the
12795
- * APP's language (fmt_date_time of yui_time.js, as the cells of
12851
+ * APP's language (fmt_date_time of yui_date_text.js, as the cells of
12796
12852
  * C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
12797
12853
  ******************************************************************/
12798
12854
  function time_cell_formatter(real_type) {
@@ -13252,7 +13308,7 @@ function clear_data(gobj, $form) {
13252
13308
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
13253
13309
  $table.yui_pending_rows = null;
13254
13310
  if ($table.tabulator.initialized) {
13255
- close_table_editor(gobj, $table.tabulator);
13311
+ yui_tabulator_close_editor($table.tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
13256
13312
  destroy_rows_tables(gobj, $table.tabulator);
13257
13313
  $table.tabulator.clearData();
13258
13314
  }
@@ -13336,6 +13392,7 @@ function set_form_values(gobj, template, $form, record) {
13336
13392
  value: stored,
13337
13393
  shown: $input.value
13338
13394
  } : null;
13395
+ if ($input.value === "" && stored !== null && stored !== "") (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: '${path}' holds ${JSON.stringify(stored)}, which the time box cannot show: a save writes it as null`);
13339
13396
  break;
13340
13397
  case "color":
13341
13398
  $input.value = convertColor(value);
@@ -15221,7 +15278,7 @@ function yui_uplot_axes(axes) {
15221
15278
  * The texts uPlot writes for a moment -- the ticks of a time axis
15222
15279
  * and the reading of the legend -- in the APP's language, with a
15223
15280
  * clock of 24 hours, as every other time a gobj-ui view shows
15224
- * (fmt_date_time of yui_time.js).
15281
+ * (fmt_date_time of yui_date_text.js).
15225
15282
  *
15226
15283
  * uPlot writes them from templates of its own, in English and
15227
15284
  * 12 hours: "3pm", "3:05pm", "10/14" (month first), "Oct", and
@@ -33225,7 +33282,12 @@ function create_tabulator(gobj) {
33225
33282
  function table__destroy(gobj) {
33226
33283
  let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
33227
33284
  if (tabulator) {
33228
- tabulator.destroy();
33285
+ yui_tabulator_close_editor(tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
33286
+ try {
33287
+ tabulator.destroy();
33288
+ } catch (e) {
33289
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot destroy the table: ${e}`);
33290
+ }
33229
33291
  (0, _yuneta_gobj_js.gobj_write_attr)(gobj, "tabulator", null);
33230
33292
  }
33231
33293
  }
@@ -34562,8 +34624,10 @@ function ac_load_nodes(gobj, event, kw, src) {
34562
34624
  }
34563
34625
  let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
34564
34626
  if (tabulator) {
34565
- if (tabulator._ready) tabulator.setData(data);
34566
- else tabulator._pendingData = data;
34627
+ if (tabulator._ready) {
34628
+ yui_tabulator_close_editor(tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
34629
+ tabulator.setData(data);
34630
+ } else tabulator._pendingData = data;
34567
34631
  }
34568
34632
  return 0;
34569
34633
  }
@@ -34592,9 +34656,15 @@ function ac_load_node_updated(gobj, event, kw, src) {
34592
34656
  return -1;
34593
34657
  }
34594
34658
  let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
34595
- if (tabulator) {
34596
- for (let record of data) if (tabulator.getRow(record.id)) tabulator.updateData([record]);
34597
- else if (tabulator.getDataCount() > 0) (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: updated node is not in the loaded table: ${record.id}`);
34659
+ if (tabulator) for (let record of data) {
34660
+ let row = tabulator.getRow(record.id);
34661
+ if (row) {
34662
+ let $row = row.getElement();
34663
+ if ($row && $row.querySelector(".tabulator-editing")) yui_tabulator_close_editor(tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
34664
+ tabulator.updateData([record]).catch((e) => {
34665
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot update row '${record.id}': ${e}`);
34666
+ });
34667
+ } else if (tabulator.getDataCount() > 0) (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: updated node is not in the loaded table: ${record.id}`);
34598
34668
  }
34599
34669
  return 0;
34600
34670
  }
@@ -35350,6 +35420,7 @@ function settle_page(gobj, req_id, value, error) {
35350
35420
  function ac_repull_page(gobj, event, kw, src) {
35351
35421
  let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "tabulator");
35352
35422
  if (!tabulator) return 0;
35423
+ yui_tabulator_close_editor(tabulator, (0, _yuneta_gobj_js.gobj_short_name)(gobj));
35353
35424
  try {
35354
35425
  tabulator.replaceData();
35355
35426
  } catch (e) {
@@ -9911,7 +9911,7 @@ function is_time_field(field) {
9911
9911
  /************************************************************
9912
9912
  * Format an epoch value as a local wall-clock string, 24
9913
9913
  * hours, in the APP's language `locale` (fmt_date_time() of
9914
- * yui_time.js, as the time cells of the forms and tables;
9914
+ * yui_date_text.js, as the time cells of the forms and tables;
9915
9915
  * up to gobj-ui 7.26.51 it was toLocaleString(): the
9916
9916
  * browser's language, and 12 hours in English).
9917
9917
  * Accepts seconds or milliseconds; returns null when the
@@ -10191,7 +10191,7 @@ function epoch_to_time_value(epoch, real_type) {
10191
10191
  /************************************************************
10192
10192
  * The value of a time column as a table cell shows it: the
10193
10193
  * local clock, 24 hours, in the APP's language `locale`
10194
- * (fmt_date_time() of yui_time.js: es "14 oct 2026, 15:05:09").
10194
+ * (fmt_date_time() of yui_date_text.js: es "14 oct 2026, 15:05:09").
10195
10195
  * Up to gobj-ui 7.26.51 the form wrote "2026-10-14 15:05:09" and
10196
10196
  * the treedb table "14 oct 2026, 03:05:09 p. m.", in the
10197
10197
  * browser's language. "" for no time; a value that is not one is
@@ -10355,22 +10355,58 @@ function form_time_cell_editor(real_type) {
10355
10355
  * (form_time_cell_editor.js) or Tabulator's own.
10356
10356
  *
10357
10357
  * `setColumns()` (a language change of
10358
- * C_YUI_TREEDB_TOPIC_WITH_FORM runs it) and `setHeight`,
10359
- * `setMaxHeight` and `setMinHeight` build the cells again the
10360
- * same way, and Tabulator throws the same.
10358
+ * C_YUI_TREEDB_TOPIC_WITH_FORM runs it), `setHeight`,
10359
+ * `setMaxHeight`, `setMinHeight`, `addColumn`,
10360
+ * `updateColumnDefinition` and `moveColumn` build the cells
10361
+ * again the same way, and Tabulator throws the same.
10361
10362
  *
10362
10363
  * So the edit is ended BEFORE each of those calls, while its cell
10363
10364
  * is alive, and opened again on the new cell of the same row
10364
- * and column after it. What was typed in the box is lost; the
10365
- * editor stays open under the reader.
10365
+ * and column after it (after the promise, for the calls that
10366
+ * answer one). What was typed in the box is lost; the editor
10367
+ * stays open under the reader. It is NOT opened again, and the
10368
+ * log says why, when: the cell is out of the page (a row the
10369
+ * virtual DOM does not render, or a filter hides), its column is
10370
+ * gone or has no editor any more, the call answered a REFUSAL
10371
+ * (it rebuilt nothing), or -- before a promise answers -- the
10372
+ * table was destroyed or another cell's editor was opened.
10373
+ *
10374
+ * A call that WIPES the rows (setData, replaceData, clearData,
10375
+ * destroy) cancels the edit first with
10376
+ * `yui_tabulator_close_editor()`: there is no cell to open it
10377
+ * on again.
10366
10378
  *
10367
10379
  * Copyright (c) 2026, ArtGins.
10368
10380
  * All Rights Reserved.
10369
10381
  ****************************************************************************/
10370
10382
  /************************************************************
10383
+ * Close the cell editor a table has open, dropping what is
10384
+ * typed in it, before its rows are wiped (setData, replaceData,
10385
+ * clearData, destroy). Tabulator 6.6.0 closes it while it wipes
10386
+ * them, and the redraw that follows walks the rows already
10387
+ * wiped: with an editor open in any row but the first it threw
10388
+ * ("reading 'add'"), and left the table half wiped.
10389
+ *
10390
+ * Tabulator has no public way to ask which cell is edited: this
10391
+ * reads its edit module (`modules.edit`, `currentCell`,
10392
+ * `cancelEdit()`), names pinned against the installed Tabulator
10393
+ * by tabulator_edit_internals.test.js. A Tabulator without them
10394
+ * is said: the guard would do nothing, and the crash come back.
10395
+ * `who` names the owner in that warning.
10396
+ ************************************************************/
10397
+ function yui_tabulator_close_editor(tabulator, who) {
10398
+ let edit = tabulator.modules ? tabulator.modules.edit : null;
10399
+ if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
10400
+ log_warning(`${who}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
10401
+ return;
10402
+ }
10403
+ if (edit.currentCell) edit.cancelEdit();
10404
+ }
10405
+ /************************************************************
10371
10406
  * Wrap the calls of `tabulator` that build the cells again --
10372
- * a forced `redraw`, `setColumns` and the three height setters
10373
- * -- so that each ends the open edit first and opens it again
10407
+ * a forced `redraw`, `setColumns`, the three height setters
10408
+ * and `addColumn`, `updateColumnDefinition`, `moveColumn` --
10409
+ * so that each ends the open edit first and opens it again
10374
10410
  * after.
10375
10411
  ************************************************************/
10376
10412
  function yui_tabulator_keep_edit_on_redraw(tabulator) {
@@ -10384,6 +10420,43 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10384
10420
  tabulator.on("cellEditCancelled", function() {
10385
10421
  editing = null;
10386
10422
  });
10423
+ function stays_closed(field, why) {
10424
+ log_warning(`yui_tabulator_keep_edit_on_redraw: the edit of '${field}' stays closed: ${why}`);
10425
+ }
10426
+ function has_column(field) {
10427
+ return tabulator.getColumns().some((c) => c.getField() === field);
10428
+ }
10429
+ function edit_again(row, field, name) {
10430
+ if (tabulator.destroyed) {
10431
+ stays_closed(field, `the table was destroyed after ${name}()`);
10432
+ return;
10433
+ }
10434
+ let $open = editing ? editing.getElement() : null;
10435
+ if ($open && $open.classList.contains("tabulator-editing")) {
10436
+ stays_closed(field, `another cell ('${editing.getField()}') was opened after ${name}()`);
10437
+ return;
10438
+ }
10439
+ let again = row.getCell(field);
10440
+ if (!again) {
10441
+ if (has_column(field)) stays_closed(field, `its row is not in the page after ${name}()`);
10442
+ else stays_closed(field, `no column '${field}' after ${name}()`);
10443
+ return;
10444
+ }
10445
+ let $again = again.getElement();
10446
+ if (!$again || !$again.isConnected) {
10447
+ stays_closed(field, `its row is not in the page after ${name}()`);
10448
+ return;
10449
+ }
10450
+ if (!again.getColumn().getDefinition().editor) {
10451
+ stays_closed(field, `the column has no editor after ${name}()`);
10452
+ return;
10453
+ }
10454
+ try {
10455
+ again.edit(true);
10456
+ } catch (e) {
10457
+ stays_closed(field, `Tabulator refused to open it after ${name}(): ${e}`);
10458
+ }
10459
+ }
10387
10460
  function keep_edit_around(name, rebuilds) {
10388
10461
  let original = tabulator[name].bind(tabulator);
10389
10462
  tabulator[name] = function(...args) {
@@ -10394,12 +10467,14 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10394
10467
  let field = cell.getField();
10395
10468
  cell.cancelEdit();
10396
10469
  let ret = original(...args);
10397
- let again = row.getCell(field);
10398
- if (!again) {
10399
- log_warning(`yui_tabulator_keep_edit_on_redraw: no cell '${field}' after ${name}()`);
10400
- return ret;
10401
- }
10402
- again.edit(true);
10470
+ if (ret && typeof ret.then === "function") return ret.then((value) => {
10471
+ edit_again(row, field, name);
10472
+ return value;
10473
+ }, (reason) => {
10474
+ stays_closed(field, `${name}() was refused: ${reason}`);
10475
+ throw reason;
10476
+ });
10477
+ edit_again(row, field, name);
10403
10478
  return ret;
10404
10479
  };
10405
10480
  }
@@ -10408,7 +10483,10 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
10408
10483
  "setColumns",
10409
10484
  "setHeight",
10410
10485
  "setMaxHeight",
10411
- "setMinHeight"
10486
+ "setMinHeight",
10487
+ "addColumn",
10488
+ "updateColumnDefinition",
10489
+ "moveColumn"
10412
10490
  ]) keep_edit_around(name, () => true);
10413
10491
  }
10414
10492
  //#endregion
@@ -11265,28 +11343,6 @@ function destroy_widget(gobj, what, widget) {
11265
11343
  }
11266
11344
  }
11267
11345
  /************************************************************
11268
- * Close the cell editor a table has open, dropping what is
11269
- * typed in it, before its rows are wiped. Tabulator 6.6.0
11270
- * closes it while it wipes them, and the redraw that follows
11271
- * walks the rows already wiped: a reload, a Clear or a destroy
11272
- * with an editor open in any row but the first threw, and left
11273
- * the table half wiped.
11274
- *
11275
- * Tabulator has no public way to ask which cell is edited: this
11276
- * reads its edit module (`modules.edit`, `currentCell`,
11277
- * `cancelEdit()`), names pinned against the installed Tabulator
11278
- * by tabulator_edit_internals.test.js. A Tabulator without them
11279
- * is said: the guard would do nothing, and the crash come back.
11280
- ************************************************************/
11281
- function close_table_editor(gobj, tabulator) {
11282
- let edit = tabulator.modules ? tabulator.modules.edit : null;
11283
- if (!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
11284
- log_warning(`${gobj_short_name(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): an open cell editor is not closed before its table is wiped`);
11285
- return;
11286
- }
11287
- if (edit.currentCell) edit.cancelEdit();
11288
- }
11289
- /************************************************************
11290
11346
  * The element of the table (`.tabulator` kept on it) that holds
11291
11347
  * $el, the innermost one.
11292
11348
  ************************************************************/
@@ -11315,7 +11371,7 @@ function destroy_row_tables(gobj, $row) {
11315
11371
  $row.yui_nested = null;
11316
11372
  for (let $nested of nested) {
11317
11373
  if ($nested.tabulator) {
11318
- close_table_editor(gobj, $nested.tabulator);
11374
+ yui_tabulator_close_editor($nested.tabulator, gobj_short_name(gobj));
11319
11375
  destroy_rows_tables(gobj, $nested.tabulator);
11320
11376
  destroy_widget(gobj, "nested table", $nested.tabulator);
11321
11377
  $nested.tabulator = null;
@@ -11348,7 +11404,7 @@ function destroy_widgets(gobj, $container) {
11348
11404
  $el.jsoneditor = null;
11349
11405
  }
11350
11406
  if ($el.tabulator) {
11351
- close_table_editor(gobj, $el.tabulator);
11407
+ yui_tabulator_close_editor($el.tabulator, gobj_short_name(gobj));
11352
11408
  destroy_rows_tables(gobj, $el.tabulator);
11353
11409
  destroy_widget(gobj, "table", $el.tabulator);
11354
11410
  $el.tabulator = null;
@@ -12787,7 +12843,7 @@ function table_column_titles(template) {
12787
12843
  var TIME_CELL_FORMATTERS = /* @__PURE__ */ new WeakSet();
12788
12844
  /******************************************************************
12789
12845
  * The formatter of a time cell: the local clock, 24 hours, in the
12790
- * APP's language (fmt_date_time of yui_time.js, as the cells of
12846
+ * APP's language (fmt_date_time of yui_date_text.js, as the cells of
12791
12847
  * C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
12792
12848
  ******************************************************************/
12793
12849
  function time_cell_formatter(real_type) {
@@ -13247,7 +13303,7 @@ function clear_data(gobj, $form) {
13247
13303
  $form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
13248
13304
  $table.yui_pending_rows = null;
13249
13305
  if ($table.tabulator.initialized) {
13250
- close_table_editor(gobj, $table.tabulator);
13306
+ yui_tabulator_close_editor($table.tabulator, gobj_short_name(gobj));
13251
13307
  destroy_rows_tables(gobj, $table.tabulator);
13252
13308
  $table.tabulator.clearData();
13253
13309
  }
@@ -13331,6 +13387,7 @@ function set_form_values(gobj, template, $form, record) {
13331
13387
  value: stored,
13332
13388
  shown: $input.value
13333
13389
  } : null;
13390
+ if ($input.value === "" && stored !== null && stored !== "") log_warning(`${gobj_short_name(gobj)}: '${path}' holds ${JSON.stringify(stored)}, which the time box cannot show: a save writes it as null`);
13334
13391
  break;
13335
13392
  case "color":
13336
13393
  $input.value = convertColor(value);
@@ -15216,7 +15273,7 @@ function yui_uplot_axes(axes) {
15216
15273
  * The texts uPlot writes for a moment -- the ticks of a time axis
15217
15274
  * and the reading of the legend -- in the APP's language, with a
15218
15275
  * clock of 24 hours, as every other time a gobj-ui view shows
15219
- * (fmt_date_time of yui_time.js).
15276
+ * (fmt_date_time of yui_date_text.js).
15220
15277
  *
15221
15278
  * uPlot writes them from templates of its own, in English and
15222
15279
  * 12 hours: "3pm", "3:05pm", "10/14" (month first), "Oct", and
@@ -33220,7 +33277,12 @@ function create_tabulator(gobj) {
33220
33277
  function table__destroy(gobj) {
33221
33278
  let tabulator = gobj_read_attr(gobj, "tabulator");
33222
33279
  if (tabulator) {
33223
- tabulator.destroy();
33280
+ yui_tabulator_close_editor(tabulator, gobj_short_name(gobj));
33281
+ try {
33282
+ tabulator.destroy();
33283
+ } catch (e) {
33284
+ log_warning(`${gobj_short_name(gobj)}: cannot destroy the table: ${e}`);
33285
+ }
33224
33286
  gobj_write_attr(gobj, "tabulator", null);
33225
33287
  }
33226
33288
  }
@@ -34557,8 +34619,10 @@ function ac_load_nodes(gobj, event, kw, src) {
34557
34619
  }
34558
34620
  let tabulator = gobj_read_attr(gobj, "tabulator");
34559
34621
  if (tabulator) {
34560
- if (tabulator._ready) tabulator.setData(data);
34561
- else tabulator._pendingData = data;
34622
+ if (tabulator._ready) {
34623
+ yui_tabulator_close_editor(tabulator, gobj_short_name(gobj));
34624
+ tabulator.setData(data);
34625
+ } else tabulator._pendingData = data;
34562
34626
  }
34563
34627
  return 0;
34564
34628
  }
@@ -34587,9 +34651,15 @@ function ac_load_node_updated(gobj, event, kw, src) {
34587
34651
  return -1;
34588
34652
  }
34589
34653
  let tabulator = gobj_read_attr(gobj, "tabulator");
34590
- if (tabulator) {
34591
- for (let record of data) if (tabulator.getRow(record.id)) tabulator.updateData([record]);
34592
- else if (tabulator.getDataCount() > 0) log_error(`${gobj_short_name(gobj)}: updated node is not in the loaded table: ${record.id}`);
34654
+ if (tabulator) for (let record of data) {
34655
+ let row = tabulator.getRow(record.id);
34656
+ if (row) {
34657
+ let $row = row.getElement();
34658
+ if ($row && $row.querySelector(".tabulator-editing")) yui_tabulator_close_editor(tabulator, gobj_short_name(gobj));
34659
+ tabulator.updateData([record]).catch((e) => {
34660
+ log_error(`${gobj_short_name(gobj)}: cannot update row '${record.id}': ${e}`);
34661
+ });
34662
+ } else if (tabulator.getDataCount() > 0) log_error(`${gobj_short_name(gobj)}: updated node is not in the loaded table: ${record.id}`);
34593
34663
  }
34594
34664
  return 0;
34595
34665
  }
@@ -35345,6 +35415,7 @@ function settle_page(gobj, req_id, value, error) {
35345
35415
  function ac_repull_page(gobj, event, kw, src) {
35346
35416
  let tabulator = gobj_read_attr(gobj, "tabulator");
35347
35417
  if (!tabulator) return 0;
35418
+ yui_tabulator_close_editor(tabulator, gobj_short_name(gobj));
35348
35419
  try {
35349
35420
  tabulator.replaceData();
35350
35421
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.56",
3
+ "version": "7.26.58",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",