@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.
@@ -181,7 +181,7 @@ let PRIVATE_DATA = {
181
181
  event_handlers: {},
182
182
  hash_handler: null,
183
183
  keydown_handler: null,
184
- /* Escape priority chain: array of { layer, handler }. Each
184
+ /* Escape priority chain: array of { layer, handler, teardown }. Each
185
185
  * interactive overlay (drawer today, modal/popup tomorrow)
186
186
  * pushes its close handler when it opens and pops it when
187
187
  * it closes. Escape calls the top handler only — LIFO. */
@@ -579,9 +579,11 @@ function mt_stop(gobj)
579
579
  return 0;
580
580
  }
581
581
 
582
- /* Tear down any toolbar dropdown that was open at stop time so its
583
- * document-level mousedown listener and escape-stack entry don't
584
- * outlive the shell. */
582
+ /* Tear down every overlay that was open at stop time -- drawers,
583
+ * modals, questions, the toolbar dropdown -- so no focus trap,
584
+ * document-level listener or escape-stack entry outlives the
585
+ * shell. */
586
+ close_overlays(gobj);
585
587
  close_toolbar_dropdown(gobj);
586
588
 
587
589
  if(priv.hash_handler) {
@@ -654,7 +656,8 @@ function mt_destroy(gobj)
654
656
  * dropdown; calling close_toolbar_dropdown here is idempotent
655
657
  * (it returns early when nothing is open) and prevents a
656
658
  * dangling document mousedown listener / escape-stack entry
657
- * when stop is skipped. */
659
+ * when stop is skipped. The other overlays the same way. */
660
+ close_overlays(gobj);
658
661
  close_toolbar_dropdown(gobj);
659
662
 
660
663
  let live_idx = __live_shells__.indexOf(gobj);
@@ -2533,7 +2536,7 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
2533
2536
  $panel.__yui_backdrop_handler__ = backdrop;
2534
2537
  $panel.__yui_dismiss_handler__ = dismiss;
2535
2538
  $panel.__yui_trigger__ = $trigger || null;
2536
- push_escape(gobj, "popup", close_fn);
2539
+ push_escape(gobj, "popup", close_fn, close_fn);
2537
2540
 
2538
2541
  /* Focus trap inside the panel — same module modals/drawers use. */
2539
2542
  $panel.__yui_focus_release__ = activate_focus_trap_on($panel);
@@ -2748,8 +2751,12 @@ function take_back_focus(ev)
2748
2751
  * only and consumes the event; LIFO ordering naturally matches
2749
2752
  * the z-index layering most apps use (drawer at the bottom,
2750
2753
  * modal on top, popup on top of that).
2754
+ *
2755
+ * `teardown` is the overlay's UNCONDITIONAL close, what the shell
2756
+ * runs when it stops with the overlay still up (close_overlays);
2757
+ * `handler` may be a guarded one (a modal's before_close).
2751
2758
  ************************************************************/
2752
- function push_escape(gobj, layer, handler)
2759
+ function push_escape(gobj, layer, handler, teardown)
2753
2760
  {
2754
2761
  let priv = gobj.priv;
2755
2762
  if(!priv || !priv.escape_stack) {
@@ -2757,7 +2764,42 @@ function push_escape(gobj, layer, handler)
2757
2764
  return;
2758
2765
  }
2759
2766
  priv.escape_seq += 1;
2760
- priv.escape_stack.push({ layer: layer, handler: handler, seq: priv.escape_seq });
2767
+ priv.escape_stack.push({
2768
+ layer: layer,
2769
+ handler: handler,
2770
+ teardown: (typeof teardown === "function") ? teardown : null,
2771
+ seq: priv.escape_seq
2772
+ });
2773
+ }
2774
+
2775
+ /************************************************************
2776
+ * Close every overlay still up, the top first, as if each had
2777
+ * been dismissed: a shell that stops -- a logout, a session cut
2778
+ * -- with a drawer, a modal or a question open. Up to gobj-ui
2779
+ * 7.26.45 only the toolbar dropdown was closed: the others kept
2780
+ * their focus trap, and every window opened afterwards believed
2781
+ * itself under an overlay and took no focus; a question never
2782
+ * answered. Run before the views stop, so what an overlay's
2783
+ * on_close calls is still alive. An overlay pushed with no
2784
+ * teardown is left to its owner.
2785
+ ************************************************************/
2786
+ function close_overlays(gobj)
2787
+ {
2788
+ let priv = gobj.priv;
2789
+ if(!priv || !priv.escape_stack) {
2790
+ return;
2791
+ }
2792
+ let entries = priv.escape_stack.slice().reverse();
2793
+ for(let entry of entries) {
2794
+ if(!entry.teardown) {
2795
+ continue;
2796
+ }
2797
+ try {
2798
+ entry.teardown();
2799
+ } catch(e) {
2800
+ log_warning(`C_YUI_SHELL: closing the '${entry.layer}' overlay at stop failed: ${e}`);
2801
+ }
2802
+ }
2761
2803
  }
2762
2804
 
2763
2805
  function pop_escape(gobj, handler)
@@ -3170,7 +3212,7 @@ function open_drawer_one(gobj, $c)
3170
3212
  }
3171
3213
  let close_fn = () => close_drawer_one(gobj, $c);
3172
3214
  $c.__yui_close_handler__ = close_fn;
3173
- push_escape(gobj, "overlay", close_fn);
3215
+ push_escape(gobj, "overlay", close_fn, close_fn);
3174
3216
  $c.classList.add("is-active");
3175
3217
  let panel = $c.querySelector(".yui-drawer-panel") || $c;
3176
3218
  $c.__yui_focus_release__ = activate_focus_trap_on(panel);
@@ -4452,10 +4494,15 @@ function yui_shell_toggle_drawer(shell_gobj, menu_id)
4452
4494
  * `layer` is a free-form tag (e.g. "modal", "popup", "overlay").
4453
4495
  * Today it is informational; the LIFO ordering of the stack is
4454
4496
  * what determines Escape priority — and naturally matches the
4455
- * z-index layering most apps use (drawer < popup < modal). */
4456
- function yui_shell_push_escape(shell_gobj, layer, handler)
4497
+ * z-index layering most apps use (drawer < popup < modal).
4498
+ *
4499
+ * `teardown` (optional): the overlay's unconditional close, which
4500
+ * the shell runs if it stops with the overlay still up (a logout
4501
+ * with a modal open). Give it whenever `handler` may refuse to
4502
+ * close, or the overlay outlives its shell with its focus trap. */
4503
+ function yui_shell_push_escape(shell_gobj, layer, handler, teardown)
4457
4504
  {
4458
- push_escape(shell_gobj, layer, handler);
4505
+ push_escape(shell_gobj, layer, handler, teardown);
4459
4506
  }
4460
4507
  function yui_shell_pop_escape(shell_gobj, handler)
4461
4508
  {
@@ -50,6 +50,7 @@ import {
50
50
  is_gobj,
51
51
  kw_get_local_storage_value,
52
52
  kw_set_local_storage_value,
53
+ kw_remove_local_storage_value,
53
54
  gobj_read_attr,
54
55
  gobj_read_bool_attr,
55
56
  gobj_read_str_attr,
@@ -765,11 +766,24 @@ function build_ui(gobj)
765
766
  *----------------------------------------------*/
766
767
  if(gobj_read_bool_attr(gobj, "auto_save_size_and_position")) {
767
768
  if(gobj_is_service(gobj)) {
769
+ /* A bad entry is said ONCE: forgotten, the next move or
770
+ * resize saves a good one. A rect with no size is what the
771
+ * box of a window not drawn answers. One only off the screen
772
+ * is kept: x, y, width and height are the DESIRED place,
773
+ * clamped to the viewport here and on every resize
774
+ * (handleResize), so a window saved on a larger screen goes
775
+ * back there when it is plugged in again. */
768
776
  let key = `${gobj_name(gobj)}-rect`;
769
777
  let stored = kw_get_local_storage_value(key);
770
778
  let rect = whole_rect(stored);
771
779
  if(!rect && stored != null) {
772
780
  log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
781
+ kw_remove_local_storage_value(key);
782
+ } else if(rect && (rect.width <= 0 || rect.height <= 0)) {
783
+ log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' has no size ` +
784
+ `(${rect.width} x ${rect.height}): ignored`);
785
+ kw_remove_local_storage_value(key);
786
+ rect = null;
773
787
  }
774
788
  if(rect) {
775
789
  rect.x = rect.x<0?0:rect.x;
@@ -238,7 +238,7 @@ vi.mock("tabulator-tables", () => {
238
238
  const {
239
239
  SDATA_END, gclass_create,
240
240
  gobj_start_up, gobj_create_yuno, gobj_create_pure_child,
241
- gobj_start, gobj_stop, gobj_destroy, gobj_send_event, gobj_read_attr,
241
+ gobj_start, gobj_stop, gobj_destroy, gobj_send_event, gobj_read_attr, gobj_write_attr,
242
242
  set_log_callback,
243
243
  } = await import("@yuneta/gobj-js");
244
244
  const {register_c_yui_form} = await import("./c_yui_form.js");
@@ -603,6 +603,154 @@ describe("a click on a row", () => {
603
603
  });
604
604
  });
605
605
 
606
+ /* Tabulator 6.6.0's row checkbox goes through `selectableRowsCheck`
607
+ * (toggleRow), but the box ticks on its own first, so a refused
608
+ * toggle leaves it ticked over a row that is not selected; and its
609
+ * header box calls selectRow(), which asks no check at all and
610
+ * selects every row. Checked in Chromium: with `selectable: false`
611
+ * the row box ticked and selected nothing, the header selected every
612
+ * row; and with the default `selectableRows` ("highlight") the
613
+ * `selectable` of the form was not asked at all. */
614
+ describe("the checkbox column", () => {
615
+ test("is not drawn when the form is not selectable", async () => {
616
+ const {first} = build(record(), null, {with_checkbox: true, selectable: false});
617
+ await settle();
618
+ const alarms = alarms_of(first);
619
+ expect(alarms.settings.rowHeader).toBeUndefined();
620
+ expect(triggers_of(alarms, 0).settings.rowHeader).toBeUndefined();
621
+ expect(errors()).toEqual([]);
622
+ });
623
+
624
+ test("is drawn when it is, and every toggle asks the form's `selectable`", async () => {
625
+ const {form, first} = build(record(), null, {with_checkbox: true});
626
+ await settle();
627
+ const alarms = alarms_of(first);
628
+ expect(alarms.settings.rowHeader.formatter).toBe("rowSelection");
629
+ expect(typeof alarms.settings.selectableRowsCheck).toBe("function");
630
+ expect(alarms.settings.selectableRowsCheck()).toBe(true);
631
+ gobj_write_attr(form, "selectable", false);
632
+ expect(alarms.settings.selectableRowsCheck()).toBe(false);
633
+ expect(errors()).toEqual([]);
634
+ });
635
+ });
636
+
637
+ /* A cell half typed: Tabulator says `dataChanged` only when its editor
638
+ * commits, and a host that reloads the form by code asks `edited`
639
+ * first -- the reload dropped what was typed without a question. */
640
+ describe("typing in a cell editor", () => {
641
+ /* The document double does not bubble: the event is handed to the
642
+ * table's element with the box as its target, as a browser does. */
643
+ function type_in(alarms, $box)
644
+ {
645
+ alarms.element.dispatchEvent({type: "input", target: $box, bubbles: true});
646
+ }
647
+
648
+ function editing_box($row, editing)
649
+ {
650
+ const $cell = document.createElement("div");
651
+ $cell.className = editing ? "tabulator-cell tabulator-editing" : "tabulator-col";
652
+ const $box = document.createElement("input");
653
+ $cell.appendChild($box);
654
+ $row.appendChild($cell);
655
+ return $box;
656
+ }
657
+
658
+ test("is `edited` at once, before the editor commits", async () => {
659
+ const {form, first} = build(record());
660
+ await settle();
661
+ const alarms = alarms_of(first);
662
+ expect(gobj_read_attr(form, "edited")).toBe(false);
663
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
664
+ expect(gobj_read_attr(form, "edited")).toBe(true);
665
+ expect(errors()).toEqual([]);
666
+ });
667
+
668
+ test("but not a box that edits no cell (a header filter)", async () => {
669
+ const {form, first} = build(record());
670
+ await settle();
671
+ const alarms = alarms_of(first);
672
+ type_in(alarms, editing_box(alarms.element, false));
673
+ expect(gobj_read_attr(form, "edited")).toBe(false);
674
+ });
675
+ });
676
+
677
+ /* A time column was edited by Tabulator's `datetime` with a `format`,
678
+ * which needs luxon, which nobody gives gobj-ui: in Chromium it said
679
+ * "'date' editor 'format' param is dependant on luxon.js", opened
680
+ * empty, and threw when committed. */
681
+ describe("a time column of a table", () => {
682
+ test("is edited by the form's own editor, which needs no luxon", async () => {
683
+ const first = tables.length;
684
+ const app = gobj_create_pure_child(`trapp${++seq}`, "C_TEST_TR_APP", {}, yuno);
685
+ gobj_start(app);
686
+ const form = gobj_create_pure_child(`trform${seq}`, "C_YUI_FORM", {
687
+ template: {
688
+ events: {
689
+ type: "array",
690
+ flag: ["writable", "persistent", "table"],
691
+ table: {
692
+ when: {type: "integer", flag: ["writable", "persistent", "time"]}
693
+ }
694
+ }
695
+ },
696
+ record: {events: [{when: 1700000000}]},
697
+ editable: true,
698
+ }, app);
699
+ gobj_start(form);
700
+ await settle();
701
+ const column = tables[first].settings.columns.find((c) => c.field === "when");
702
+ expect(typeof column.editor).toBe("function");
703
+ const params = column.editorParams({getValue: () => 1700000000});
704
+ expect(params.format).toBeUndefined();
705
+ expect(params.elementAttributes["aria-label"]).toBe("when");
706
+ expect(params.elementAttributes.title).toBe("when");
707
+ gobj_stop(form);
708
+ gobj_destroy(form);
709
+ expect(errors()).toEqual([]);
710
+ });
711
+ });
712
+
713
+ /* A click in a nested table is the nested table's: it bubbled up to
714
+ * the row that holds it, and Tabulator 6.6.0's SelectRow -- listening
715
+ * on that row's element -- toggled the outer row too (Chromium). So
716
+ * does a Shift+press, which starts its range selection. */
717
+ describe("a click in a nested table", () => {
718
+ function event(type, init)
719
+ {
720
+ let stopped = 0;
721
+ const ev = Object.assign({
722
+ type: type,
723
+ bubbles: true,
724
+ preventDefault() {
725
+ },
726
+ stopPropagation() {
727
+ stopped++;
728
+ },
729
+ }, init || {});
730
+ return {ev, stopped: () => stopped};
731
+ }
732
+
733
+ test("does not reach the row that holds the table", async () => {
734
+ const {first} = build(record(), null, {tabulator_settings: {selectableRows: true}});
735
+ await settle();
736
+ const $nested = alarms_of(first).rows[0].$row.querySelector(".yui-tabulator-table-nested");
737
+
738
+ const click = event("click");
739
+ $nested.dispatchEvent(click.ev);
740
+ expect(click.stopped()).toBe(1);
741
+
742
+ const shift_press = event("mousedown", {shiftKey: true});
743
+ $nested.dispatchEvent(shift_press.ev);
744
+ expect(shift_press.stopped()).toBe(1);
745
+
746
+ /* A plain press goes on: what closes a popup listens for it. */
747
+ const press = event("mousedown", {shiftKey: false});
748
+ $nested.dispatchEvent(press.ev);
749
+ expect(press.stopped()).toBe(0);
750
+ expect(errors()).toEqual([]);
751
+ });
752
+ });
753
+
606
754
  describe("a cell editor open while its table goes", () => {
607
755
  function warnings()
608
756
  {
@@ -642,4 +790,19 @@ describe("a cell editor open while its table goes", () => {
642
790
  expect(live() - before).toBe(0);
643
791
  expect(warnings()).toEqual([]);
644
792
  });
793
+
794
+ /* The guard reads Tabulator's edit module, which is no public
795
+ * API: a Tabulator that moved it would leave the guard doing
796
+ * nothing, and the crash back. That is said. */
797
+ test("a Tabulator with no edit module is said, not trusted", async () => {
798
+ const {form, first} = build(record());
799
+ await settle();
800
+ const alarms = alarms_of(first);
801
+ alarms.modules.edit = {editingCell: false, cancel: () => {}}; /* renamed */
802
+ gobj_send_event(form, "EV_LOAD_RECORD", record(), form);
803
+ await settle();
804
+ const said = warnings().map((l) => l.msg);
805
+ expect(said.length).toBe(1);
806
+ expect(said[0]).toContain("has no modules.edit.currentCell/cancelEdit()");
807
+ });
645
808
  });
@@ -0,0 +1,143 @@
1
+ /****************************************************************************
2
+ * form_time_cell_editor.js
3
+ *
4
+ * The cell editor of a `time` / `now` column in a table of
5
+ * C_YUI_FORM: a `datetime-local` box, as the form's own time
6
+ * field, converting with the same helpers (form_time_value.js)
7
+ * -- an epoch in SECONDS for an integer column, an ISO text
8
+ * for a string one -- and to the second (`step` 1).
9
+ *
10
+ * Up to gobj-ui 7.26.45 the column used Tabulator's `datetime`
11
+ * editor with a `format`, which needs luxon, and nothing gives
12
+ * gobj-ui luxon: the editor said "'date' editor 'format' param
13
+ * is dependant on luxon.js" in the console, opened empty, and
14
+ * threw when it was committed. Its format ("dd/MM/yyyy hh:mm",
15
+ * 12-hour) could not have read an epoch either. Luxon is not
16
+ * taken in for it: one editor is not worth a dependency every
17
+ * app would have to dedupe, and the conversion it needs is the
18
+ * one the form already makes.
19
+ *
20
+ * It behaves as Tabulator's own: `elementAttributes` are
21
+ * written on the box (the column's name, see
22
+ * yui_tabulator_name_editor), a true blur or Enter commits,
23
+ * Escape cancels, `verticalNavigation: "editor"` keeps the
24
+ * arrows, and a value that did not change is a cancel.
25
+ *
26
+ * Copyright (c) 2026, ArtGins.
27
+ * All Rights Reserved.
28
+ ****************************************************************************/
29
+ import {date_to_datetime_local, datetime_local_to_epoch} from "./form_time_value.js";
30
+
31
+ /************************************************************
32
+ * A cell's value -> the text of the box ("" when empty).
33
+ ************************************************************/
34
+ function time_to_datetime_local(value, real_type)
35
+ {
36
+ if(value === null || value === undefined || value === "") {
37
+ return "";
38
+ }
39
+ if(real_type === "string") {
40
+ return date_to_datetime_local(new Date(String(value)));
41
+ }
42
+ let seconds = Number(value);
43
+ if(!Number.isFinite(seconds)) {
44
+ return "";
45
+ }
46
+ return date_to_datetime_local(new Date(seconds * 1000));
47
+ }
48
+
49
+ /************************************************************
50
+ * The text of the box -> the cell's value (null when empty).
51
+ ************************************************************/
52
+ function datetime_local_to_time(text, real_type)
53
+ {
54
+ let epoch = datetime_local_to_epoch(text);
55
+ if(epoch === null) {
56
+ return null;
57
+ }
58
+ if(real_type === "string") {
59
+ return new Date(epoch * 1000).toISOString();
60
+ }
61
+ return epoch;
62
+ }
63
+
64
+ /************************************************************
65
+ * The editor of a time column whose values are `real_type`
66
+ * ("integer": epoch seconds; "string": ISO text).
67
+ ************************************************************/
68
+ function form_time_cell_editor(real_type)
69
+ {
70
+ return function(cell, onRendered, success, cancel, editorParams) {
71
+ let params = editorParams || {};
72
+ let vertical = params.verticalNavigation || "editor";
73
+ let original = cell.getValue();
74
+ let original_text = time_to_datetime_local(original, real_type);
75
+
76
+ let input = document.createElement("input");
77
+ input.type = "datetime-local";
78
+ input.setAttribute("step", "1");
79
+ input.style.padding = "4px";
80
+ input.style.width = "100%";
81
+ input.style.boxSizing = "border-box";
82
+ let attrs = params.elementAttributes;
83
+ if(attrs && typeof attrs === "object") {
84
+ for(let key of Object.keys(attrs)) {
85
+ input.setAttribute(key, attrs[key]);
86
+ }
87
+ }
88
+ input.value = original_text;
89
+
90
+ onRendered(function() {
91
+ if(cell.getType() === "cell") {
92
+ input.focus({preventScroll: true});
93
+ input.style.height = "100%";
94
+ }
95
+ });
96
+
97
+ let commit = function() {
98
+ if(input.value === original_text) {
99
+ cancel();
100
+ return;
101
+ }
102
+ let value = datetime_local_to_time(input.value, real_type);
103
+ if(value === original || (value === null && original_text === "")) {
104
+ cancel();
105
+ return;
106
+ }
107
+ success(value);
108
+ };
109
+
110
+ /* Only a TRUE blur: not the one of the browser's own picker. */
111
+ input.addEventListener("blur", function(e) {
112
+ if(e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {
113
+ commit();
114
+ }
115
+ });
116
+
117
+ input.addEventListener("keydown", function(e) {
118
+ switch(e.key) {
119
+ case "Enter":
120
+ commit();
121
+ break;
122
+ case "Escape":
123
+ cancel();
124
+ break;
125
+ case "End":
126
+ case "Home":
127
+ e.stopPropagation();
128
+ break;
129
+ case "ArrowUp":
130
+ case "ArrowDown":
131
+ if(vertical === "editor") {
132
+ e.stopImmediatePropagation();
133
+ e.stopPropagation();
134
+ }
135
+ break;
136
+ }
137
+ });
138
+
139
+ return input;
140
+ };
141
+ }
142
+
143
+ export {form_time_cell_editor, time_to_datetime_local, datetime_local_to_time};
@@ -0,0 +1,116 @@
1
+ /***********************************************************************
2
+ * form_time_cell_editor.test.js
3
+ *
4
+ * The cell editor of a time column of C_YUI_FORM's tables. Up to
5
+ * gobj-ui 7.26.45 it was Tabulator's `datetime` with a `format`,
6
+ * which needs luxon -- nobody gives gobj-ui luxon: it opened empty,
7
+ * said so in the console, and threw when committed.
8
+ *
9
+ * Copyright (c) 2026, ArtGins.
10
+ * All Rights Reserved.
11
+ ***********************************************************************/
12
+ import {describe, test, expect} from "vitest";
13
+ import {install_dom_double} from "../test/dom_double.js";
14
+
15
+ install_dom_double();
16
+
17
+ const {
18
+ form_time_cell_editor, time_to_datetime_local, datetime_local_to_time,
19
+ } = await import("./form_time_cell_editor.js");
20
+ const {date_to_datetime_local} = await import("./form_time_value.js");
21
+
22
+ /* A local wall time and its epoch, whatever the zone of the run. */
23
+ const WALL = "2026-03-14T09:26:53";
24
+ const EPOCH = Math.floor(new Date(WALL).getTime() / 1000);
25
+
26
+ function open_editor(value, real_type, params)
27
+ {
28
+ const said = {success: [], cancel: 0, rendered: null};
29
+ const cell = {
30
+ getValue: () => value,
31
+ getType: () => "cell",
32
+ };
33
+ const $input = form_time_cell_editor(real_type)(
34
+ cell,
35
+ (fn) => {
36
+ said.rendered = fn;
37
+ },
38
+ (v) => {
39
+ said.success.push(v);
40
+ return true;
41
+ },
42
+ () => {
43
+ said.cancel++;
44
+ },
45
+ params || {}
46
+ );
47
+ return {$input, said};
48
+ }
49
+
50
+ function key(name)
51
+ {
52
+ return {
53
+ type: "keydown", key: name,
54
+ stopPropagation() {}, stopImmediatePropagation() {}, preventDefault() {},
55
+ };
56
+ }
57
+
58
+ describe("a time column's cell editor", () => {
59
+ test("shows an epoch in seconds as a local time, to the second", () => {
60
+ const {$input} = open_editor(EPOCH, "integer");
61
+ expect($input.type).toBe("datetime-local");
62
+ expect($input.getAttribute("step")).toBe("1");
63
+ expect($input.value).toBe(WALL);
64
+ });
65
+
66
+ test("gives back an epoch in seconds", () => {
67
+ const {$input, said} = open_editor(EPOCH, "integer");
68
+ $input.value = "2026-03-14T10:00:00";
69
+ $input.dispatchEvent(key("Enter"));
70
+ expect(said.success).toEqual([Math.floor(new Date("2026-03-14T10:00:00").getTime() / 1000)]);
71
+ });
72
+
73
+ test("an ISO text column stays an ISO text", () => {
74
+ const iso = new Date(EPOCH * 1000).toISOString();
75
+ const {$input, said} = open_editor(iso, "string");
76
+ expect($input.value).toBe(WALL);
77
+ $input.value = "2026-03-14T10:00:00";
78
+ $input.dispatchEvent(key("Enter"));
79
+ expect(said.success).toEqual([new Date("2026-03-14T10:00:00").toISOString()]);
80
+ });
81
+
82
+ test("an unchanged value is a cancel, and so is Escape", () => {
83
+ const a = open_editor(EPOCH, "integer");
84
+ a.$input.dispatchEvent(key("Enter"));
85
+ expect(a.said.success).toEqual([]);
86
+ expect(a.said.cancel).toBe(1);
87
+
88
+ const b = open_editor(EPOCH, "integer");
89
+ b.$input.value = "2026-03-14T10:00:00";
90
+ b.$input.dispatchEvent(key("Escape"));
91
+ expect(b.said.success).toEqual([]);
92
+ expect(b.said.cancel).toBe(1);
93
+ });
94
+
95
+ test("an empty cell opens empty, and emptied commits null", () => {
96
+ const {$input, said} = open_editor(EPOCH, "integer");
97
+ $input.value = "";
98
+ $input.dispatchEvent(key("Enter"));
99
+ expect(said.success).toEqual([null]);
100
+ expect(open_editor(null, "integer").$input.value).toBe("");
101
+ expect(open_editor(undefined, "string").$input.value).toBe("");
102
+ });
103
+
104
+ test("writes the attributes it is given: the column's name", () => {
105
+ const {$input} = open_editor(EPOCH, "integer", {
106
+ elementAttributes: {"aria-label": "since", title: "since"}
107
+ });
108
+ expect($input.getAttribute("aria-label")).toBe("since");
109
+ expect($input.getAttribute("title")).toBe("since");
110
+ });
111
+
112
+ test("the conversions are each other's inverse", () => {
113
+ expect(datetime_local_to_time(time_to_datetime_local(EPOCH, "integer"), "integer")).toBe(EPOCH);
114
+ expect(time_to_datetime_local(EPOCH, "integer")).toBe(date_to_datetime_local(new Date(EPOCH * 1000)));
115
+ });
116
+ });
@@ -111,6 +111,10 @@ import {
111
111
 
112
112
  const SRC = dirname(fileURLToPath(import.meta.url));
113
113
 
114
+ /* The tests that parse every module of the library take a second or
115
+ * more alone, and brushed vitest's 5 s with the whole suite running. */
116
+ const SLOW_SCAN_MS = 30000;
117
+
114
118
  const MODULES = readdirSync(SRC)
115
119
  .filter((f) => f.endsWith(".js") && !f.endsWith(".test.js"))
116
120
  .sort();
@@ -1122,11 +1126,11 @@ describe("I18N_KEY_FUNCTIONS: the table", () => {
1122
1126
  describe("REV-CLOUD V21.4.1: every forwarder is in the table", () => {
1123
1127
  test("every function that hands a parameter to a place a key is read, in every module", () => {
1124
1128
  expect(forwarders_report(find_forwarders())).toEqual([]);
1125
- });
1129
+ }, SLOW_SCAN_MS);
1126
1130
 
1127
1131
  test("REV-CLOUD V22: the table is CORRECT -- every entry is a hand-off the library shows", () => {
1128
1132
  expect(table_errors(find_forwarders(MODULES, ast_of, []).found)).toEqual([]);
1129
- });
1133
+ }, SLOW_SCAN_MS);
1130
1134
 
1131
1135
  test("every fallback of the table is one in the code, and the check fails when it is not", () => {
1132
1136
  expect(fallback_errors()).toEqual([]);
@@ -1222,7 +1226,7 @@ describe("REV-CLOUD V21.4.1: every forwarder is in the table", () => {
1222
1226
  let unmarked = parse_as(code.replace(/\/\* i18n: data \*\/ /g, ""), module);
1223
1227
  expect(find_forwarders([module], () => unmarked).unmarked.map((u) => u.name))
1224
1228
  .toContain("ac_register_window");
1225
- });
1229
+ }, SLOW_SCAN_MS);
1226
1230
  });
1227
1231
 
1228
1232
  describe("a `code` is a key where the library makes one", () => {
@@ -2081,7 +2085,7 @@ describe("REV-CLOUD V22.2: what the search for forwarders sees, and what fails i
2081
2085
  /* ...as the real table was, before V22: an action label that went
2082
2086
  * through a DOM property, a flag that hid an export */
2083
2087
  expect(table_errors(found)).toEqual([]);
2084
- });
2088
+ }, SLOW_SCAN_MS);
2085
2089
  });
2086
2090
 
2087
2091
  describe("REV-CLOUD V22.3-4: the data marker hides no key; one notion of a translator", () => {