@yuneta/gobj-ui 7.26.45 → 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.
@@ -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,25 @@ 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
- if(!rect && stored != null) {
779
+ /* Text that is not json reads as nothing, as no entry does */
780
+ if(!rect && local_storage_holds(key)) {
772
781
  log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' is not a rect of four numbers: ignored`);
782
+ kw_remove_local_storage_value(key);
783
+ } else if(rect && (rect.width <= 0 || rect.height <= 0)) {
784
+ log_warning(`${gobj_short_name(gobj)}: the saved position '${key}' has no size ` +
785
+ `(${rect.width} x ${rect.height}): ignored`);
786
+ kw_remove_local_storage_value(key);
787
+ rect = null;
773
788
  }
774
789
  if(rect) {
775
790
  rect.x = rect.x<0?0:rect.x;
@@ -1338,6 +1353,19 @@ function min(gobj)
1338
1353
  return rect;
1339
1354
  }
1340
1355
 
1356
+ /************************************************************
1357
+ * Whether localStorage holds anything under `key`, readable
1358
+ * or not.
1359
+ ************************************************************/
1360
+ function local_storage_holds(key)
1361
+ {
1362
+ try {
1363
+ return window.localStorage.getItem(key) !== null;
1364
+ } catch(e) {
1365
+ return false; // no storage: nothing is kept in it either
1366
+ }
1367
+ }
1368
+
1341
1369
  /************************************************************
1342
1370
  * The rect of a window in whole pixels: x, y, width and height
1343
1371
  * are DTP_INTEGER, and getBoundingClientRect() answers fractions
@@ -60,6 +60,7 @@ vi.mock("tabulator-tables", () => {
60
60
  this.initialized = false;
61
61
  this.destroyed = false;
62
62
  this.rows = [];
63
+ this.row_header = null;
63
64
  this.calls = {addRow: 0, addData: 0, redraw: 0};
64
65
  this.modules = {
65
66
  localize: {
@@ -166,6 +167,28 @@ vi.mock("tabulator-tables", () => {
166
167
  getRows() {
167
168
  return this.rows.map((row) => row.component);
168
169
  }
170
+ /* The structured columns start with the row header, as
171
+ * Tabulator's (ColumnManager.columns). */
172
+ getColumns(structured) {
173
+ const def = this.settings && this.settings.rowHeader;
174
+ if(!structured || !def) {
175
+ return [];
176
+ }
177
+ if(!this.row_header) {
178
+ const header = {visible: def.visible !== false};
179
+ this.row_header = {
180
+ getDefinition: () => def,
181
+ isVisible: () => header.visible,
182
+ show: () => {
183
+ header.visible = true;
184
+ },
185
+ hide: () => {
186
+ header.visible = false;
187
+ },
188
+ };
189
+ }
190
+ return [this.row_header];
191
+ }
169
192
  getData() {
170
193
  return this.rows.map((row) => structuredClone(row.data));
171
194
  }
@@ -238,7 +261,7 @@ vi.mock("tabulator-tables", () => {
238
261
  const {
239
262
  SDATA_END, gclass_create,
240
263
  gobj_start_up, gobj_create_yuno, gobj_create_pure_child,
241
- gobj_start, gobj_stop, gobj_destroy, gobj_send_event, gobj_read_attr,
264
+ gobj_start, gobj_stop, gobj_destroy, gobj_send_event, gobj_read_attr, gobj_write_attr,
242
265
  set_log_callback,
243
266
  } = await import("@yuneta/gobj-js");
244
267
  const {register_c_yui_form} = await import("./c_yui_form.js");
@@ -603,6 +626,297 @@ describe("a click on a row", () => {
603
626
  });
604
627
  });
605
628
 
629
+ /* Tabulator 6.6.0's row checkbox goes through `selectableRowsCheck`
630
+ * (toggleRow), but the box ticks on its own first, so a refused
631
+ * toggle leaves it ticked over a row that is not selected; and its
632
+ * header box calls selectRow(), which asks no check at all and
633
+ * selects every row. Checked in Chromium: with `selectable: false`
634
+ * the row box ticked and selected nothing, the header selected every
635
+ * row; and with the default `selectableRows` ("highlight") the
636
+ * `selectable` of the form was not asked at all. */
637
+ describe("the checkbox column", () => {
638
+ test("is not shown when the form is not selectable", async () => {
639
+ const {first} = build(record(), null, {with_checkbox: true, selectable: false});
640
+ await settle();
641
+ const alarms = alarms_of(first);
642
+ expect(alarms.getColumns(true)[0].isVisible()).toBe(false);
643
+ expect(triggers_of(alarms, 0).getColumns(true)[0].isVisible()).toBe(false);
644
+ expect(errors()).toEqual([]);
645
+ });
646
+
647
+ /* Up to 7.26.46 `selectable` was read when a table was built: written
648
+ * false after it, the boxes stayed, and ticked over rows that the
649
+ * check no longer let be selected. */
650
+ test("follows `selectable` written after the tables are built", async () => {
651
+ const {form, first} = build(record(), null, {with_checkbox: true});
652
+ await settle();
653
+ const alarms = alarms_of(first);
654
+ const nested = triggers_of(alarms, 0);
655
+ expect(alarms.getColumns(true)[0].isVisible()).toBe(true);
656
+ gobj_write_attr(form, "selectable", false);
657
+ expect(alarms.getColumns(true)[0].isVisible()).toBe(false);
658
+ expect(nested.getColumns(true)[0].isVisible()).toBe(false);
659
+ gobj_write_attr(form, "selectable", true);
660
+ expect(alarms.getColumns(true)[0].isVisible()).toBe(true);
661
+ expect(nested.getColumns(true)[0].isVisible()).toBe(true);
662
+ expect(errors()).toEqual([]);
663
+ });
664
+
665
+ test("a table built after `selectable` was written follows it", async () => {
666
+ const {form, first} = build(record(), (f) => {
667
+ gobj_write_attr(f, "selectable", false);
668
+ }, {with_checkbox: true});
669
+ await settle();
670
+ expect(alarms_of(first).getColumns(true)[0].isVisible()).toBe(false);
671
+ expect(errors()).toEqual([]);
672
+ });
673
+
674
+ test("is drawn when it is, and every toggle asks the form's `selectable`", async () => {
675
+ const {form, first} = build(record(), null, {with_checkbox: true});
676
+ await settle();
677
+ const alarms = alarms_of(first);
678
+ expect(alarms.settings.rowHeader.formatter).toBe("rowSelection");
679
+ expect(typeof alarms.settings.selectableRowsCheck).toBe("function");
680
+ expect(alarms.settings.selectableRowsCheck()).toBe(true);
681
+ gobj_write_attr(form, "selectable", false);
682
+ expect(alarms.settings.selectableRowsCheck()).toBe(false);
683
+ expect(errors()).toEqual([]);
684
+ });
685
+ });
686
+
687
+ /* Enter in a box of a <form> is an implicit submission: the browser
688
+ * clicks the form's first SUBMIT button, and with none and a single text
689
+ * box it submits the form. Up to 7.26.46 the table's "add" button had no
690
+ * `type`, so it was that button: Enter in any field (or in a cell editor
691
+ * that stays open) added an empty row; and a form of one text box
692
+ * reloaded the page (Chromium and Firefox). */
693
+ describe("Enter in a box of the form", () => {
694
+ test("the table's add button is no submit button", async () => {
695
+ const {form} = build(record());
696
+ await settle();
697
+ const $container = gobj_read_attr(form, "$container");
698
+ const $buttons = Array.from($container.querySelector("form").querySelectorAll("button"));
699
+ expect($buttons.length).toBeGreaterThan(0);
700
+ for(const $b of $buttons) {
701
+ expect($b.getAttribute("type"), $b.className).toBe("button");
702
+ }
703
+ });
704
+
705
+ test("the form is never submitted", async () => {
706
+ const {form} = build(record());
707
+ await settle();
708
+ const $form = gobj_read_attr(form, "$container").querySelector("form");
709
+ let prevented = 0;
710
+ $form.dispatchEvent({type: "submit", target: $form, preventDefault() {
711
+ prevented++;
712
+ }, stopPropagation() {}});
713
+ expect(prevented).toBe(1);
714
+ });
715
+ });
716
+
717
+ /* A cell half typed: Tabulator says `dataChanged` only when its editor
718
+ * commits, and a host that reloads the form by code asks `edited`
719
+ * first -- the reload dropped what was typed without a question. */
720
+ describe("typing in a cell editor", () => {
721
+ /* The document double does not bubble: the event is handed to the
722
+ * table's element with the box as its target, as a browser does. */
723
+ function type_in(alarms, $box)
724
+ {
725
+ alarms.element.dispatchEvent({type: "input", target: $box, bubbles: true});
726
+ }
727
+
728
+ function editing_box($row, editing)
729
+ {
730
+ const $cell = document.createElement("div");
731
+ $cell.className = editing ? "tabulator-cell tabulator-editing" : "tabulator-col";
732
+ const $box = document.createElement("input");
733
+ $cell.appendChild($box);
734
+ $row.appendChild($cell);
735
+ return $box;
736
+ }
737
+
738
+ test("is `edited` at once, before the editor commits", async () => {
739
+ const {form, first} = build(record());
740
+ await settle();
741
+ const alarms = alarms_of(first);
742
+ expect(gobj_read_attr(form, "edited")).toBe(false);
743
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
744
+ expect(gobj_read_attr(form, "edited")).toBe(true);
745
+ expect(errors()).toEqual([]);
746
+ });
747
+
748
+ test("but not a box that edits no cell (a header filter)", async () => {
749
+ const {form, first} = build(record());
750
+ await settle();
751
+ const alarms = alarms_of(first);
752
+ type_in(alarms, editing_box(alarms.element, false));
753
+ expect(gobj_read_attr(form, "edited")).toBe(false);
754
+ });
755
+
756
+ /* Escape, or a box left as it was: what was typed is gone, and up
757
+ * to 7.26.46 it still counted -- closing asked about nothing. */
758
+ test("a cancelled edit gives back the `edited` the form had when it opened", async () => {
759
+ const {form, first} = build(record());
760
+ await settle();
761
+ const alarms = alarms_of(first);
762
+ alarms.emit("cellEditing");
763
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
764
+ expect(gobj_read_attr(form, "edited")).toBe(true);
765
+ alarms.emit("cellEditCancelled");
766
+ expect(gobj_read_attr(form, "edited")).toBe(false);
767
+ expect(gobj_read_attr(form, "changes")).toBe(false);
768
+ expect(close_asks(form)).toBe(false);
769
+
770
+ /* An edit already made stays one: the cancel gives back what
771
+ * was there when THIS editor opened. */
772
+ alarms.edit_cell(0, "name", "renamed");
773
+ expect(gobj_read_attr(form, "edited")).toBe(true);
774
+ alarms.emit("cellEditing");
775
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
776
+ alarms.emit("cellEditCancelled");
777
+ expect(gobj_read_attr(form, "edited")).toBe(true);
778
+ expect(errors()).toEqual([]);
779
+ });
780
+
781
+ test("a cancel gives nothing back when something else changed the form meanwhile", async () => {
782
+ const {form, first} = build(record());
783
+ await settle();
784
+ const alarms = alarms_of(first);
785
+ alarms.emit("cellEditing");
786
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
787
+ alarms.edit_cell(1, "name", "elsewhere");
788
+ alarms.emit("cellEditCancelled");
789
+ expect(gobj_read_attr(form, "edited")).toBe(true);
790
+ expect(errors()).toEqual([]);
791
+ });
792
+
793
+ test("a committed edit stays `edited`", async () => {
794
+ const {form, first} = build(record());
795
+ await settle();
796
+ const alarms = alarms_of(first);
797
+ alarms.emit("cellEditing");
798
+ type_in(alarms, editing_box(alarms.rows[0].$row, true));
799
+ alarms.edit_cell(0, "name", "typed");
800
+ expect(gobj_read_attr(form, "edited")).toBe(true);
801
+ expect(errors()).toEqual([]);
802
+ });
803
+ });
804
+
805
+ /* A time column was edited by Tabulator's `datetime` with a `format`,
806
+ * which needs luxon, which nobody gives gobj-ui: in Chromium it said
807
+ * "'date' editor 'format' param is dependant on luxon.js", opened
808
+ * empty, and threw when committed. */
809
+ describe("a time column of a table", () => {
810
+ test("is edited by the form's own editor, which needs no luxon", async () => {
811
+ const first = tables.length;
812
+ const app = gobj_create_pure_child(`trapp${++seq}`, "C_TEST_TR_APP", {}, yuno);
813
+ gobj_start(app);
814
+ const form = gobj_create_pure_child(`trform${seq}`, "C_YUI_FORM", {
815
+ template: {
816
+ events: {
817
+ type: "array",
818
+ flag: ["writable", "persistent", "table"],
819
+ table: {
820
+ when: {type: "integer", flag: ["writable", "persistent", "time"]}
821
+ }
822
+ }
823
+ },
824
+ record: {events: [{when: 1700000000}]},
825
+ editable: true,
826
+ }, app);
827
+ gobj_start(form);
828
+ await settle();
829
+ const column = tables[first].settings.columns.find((c) => c.field === "when");
830
+ expect(typeof column.editor).toBe("function");
831
+ const params = column.editorParams({getValue: () => 1700000000});
832
+ expect(params.format).toBeUndefined();
833
+ expect(params.elementAttributes["aria-label"]).toBe("when");
834
+ expect(params.elementAttributes.title).toBe("when");
835
+ gobj_stop(form);
836
+ gobj_destroy(form);
837
+ expect(errors()).toEqual([]);
838
+ });
839
+
840
+ /* Up to 7.26.46 the cell showed the raw epoch (1700000000). */
841
+ test("shows its time as the local clock the editor opens on, not the epoch", async () => {
842
+ const first = tables.length;
843
+ const app = gobj_create_pure_child(`trapp${++seq}`, "C_TEST_TR_APP", {}, yuno);
844
+ gobj_start(app);
845
+ const form = gobj_create_pure_child(`trform${seq}`, "C_YUI_FORM", {
846
+ template: {
847
+ events: {
848
+ type: "array",
849
+ flag: ["writable", "persistent", "table"],
850
+ table: {
851
+ when: {type: "integer", flag: ["writable", "persistent", "time"]},
852
+ at: {type: "string", flag: ["writable", "persistent", "time"]}
853
+ }
854
+ }
855
+ },
856
+ record: {events: []},
857
+ editable: true,
858
+ }, app);
859
+ gobj_start(form);
860
+ await settle();
861
+ const columns = tables[first].settings.columns;
862
+ const text = (field, value) => {
863
+ const column = columns.find((c) => c.field === field);
864
+ const out = column.formatter({getValue: () => value});
865
+ return typeof out === "string" ? out : out.textContent;
866
+ };
867
+ const wall = "2026-03-14T09:26:53";
868
+ const epoch = Math.floor(new Date(wall).getTime() / 1000);
869
+ expect(text("when", epoch)).toBe("2026-03-14 09:26:53");
870
+ expect(text("at", new Date(epoch * 1000).toISOString())).toBe("2026-03-14 09:26:53");
871
+ expect(text("when", null)).toBe("");
872
+ expect(text("at", "not a time")).toBe("not a time");
873
+ gobj_stop(form);
874
+ gobj_destroy(form);
875
+ expect(errors()).toEqual([]);
876
+ });
877
+ });
878
+
879
+ /* A click in a nested table is the nested table's: it bubbled up to
880
+ * the row that holds it, and Tabulator 6.6.0's SelectRow -- listening
881
+ * on that row's element -- toggled the outer row too (Chromium). So
882
+ * does a Shift+press, which starts its range selection. */
883
+ describe("a click in a nested table", () => {
884
+ function event(type, init)
885
+ {
886
+ let stopped = 0;
887
+ const ev = Object.assign({
888
+ type: type,
889
+ bubbles: true,
890
+ preventDefault() {
891
+ },
892
+ stopPropagation() {
893
+ stopped++;
894
+ },
895
+ }, init || {});
896
+ return {ev, stopped: () => stopped};
897
+ }
898
+
899
+ test("does not reach the row that holds the table", async () => {
900
+ const {first} = build(record(), null, {tabulator_settings: {selectableRows: true}});
901
+ await settle();
902
+ const $nested = alarms_of(first).rows[0].$row.querySelector(".yui-tabulator-table-nested");
903
+
904
+ const click = event("click");
905
+ $nested.dispatchEvent(click.ev);
906
+ expect(click.stopped()).toBe(1);
907
+
908
+ const shift_press = event("mousedown", {shiftKey: true});
909
+ $nested.dispatchEvent(shift_press.ev);
910
+ expect(shift_press.stopped()).toBe(1);
911
+
912
+ /* A plain press goes on: what closes a popup listens for it. */
913
+ const press = event("mousedown", {shiftKey: false});
914
+ $nested.dispatchEvent(press.ev);
915
+ expect(press.stopped()).toBe(0);
916
+ expect(errors()).toEqual([]);
917
+ });
918
+ });
919
+
606
920
  describe("a cell editor open while its table goes", () => {
607
921
  function warnings()
608
922
  {
@@ -642,4 +956,19 @@ describe("a cell editor open while its table goes", () => {
642
956
  expect(live() - before).toBe(0);
643
957
  expect(warnings()).toEqual([]);
644
958
  });
959
+
960
+ /* The guard reads Tabulator's edit module, which is no public
961
+ * API: a Tabulator that moved it would leave the guard doing
962
+ * nothing, and the crash back. That is said. */
963
+ test("a Tabulator with no edit module is said, not trusted", async () => {
964
+ const {form, first} = build(record());
965
+ await settle();
966
+ const alarms = alarms_of(first);
967
+ alarms.modules.edit = {editingCell: false, cancel: () => {}}; /* renamed */
968
+ gobj_send_event(form, "EV_LOAD_RECORD", record(), form);
969
+ await settle();
970
+ const said = warnings().map((l) => l.msg);
971
+ expect(said.length).toBe(1);
972
+ expect(said[0]).toContain("has no modules.edit.currentCell/cancelEdit()");
973
+ });
645
974
  });
@@ -0,0 +1,160 @@
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
+ * A date with a part cleared is NOT a value: the box answers
27
+ * `value ""` for it, as for an empty box, and only
28
+ * `validity.badInput` tells them apart. Enter leaves the
29
+ * editor open with `aria-invalid` until the date is whole
30
+ * again (or Escape); a blur cancels, and the cell keeps what
31
+ * it had. Up to gobj-ui 7.26.46 both committed null: one
32
+ * Backspace and Enter erased the stored time. To clear a time
33
+ * on purpose, clear EVERY part of the box: an empty box
34
+ * commits null. (Inside the box Tab moves between its parts,
35
+ * as the browser does: it does not leave the cell.)
36
+ *
37
+ * Copyright (c) 2026, ArtGins.
38
+ * All Rights Reserved.
39
+ ****************************************************************************/
40
+ import {
41
+ date_to_datetime_local, datetime_local_to_epoch, time_value_to_date, epoch_to_time_value
42
+ } from "./form_time_value.js";
43
+
44
+ /************************************************************
45
+ * A cell's value -> the text of the box ("" when empty).
46
+ ************************************************************/
47
+ function time_to_datetime_local(value, real_type)
48
+ {
49
+ return date_to_datetime_local(time_value_to_date(value, real_type));
50
+ }
51
+
52
+ /************************************************************
53
+ * The text of the box -> the cell's value (null when empty).
54
+ ************************************************************/
55
+ function datetime_local_to_time(text, real_type)
56
+ {
57
+ return epoch_to_time_value(datetime_local_to_epoch(text), real_type);
58
+ }
59
+
60
+ /************************************************************
61
+ * The editor of a time column whose values are `real_type`
62
+ * ("integer": epoch seconds; "string": ISO text).
63
+ ************************************************************/
64
+ function form_time_cell_editor(real_type)
65
+ {
66
+ return function(cell, onRendered, success, cancel, editorParams) {
67
+ let params = editorParams || {};
68
+ let vertical = params.verticalNavigation || "editor";
69
+ let original = cell.getValue();
70
+ let original_text = time_to_datetime_local(original, real_type);
71
+
72
+ let input = document.createElement("input");
73
+ input.type = "datetime-local";
74
+ input.setAttribute("step", "1");
75
+ input.style.padding = "4px";
76
+ input.style.width = "100%";
77
+ input.style.boxSizing = "border-box";
78
+ let attrs = params.elementAttributes;
79
+ if(attrs && typeof attrs === "object") {
80
+ for(let key of Object.keys(attrs)) {
81
+ input.setAttribute(key, attrs[key]);
82
+ }
83
+ }
84
+ input.value = original_text;
85
+
86
+ onRendered(function() {
87
+ if(cell.getType() === "cell") {
88
+ input.focus({preventScroll: true});
89
+ input.style.height = "100%";
90
+ }
91
+ });
92
+
93
+ /* A part of the date cleared (one Backspace) reads "" as an
94
+ * empty box does: only badInput tells "not a time yet" from
95
+ * "no time". */
96
+ let incomplete = function() {
97
+ return !!(input.validity && input.validity.badInput);
98
+ };
99
+
100
+ let commit = function(from_blur) {
101
+ if(incomplete()) {
102
+ if(from_blur) {
103
+ cancel();
104
+ } else {
105
+ input.setAttribute("aria-invalid", "true");
106
+ }
107
+ return;
108
+ }
109
+ if(input.value === original_text) {
110
+ cancel();
111
+ return;
112
+ }
113
+ let value = datetime_local_to_time(input.value, real_type);
114
+ if(value === original || (value === null && original_text === "")) {
115
+ cancel();
116
+ return;
117
+ }
118
+ success(value);
119
+ };
120
+
121
+ /* Only a TRUE blur: not the one of the browser's own picker. */
122
+ input.addEventListener("blur", function(e) {
123
+ if(e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {
124
+ commit(true);
125
+ }
126
+ });
127
+
128
+ input.addEventListener("input", function() {
129
+ if(!incomplete()) {
130
+ input.removeAttribute("aria-invalid");
131
+ }
132
+ });
133
+
134
+ input.addEventListener("keydown", function(e) {
135
+ switch(e.key) {
136
+ case "Enter":
137
+ commit(false);
138
+ break;
139
+ case "Escape":
140
+ cancel();
141
+ break;
142
+ case "End":
143
+ case "Home":
144
+ e.stopPropagation();
145
+ break;
146
+ case "ArrowUp":
147
+ case "ArrowDown":
148
+ if(vertical === "editor") {
149
+ e.stopImmediatePropagation();
150
+ e.stopPropagation();
151
+ }
152
+ break;
153
+ }
154
+ });
155
+
156
+ return input;
157
+ };
158
+ }
159
+
160
+ export {form_time_cell_editor, time_to_datetime_local, datetime_local_to_time};