@yuneta/gobj-ui 7.26.46 → 7.26.47
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 +94 -16
- package/dist/gobj-ui.cjs.js +247 -59
- package/dist/gobj-ui.es.js +247 -59
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +185 -8
- package/src/c_yui_form.css +9 -0
- package/src/c_yui_form.js +158 -20
- package/src/c_yui_shell.js +25 -2
- package/src/c_yui_treedb_topic_with_form.js +8 -2
- package/src/c_yui_window.js +15 -1
- package/src/form_table_rows.wiring.test.js +169 -3
- package/src/form_time_cell_editor.js +40 -23
- package/src/form_time_cell_editor.test.js +38 -0
- package/src/form_time_field.wiring.test.js +118 -0
- package/src/form_time_value.js +59 -1
- package/src/form_time_value.test.js +25 -1
- package/src/shell_focus_trap.js +19 -24
- package/src/shell_focus_trap.test.js +53 -9
- package/src/shell_stop_overlays.wiring.test.js +35 -3
- package/src/treedb_time_cell.wiring.test.js +103 -0
- package/src/window_rect_rounding.wiring.test.js +29 -1
- package/src/yui_tabulator_i18n.js +18 -7
- package/src/yui_tabulator_i18n.test.js +36 -0
package/dist/gobj-ui.es.js
CHANGED
|
@@ -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
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -1432,7 +1428,7 @@ function mt_start$21(gobj) {
|
|
|
1432
1428
|
function mt_stop$20(gobj) {
|
|
1433
1429
|
let priv = gobj.priv;
|
|
1434
1430
|
if (!priv) return 0;
|
|
1435
|
-
|
|
1431
|
+
retire_overlays(gobj);
|
|
1436
1432
|
close_toolbar_dropdown(gobj);
|
|
1437
1433
|
if (priv.hash_handler) {
|
|
1438
1434
|
window.removeEventListener("hashchange", priv.hash_handler);
|
|
@@ -1487,7 +1483,7 @@ function mt_stop$20(gobj) {
|
|
|
1487
1483
|
* Framework Method: Destroy
|
|
1488
1484
|
***************************************************************/
|
|
1489
1485
|
function mt_destroy$22(gobj) {
|
|
1490
|
-
|
|
1486
|
+
retire_overlays(gobj);
|
|
1491
1487
|
close_toolbar_dropdown(gobj);
|
|
1492
1488
|
let live_idx = __live_shells__.indexOf(gobj);
|
|
1493
1489
|
if (live_idx >= 0) __live_shells__.splice(live_idx, 1);
|
|
@@ -2796,6 +2792,25 @@ function close_overlays(gobj) {
|
|
|
2796
2792
|
}
|
|
2797
2793
|
}
|
|
2798
2794
|
}
|
|
2795
|
+
/************************************************************
|
|
2796
|
+
* What a shell that stops does with its overlays: their
|
|
2797
|
+
* history markers are left where they are, and then they are
|
|
2798
|
+
* closed (close_overlays). The overlay stack is emptied FIRST,
|
|
2799
|
+
* so no close -- of an overlay closed here, or of a window
|
|
2800
|
+
* closed later -- retires its marker with a history.back().
|
|
2801
|
+
* Such a back() is asynchronous and a stopped shell no longer
|
|
2802
|
+
* hears where it lands: up to gobj-ui 7.26.46 a logout followed
|
|
2803
|
+
* by a new shell in the same turn had it taken by the new
|
|
2804
|
+
* shell's first window (Chromium stepped back off that window's
|
|
2805
|
+
* marker, Firefox dropped the back()), and the next Back left
|
|
2806
|
+
* the page. A marker left in place is inert, as a drained one
|
|
2807
|
+
* is: a later Back lands on it and is absorbed.
|
|
2808
|
+
************************************************************/
|
|
2809
|
+
function retire_overlays(gobj) {
|
|
2810
|
+
let priv = gobj.priv;
|
|
2811
|
+
if (priv && priv.overlay_stack) priv.overlay_stack.splice(0);
|
|
2812
|
+
close_overlays(gobj);
|
|
2813
|
+
}
|
|
2799
2814
|
function pop_escape(gobj, handler) {
|
|
2800
2815
|
let priv = gobj.priv;
|
|
2801
2816
|
if (!priv || !priv.escape_stack) return;
|
|
@@ -5084,9 +5099,8 @@ function build_ui$18(gobj) {
|
|
|
5084
5099
|
if (gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
|
|
5085
5100
|
if (gobj_is_service(gobj)) {
|
|
5086
5101
|
let key = `${gobj_name(gobj)}-rect`;
|
|
5087
|
-
let
|
|
5088
|
-
|
|
5089
|
-
if (!rect && stored != null) {
|
|
5102
|
+
let rect = whole_rect(kw_get_local_storage_value(key));
|
|
5103
|
+
if (!rect && local_storage_holds(key)) {
|
|
5090
5104
|
log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
|
|
5091
5105
|
kw_remove_local_storage_value(key);
|
|
5092
5106
|
} else if (rect && (rect.width <= 0 || rect.height <= 0)) {
|
|
@@ -5533,6 +5547,17 @@ function min$1(gobj) {
|
|
|
5533
5547
|
return rect;
|
|
5534
5548
|
}
|
|
5535
5549
|
/************************************************************
|
|
5550
|
+
* Whether localStorage holds anything under `key`, readable
|
|
5551
|
+
* or not.
|
|
5552
|
+
************************************************************/
|
|
5553
|
+
function local_storage_holds(key) {
|
|
5554
|
+
try {
|
|
5555
|
+
return window.localStorage.getItem(key) !== null;
|
|
5556
|
+
} catch (e) {
|
|
5557
|
+
return false;
|
|
5558
|
+
}
|
|
5559
|
+
}
|
|
5560
|
+
/************************************************************
|
|
5536
5561
|
* The rect of a window in whole pixels: x, y, width and height
|
|
5537
5562
|
* are DTP_INTEGER, and getBoundingClientRect() answers fractions
|
|
5538
5563
|
* under a zoom or a device pixel ratio (an integer attr refuses
|
|
@@ -7861,8 +7886,14 @@ function yui_tabulator_name_filters(table, t) {
|
|
|
7861
7886
|
* from `yui_tabulator_relocalize()` so a language change
|
|
7862
7887
|
* reaches them.
|
|
7863
7888
|
*
|
|
7864
|
-
* It matches Tabulator's OWN literal and
|
|
7865
|
-
* view named itself is
|
|
7889
|
+
* It matches Tabulator's OWN literal, and the boxes it named itself
|
|
7890
|
+
* (they carry `data-yui-row-select`), so a box a view named itself is
|
|
7891
|
+
* left alone. Up to 7.26.46 it matched only the literal: a box named
|
|
7892
|
+
* once was never found again, and a language change through
|
|
7893
|
+
* yui_tabulator_relocalize() left it in the old language.
|
|
7894
|
+
*
|
|
7895
|
+
* The box in the HEADER selects every row, and is named so
|
|
7896
|
+
* ("select all rows"); up to 7.26.46 it was "select row" too.
|
|
7866
7897
|
***************************************************************/
|
|
7867
7898
|
var TABULATOR_ROW_SELECT_ARIA = "Select Row";
|
|
7868
7899
|
function yui_tabulator_name_row_selects(table, t) {
|
|
@@ -7873,12 +7904,16 @@ function yui_tabulator_name_row_selects(table, t) {
|
|
|
7873
7904
|
log_warning("yui_tabulator_name_row_selects: table has no element: its row-selection boxes keep Tabulator's English name");
|
|
7874
7905
|
return;
|
|
7875
7906
|
}
|
|
7876
|
-
let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"]`);
|
|
7907
|
+
let boxes = $el.querySelectorAll(`input[type=checkbox][aria-label="${TABULATOR_ROW_SELECT_ARIA}"], input[type=checkbox][data-yui-row-select]`);
|
|
7877
7908
|
for (let $box of boxes) {
|
|
7878
|
-
$box.
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
$box.setAttribute("
|
|
7909
|
+
let all = typeof $box.closest === "function" && !!$box.closest(".tabulator-header");
|
|
7910
|
+
let name = all ? t("select all rows") : t("select row");
|
|
7911
|
+
let key = all ? "select all rows" : "select row";
|
|
7912
|
+
$box.setAttribute("aria-label", name);
|
|
7913
|
+
$box.setAttribute("data-i18n-aria-label", key);
|
|
7914
|
+
$box.setAttribute("title", name);
|
|
7915
|
+
$box.setAttribute("data-i18n-title", key);
|
|
7916
|
+
$box.setAttribute("data-yui-row-select", "");
|
|
7882
7917
|
}
|
|
7883
7918
|
} catch (e) {}
|
|
7884
7919
|
}
|
|
@@ -9731,6 +9766,44 @@ function datetime_local_to_epoch(value) {
|
|
|
9731
9766
|
if (isNaN(date.getTime())) return null;
|
|
9732
9767
|
return Math.floor(date.getTime() / 1e3);
|
|
9733
9768
|
}
|
|
9769
|
+
/************************************************************
|
|
9770
|
+
* The value of a time column -> a Date, or null when it holds
|
|
9771
|
+
* none. A `string` column holds an ISO text, any other an epoch
|
|
9772
|
+
* in SECONDS. The form's time field and the cell editor of a
|
|
9773
|
+
* table read it here, so the two agree: up to gobj-ui 7.26.46 the
|
|
9774
|
+
* field read every column with parseInt -- an ISO text as the
|
|
9775
|
+
* year 2026 in SECONDS, in January 1970 -- and showed an empty
|
|
9776
|
+
* one as January 1970 too, which a save then wrote back as 0.
|
|
9777
|
+
************************************************************/
|
|
9778
|
+
function time_value_to_date(value, real_type) {
|
|
9779
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
9780
|
+
let date = real_type === "string" ? new Date(String(value)) : /* @__PURE__ */ new Date(Number(value) * 1e3);
|
|
9781
|
+
return isNaN(date.getTime()) ? null : date;
|
|
9782
|
+
}
|
|
9783
|
+
/************************************************************
|
|
9784
|
+
* An epoch in seconds (null: no time) -> the value of a time
|
|
9785
|
+
* column: an ISO text for a `string` column, the epoch for any
|
|
9786
|
+
* other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
|
|
9787
|
+
* `string` column too.
|
|
9788
|
+
************************************************************/
|
|
9789
|
+
function epoch_to_time_value(epoch, real_type) {
|
|
9790
|
+
if (epoch === null || epoch === void 0) return null;
|
|
9791
|
+
if (typeof epoch !== "number" || !Number.isFinite(epoch)) return epoch;
|
|
9792
|
+
if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
|
|
9793
|
+
return epoch;
|
|
9794
|
+
}
|
|
9795
|
+
/************************************************************
|
|
9796
|
+
* The value of a time column as a table cell shows it: the
|
|
9797
|
+
* local clock the editor opens on, "YYYY-MM-DD HH:mm:ss", as
|
|
9798
|
+
* fmt_epoch() of yui_time.js writes a timestamp in a table. ""
|
|
9799
|
+
* for no time; a value that is not one is shown as it is, so the
|
|
9800
|
+
* reader sees what the column holds.
|
|
9801
|
+
************************************************************/
|
|
9802
|
+
function time_value_to_text(value, real_type) {
|
|
9803
|
+
let date = time_value_to_date(value, real_type);
|
|
9804
|
+
if (!date) return value === null || value === void 0 ? "" : String(value);
|
|
9805
|
+
return date_to_datetime_local(date).replace("T", " ");
|
|
9806
|
+
}
|
|
9734
9807
|
//#endregion
|
|
9735
9808
|
//#region src/form_time_cell_editor.js
|
|
9736
9809
|
/****************************************************************************
|
|
@@ -9758,6 +9831,17 @@ function datetime_local_to_epoch(value) {
|
|
|
9758
9831
|
* Escape cancels, `verticalNavigation: "editor"` keeps the
|
|
9759
9832
|
* arrows, and a value that did not change is a cancel.
|
|
9760
9833
|
*
|
|
9834
|
+
* A date with a part cleared is NOT a value: the box answers
|
|
9835
|
+
* `value ""` for it, as for an empty box, and only
|
|
9836
|
+
* `validity.badInput` tells them apart. Enter leaves the
|
|
9837
|
+
* editor open with `aria-invalid` until the date is whole
|
|
9838
|
+
* again (or Escape); a blur cancels, and the cell keeps what
|
|
9839
|
+
* it had. Up to gobj-ui 7.26.46 both committed null: one
|
|
9840
|
+
* Backspace and Enter erased the stored time. To clear a time
|
|
9841
|
+
* on purpose, clear EVERY part of the box: an empty box
|
|
9842
|
+
* commits null. (Inside the box Tab moves between its parts,
|
|
9843
|
+
* as the browser does: it does not leave the cell.)
|
|
9844
|
+
*
|
|
9761
9845
|
* Copyright (c) 2026, ArtGins.
|
|
9762
9846
|
* All Rights Reserved.
|
|
9763
9847
|
****************************************************************************/
|
|
@@ -9765,20 +9849,13 @@ function datetime_local_to_epoch(value) {
|
|
|
9765
9849
|
* A cell's value -> the text of the box ("" when empty).
|
|
9766
9850
|
************************************************************/
|
|
9767
9851
|
function time_to_datetime_local(value, real_type) {
|
|
9768
|
-
|
|
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));
|
|
9852
|
+
return date_to_datetime_local(time_value_to_date(value, real_type));
|
|
9773
9853
|
}
|
|
9774
9854
|
/************************************************************
|
|
9775
9855
|
* The text of the box -> the cell's value (null when empty).
|
|
9776
9856
|
************************************************************/
|
|
9777
9857
|
function datetime_local_to_time(text, real_type) {
|
|
9778
|
-
|
|
9779
|
-
if (epoch === null) return null;
|
|
9780
|
-
if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
|
|
9781
|
-
return epoch;
|
|
9858
|
+
return epoch_to_time_value(datetime_local_to_epoch(text), real_type);
|
|
9782
9859
|
}
|
|
9783
9860
|
/************************************************************
|
|
9784
9861
|
* The editor of a time column whose values are `real_type`
|
|
@@ -9805,7 +9882,15 @@ function form_time_cell_editor(real_type) {
|
|
|
9805
9882
|
input.style.height = "100%";
|
|
9806
9883
|
}
|
|
9807
9884
|
});
|
|
9808
|
-
let
|
|
9885
|
+
let incomplete = function() {
|
|
9886
|
+
return !!(input.validity && input.validity.badInput);
|
|
9887
|
+
};
|
|
9888
|
+
let commit = function(from_blur) {
|
|
9889
|
+
if (incomplete()) {
|
|
9890
|
+
if (from_blur) cancel();
|
|
9891
|
+
else input.setAttribute("aria-invalid", "true");
|
|
9892
|
+
return;
|
|
9893
|
+
}
|
|
9809
9894
|
if (input.value === original_text) {
|
|
9810
9895
|
cancel();
|
|
9811
9896
|
return;
|
|
@@ -9818,12 +9903,15 @@ function form_time_cell_editor(real_type) {
|
|
|
9818
9903
|
success(value);
|
|
9819
9904
|
};
|
|
9820
9905
|
input.addEventListener("blur", function(e) {
|
|
9821
|
-
if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit();
|
|
9906
|
+
if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) commit(true);
|
|
9907
|
+
});
|
|
9908
|
+
input.addEventListener("input", function() {
|
|
9909
|
+
if (!incomplete()) input.removeAttribute("aria-invalid");
|
|
9822
9910
|
});
|
|
9823
9911
|
input.addEventListener("keydown", function(e) {
|
|
9824
9912
|
switch (e.key) {
|
|
9825
9913
|
case "Enter":
|
|
9826
|
-
commit();
|
|
9914
|
+
commit(false);
|
|
9827
9915
|
break;
|
|
9828
9916
|
case "Escape":
|
|
9829
9917
|
cancel();
|
|
@@ -10268,7 +10356,7 @@ var attrs_table$17 = [
|
|
|
10268
10356
|
SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
|
|
10269
10357
|
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
10358
|
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 (
|
|
10359
|
+
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
10360
|
SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
|
|
10273
10361
|
SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
|
|
10274
10362
|
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 +10378,9 @@ var PRIVATE_DATA$17 = {
|
|
|
10290
10378
|
tables: null,
|
|
10291
10379
|
table_seq: 0,
|
|
10292
10380
|
json_names_posted: false,
|
|
10293
|
-
lang_shell: null
|
|
10381
|
+
lang_shell: null,
|
|
10382
|
+
change_seq: 0,
|
|
10383
|
+
cell_edit: null
|
|
10294
10384
|
};
|
|
10295
10385
|
var __gclass__$17 = null;
|
|
10296
10386
|
/***************************
|
|
@@ -10309,6 +10399,16 @@ function mt_create$17(gobj) {
|
|
|
10309
10399
|
build_ui$15(gobj);
|
|
10310
10400
|
}
|
|
10311
10401
|
/************************************************************
|
|
10402
|
+
* Framework Method writing
|
|
10403
|
+
************************************************************/
|
|
10404
|
+
function mt_writing$2(gobj, path) {
|
|
10405
|
+
if (path === "selectable") {
|
|
10406
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
10407
|
+
if (!$container) return;
|
|
10408
|
+
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) if ($table.tabulator) show_row_selection(gobj, $table.tabulator);
|
|
10409
|
+
}
|
|
10410
|
+
}
|
|
10411
|
+
/************************************************************
|
|
10312
10412
|
* Framework Method destroy
|
|
10313
10413
|
* In this point, all children
|
|
10314
10414
|
* and subscriptions are already deleted.
|
|
@@ -10346,6 +10446,7 @@ function mt_stop$17(gobj) {
|
|
|
10346
10446
|
* not switched here: they always say it (create_tabulator).
|
|
10347
10447
|
************************************************************/
|
|
10348
10448
|
function set_changed_stated(gobj, changed) {
|
|
10449
|
+
gobj.priv.change_seq += 1;
|
|
10349
10450
|
let $container = gobj_read_attr(gobj, "$container");
|
|
10350
10451
|
$container.querySelector("form");
|
|
10351
10452
|
const enable = ($btn, on, color) => {
|
|
@@ -10910,6 +11011,9 @@ function build_form(gobj) {
|
|
|
10910
11011
|
id: form_id,
|
|
10911
11012
|
class: "yui-form"
|
|
10912
11013
|
}]);
|
|
11014
|
+
$form.addEventListener("submit", function(ev) {
|
|
11015
|
+
ev.preventDefault();
|
|
11016
|
+
});
|
|
10913
11017
|
let template = gobj_read_attr(gobj, "template");
|
|
10914
11018
|
if (!is_object(template) && !is_array(template)) {
|
|
10915
11019
|
$form.appendChild(createOneHtml(template));
|
|
@@ -11421,6 +11525,7 @@ function create_form_field(gobj, $form, prefix, field_desc, { tag, inputType, na
|
|
|
11421
11525
|
"button",
|
|
11422
11526
|
{
|
|
11423
11527
|
class: "button p-1",
|
|
11528
|
+
type: "button",
|
|
11424
11529
|
title: t("add"),
|
|
11425
11530
|
"data-i18n-title": "add",
|
|
11426
11531
|
"aria-label": t("add"),
|
|
@@ -12000,6 +12105,22 @@ function create_coordinates(gobj, attrs) {
|
|
|
12000
12105
|
return $extend;
|
|
12001
12106
|
}
|
|
12002
12107
|
/******************************************************************
|
|
12108
|
+
* Show the checkbox column of a table while the form is
|
|
12109
|
+
* `selectable`, hide it while it is not. The column is the table's
|
|
12110
|
+
* row header, the first of its structured columns. A table not
|
|
12111
|
+
* built yet does it when it is (tableBuilt).
|
|
12112
|
+
******************************************************************/
|
|
12113
|
+
function show_row_selection(gobj, tabulator) {
|
|
12114
|
+
if (!gobj_read_bool_attr(gobj, "with_checkbox") || !tabulator.initialized) return;
|
|
12115
|
+
let column = tabulator.getColumns(true).find((c) => c.getDefinition().formatter === "rowSelection");
|
|
12116
|
+
if (!column) {
|
|
12117
|
+
log_error(`${gobj_short_name(gobj)}: the table has no checkbox column to show or hide`);
|
|
12118
|
+
return;
|
|
12119
|
+
}
|
|
12120
|
+
if (gobj_read_bool_attr(gobj, "selectable")) column.show();
|
|
12121
|
+
else column.hide();
|
|
12122
|
+
}
|
|
12123
|
+
/******************************************************************
|
|
12003
12124
|
* Create tabulator
|
|
12004
12125
|
*
|
|
12005
12126
|
* A row builds its nested tables the first time it is drawn, each
|
|
@@ -12029,11 +12150,13 @@ function create_coordinates(gobj, attrs) {
|
|
|
12029
12150
|
* `"highlight"` is left as it is, hover and all.
|
|
12030
12151
|
*
|
|
12031
12152
|
* The checkbox column (`with_checkbox`) asks `selectable` too, and is
|
|
12032
|
-
* not
|
|
12033
|
-
* before its toggle is refused (a ticked box over a row not
|
|
12034
|
-
* and its header box selects every row asking nothing. Up
|
|
12035
|
-
* the boxes were drawn and lied; with the default
|
|
12036
|
-
* they selected whatever `selectable` said.
|
|
12153
|
+
* not shown while the form is not selectable: Tabulator's row box
|
|
12154
|
+
* ticks before its toggle is refused (a ticked box over a row not
|
|
12155
|
+
* selected), and its header box selects every row asking nothing. Up
|
|
12156
|
+
* to 7.26.45 the boxes were drawn and lied; with the default
|
|
12157
|
+
* `selectableRows` they selected whatever `selectable` said. Up to
|
|
12158
|
+
* 7.26.46 `selectable` was read when the table was built; the column
|
|
12159
|
+
* now follows every write of it (mt_writing, show_row_selection).
|
|
12037
12160
|
*
|
|
12038
12161
|
* A click in a nested table stays there: it bubbled to the row that
|
|
12039
12162
|
* holds the table, whose own click listener (SelectRow's) toggled
|
|
@@ -12099,14 +12222,15 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
|
|
|
12099
12222
|
cell.getRow().delete();
|
|
12100
12223
|
}
|
|
12101
12224
|
});
|
|
12102
|
-
if (with_checkbox
|
|
12225
|
+
if (with_checkbox) tabulator_settings.rowHeader = {
|
|
12103
12226
|
formatter: "rowSelection",
|
|
12104
12227
|
titleFormatter: "rowSelection",
|
|
12105
12228
|
headerSort: false,
|
|
12106
12229
|
resizable: false,
|
|
12107
12230
|
frozen: true,
|
|
12108
12231
|
headerHozAlign: "center",
|
|
12109
|
-
hozAlign: "center"
|
|
12232
|
+
hozAlign: "center",
|
|
12233
|
+
visible: gobj_read_bool_attr(gobj, "selectable")
|
|
12110
12234
|
};
|
|
12111
12235
|
let tabulator = new TabulatorFull($extend, tabulator_settings);
|
|
12112
12236
|
tabulator.on("dataChanged", function() {
|
|
@@ -12116,10 +12240,19 @@ function create_tabulator$1(gobj, $extend, name, template, rows) {
|
|
|
12116
12240
|
$extend.addEventListener("input", function(ev) {
|
|
12117
12241
|
let $target = ev.target;
|
|
12118
12242
|
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);
|
|
12243
|
+
gobj_send_event(gobj, "EV_RECORD_CHANGED", { typed_in: table_identity(gobj, $extend) }, gobj);
|
|
12244
|
+
});
|
|
12245
|
+
tabulator.on("cellEditing", function() {
|
|
12246
|
+
if (gobj_is_destroying(gobj)) return;
|
|
12247
|
+
gobj_send_event(gobj, "EV_CELL_EDIT_OPENED", { table_id: table_identity(gobj, $extend) }, gobj);
|
|
12248
|
+
});
|
|
12249
|
+
tabulator.on("cellEditCancelled", function() {
|
|
12250
|
+
if (gobj_is_destroying(gobj)) return;
|
|
12251
|
+
gobj_send_event(gobj, "EV_CELL_EDIT_CANCELLED", { table_id: table_identity(gobj, $extend) }, gobj);
|
|
12120
12252
|
});
|
|
12121
12253
|
$extend.yui_pending_rows = null;
|
|
12122
12254
|
tabulator.on("tableBuilt", function() {
|
|
12255
|
+
show_row_selection(gobj, tabulator);
|
|
12123
12256
|
let rows = $extend.yui_pending_rows;
|
|
12124
12257
|
$extend.yui_pending_rows = null;
|
|
12125
12258
|
if (rows && !gobj_is_destroying(gobj)) gobj_send_event(gobj, "EV_LOAD_TABLE_ROWS", {
|
|
@@ -12274,6 +12407,9 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12274
12407
|
case "time":
|
|
12275
12408
|
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
12276
12409
|
column.editorParams = { verticalNavigation: "table" };
|
|
12410
|
+
column.formatter = function(cell) {
|
|
12411
|
+
return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
|
|
12412
|
+
};
|
|
12277
12413
|
break;
|
|
12278
12414
|
case "color":
|
|
12279
12415
|
column.editor = "input";
|
|
@@ -12761,7 +12897,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
|
|
|
12761
12897
|
case "url": break;
|
|
12762
12898
|
case "now":
|
|
12763
12899
|
case "time":
|
|
12764
|
-
value =
|
|
12900
|
+
value = time_value_to_date(value, field_desc.real_type);
|
|
12765
12901
|
break;
|
|
12766
12902
|
case "date":
|
|
12767
12903
|
case "color":
|
|
@@ -12855,10 +12991,9 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
|
|
|
12855
12991
|
case "time":
|
|
12856
12992
|
switch (real_type) {
|
|
12857
12993
|
case "string":
|
|
12858
|
-
if (value && is_date(value)) value = value.toISOString();
|
|
12859
|
-
break;
|
|
12860
12994
|
case "integer":
|
|
12861
|
-
if (
|
|
12995
|
+
if (is_date(value)) value = Math.floor(value.getTime() / 1e3);
|
|
12996
|
+
value = epoch_to_time_value(value, real_type);
|
|
12862
12997
|
break;
|
|
12863
12998
|
default: log_error("incompatible type for time: " + real_type);
|
|
12864
12999
|
}
|
|
@@ -13106,7 +13241,44 @@ function ac_load_table_rows(gobj, event, kw, src) {
|
|
|
13106
13241
|
* Internal event
|
|
13107
13242
|
************************************************************/
|
|
13108
13243
|
function ac_record_changed(gobj, event, kw, src) {
|
|
13109
|
-
if (gobj_read_bool_attr(gobj, "initialized"))
|
|
13244
|
+
if (gobj_read_bool_attr(gobj, "initialized")) {
|
|
13245
|
+
let priv = gobj.priv;
|
|
13246
|
+
let open = priv.cell_edit;
|
|
13247
|
+
let own = !!(open && kw && kw.typed_in === open.table_id && open.seq === priv.change_seq);
|
|
13248
|
+
set_edited_by_reader(gobj);
|
|
13249
|
+
if (own) open.seq = priv.change_seq;
|
|
13250
|
+
}
|
|
13251
|
+
return 0;
|
|
13252
|
+
}
|
|
13253
|
+
/************************************************************
|
|
13254
|
+
* A cell editor opened, in the table `table_id`: what the form
|
|
13255
|
+
* says now is what a cancel of it gives back.
|
|
13256
|
+
************************************************************/
|
|
13257
|
+
function ac_cell_edit_opened(gobj, event, kw, src) {
|
|
13258
|
+
let priv = gobj.priv;
|
|
13259
|
+
priv.cell_edit = {
|
|
13260
|
+
table_id: kw.table_id,
|
|
13261
|
+
edited: gobj_read_bool_attr(gobj, "edited"),
|
|
13262
|
+
changes: gobj_read_bool_attr(gobj, "changes"),
|
|
13263
|
+
seq: priv.change_seq
|
|
13264
|
+
};
|
|
13265
|
+
return 0;
|
|
13266
|
+
}
|
|
13267
|
+
/************************************************************
|
|
13268
|
+
* A cell editor cancelled -- Escape, or a box left as it was:
|
|
13269
|
+
* the value comes back, and so do the `edited` and `changes` the
|
|
13270
|
+
* form had when it opened. Up to gobj-ui 7.26.46 what was typed
|
|
13271
|
+
* in it still counted, and closing asked about a change that was
|
|
13272
|
+
* gone. Nothing is given back when anything but that editor's
|
|
13273
|
+
* own typing changed the form meanwhile: that change is real.
|
|
13274
|
+
************************************************************/
|
|
13275
|
+
function ac_cell_edit_cancelled(gobj, event, kw, src) {
|
|
13276
|
+
let priv = gobj.priv;
|
|
13277
|
+
let open = priv.cell_edit;
|
|
13278
|
+
priv.cell_edit = null;
|
|
13279
|
+
if (!open || open.table_id !== kw.table_id || open.seq !== priv.change_seq) return 0;
|
|
13280
|
+
if (gobj_read_bool_attr(gobj, "changes") !== open.changes) set_changed_stated(gobj, open.changes);
|
|
13281
|
+
gobj_write_bool_attr(gobj, "edited", open.edited);
|
|
13110
13282
|
return 0;
|
|
13111
13283
|
}
|
|
13112
13284
|
/************************************************************
|
|
@@ -13250,6 +13422,7 @@ function cmd_get_picked_files(gobj, cmd, kw, src) {
|
|
|
13250
13422
|
}
|
|
13251
13423
|
var gmt$17 = {
|
|
13252
13424
|
mt_create: mt_create$17,
|
|
13425
|
+
mt_writing: mt_writing$2,
|
|
13253
13426
|
mt_start: mt_start$17,
|
|
13254
13427
|
mt_stop: mt_stop$17,
|
|
13255
13428
|
mt_destroy: mt_destroy$17,
|
|
@@ -13299,6 +13472,16 @@ function create_gclass$17(gclass_name) {
|
|
|
13299
13472
|
ac_record_changed,
|
|
13300
13473
|
null
|
|
13301
13474
|
],
|
|
13475
|
+
[
|
|
13476
|
+
"EV_CELL_EDIT_OPENED",
|
|
13477
|
+
ac_cell_edit_opened,
|
|
13478
|
+
null
|
|
13479
|
+
],
|
|
13480
|
+
[
|
|
13481
|
+
"EV_CELL_EDIT_CANCELLED",
|
|
13482
|
+
ac_cell_edit_cancelled,
|
|
13483
|
+
null
|
|
13484
|
+
],
|
|
13302
13485
|
[
|
|
13303
13486
|
"EV_COPY_RECORD",
|
|
13304
13487
|
ac_copy_record,
|
|
@@ -13368,6 +13551,8 @@ function create_gclass$17(gclass_name) {
|
|
|
13368
13551
|
["EV_ADD_TABLE_ROW", 0],
|
|
13369
13552
|
["EV_LOAD_TABLE_ROWS", 0],
|
|
13370
13553
|
["EV_RECORD_CHANGED", 0],
|
|
13554
|
+
["EV_CELL_EDIT_OPENED", 0],
|
|
13555
|
+
["EV_CELL_EDIT_CANCELLED", 0],
|
|
13371
13556
|
["EV_COPY_RECORD", 0],
|
|
13372
13557
|
["EV_PASTE_RECORD", 0],
|
|
13373
13558
|
["EV_SET_FILE_PREVIEW", 0],
|
|
@@ -32477,8 +32662,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
|
|
|
32477
32662
|
switch (field_desc.real_type) {
|
|
32478
32663
|
case "string":
|
|
32479
32664
|
case "integer":
|
|
32480
|
-
value =
|
|
32481
|
-
|
|
32665
|
+
value = time_value_to_date(value, field_desc.real_type);
|
|
32666
|
+
if (!value) {
|
|
32667
|
+
value = "";
|
|
32668
|
+
break;
|
|
32669
|
+
}
|
|
32482
32670
|
const rawLocale = navigator.language;
|
|
32483
32671
|
const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
|
|
32484
32672
|
const formatter = new Intl.DateTimeFormat(userLocale, {
|