@yuneta/gobj-ui 7.26.49 → 7.26.51

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.
@@ -1290,6 +1290,8 @@ var PRIVATE_DATA$22 = {
1290
1290
  expected_pop_ids: [],
1291
1291
  given_up: null,
1292
1292
  own_entries: [],
1293
+ traverse_from: -1,
1294
+ entry_change_handler: null,
1293
1295
  popstate_handler: null,
1294
1296
  avatar_provider: null,
1295
1297
  avatar_nodes: [],
@@ -1365,7 +1367,13 @@ function mt_start$21(gobj) {
1365
1367
  let p = gobj.priv;
1366
1368
  if (!p) return;
1367
1369
  note_late_landing(gobj, ev);
1370
+ let from = p.traverse_from;
1371
+ p.traverse_from = -1;
1368
1372
  let hash_moved = window.location.hash !== p.last_hash;
1373
+ if (p.expected_pops === 0 && from >= 0 && retire_dead_entries(gobj, from, hash_moved)) {
1374
+ if (!p.skip_hash) p.last_hash = window.location.hash;
1375
+ return;
1376
+ }
1369
1377
  if (p.expected_pops > 0 && window.location.hash !== p.expected_pop_hash) {
1370
1378
  drop_expected_pops(gobj);
1371
1379
  on_traversal(ev);
@@ -1416,6 +1424,15 @@ function mt_start$21(gobj) {
1416
1424
  }
1417
1425
  };
1418
1426
  window.addEventListener("popstate", priv.popstate_handler);
1427
+ let nav = window.navigation;
1428
+ if (nav && typeof nav.addEventListener === "function") {
1429
+ priv.entry_change_handler = (ev) => {
1430
+ let p = gobj.priv;
1431
+ if (!p) return;
1432
+ p.traverse_from = ev && ev.navigationType === "traverse" && ev.from && typeof ev.from.index === "number" ? ev.from.index : -1;
1433
+ };
1434
+ nav.addEventListener("currententrychange", priv.entry_change_handler);
1435
+ }
1419
1436
  keep_dead_entries_across_reload();
1420
1437
  adopt_orphan_back(gobj);
1421
1438
  }
@@ -1458,6 +1475,12 @@ function mt_stop$20(gobj) {
1458
1475
  window.removeEventListener("popstate", priv.popstate_handler);
1459
1476
  priv.popstate_handler = null;
1460
1477
  }
1478
+ if (priv.entry_change_handler) {
1479
+ let nav = window.navigation;
1480
+ if (nav && typeof nav.removeEventListener === "function") nav.removeEventListener("currententrychange", priv.entry_change_handler);
1481
+ priv.entry_change_handler = null;
1482
+ }
1483
+ priv.traverse_from = -1;
1461
1484
  for (let entry of priv.pending_markers) {
1462
1485
  entry.marker_pending = false;
1463
1486
  entry.no_marker = true;
@@ -2855,7 +2878,9 @@ function retire_overlays(gobj) {
2855
2878
  *
2856
2879
  * A page with no next shell keeps them: with no router on the
2857
2880
  * page, a Back over the app's own entries changes nothing on
2858
- * screen anyway, and the next shell retires them all the same.
2881
+ * screen anyway, and the next shell retires them all the same --
2882
+ * at its start, or when a traversal of the reader's lands on them
2883
+ * if the reader moved meanwhile.
2859
2884
  ************************************************************/
2860
2885
  function hand_over_history(gobj) {
2861
2886
  let priv = gobj.priv;
@@ -2975,6 +3000,7 @@ function note_own_entry(gobj) {
2975
3000
  let priv = gobj.priv;
2976
3001
  let key = current_entry_key();
2977
3002
  if (!key || priv.own_entries.includes(key)) return;
3003
+ __dead_entries__.delete(key);
2978
3004
  priv.own_entries.push(key);
2979
3005
  if (priv.own_entries.length > OWN_ENTRIES_PRUNE_AT) {
2980
3006
  let alive = new Set(window.navigation.entries().map((e) => e.key));
@@ -2985,42 +3011,70 @@ function note_own_entry(gobj) {
2985
3011
  * Take off, with ONE history.go(-n), the dead entries a
2986
3012
  * stopped shell left under the current one (hand_over_history).
2987
3013
  * The walk stops at the first entry that is not dead, so it
2988
- * never goes past an entry of the reader's. The traversal is
2989
- * this shell's own (expected_pops): its overlays' markers and
2990
- * the routes it pushes wait for the landing, and a position
2991
- * the URL holds is put back on the entry it lands on, as for
2992
- * any back() of ours (restore_hash). Returns true when it
2993
- * went.
2994
- ************************************************************/
2995
- function retire_dead_entries(gobj) {
2996
- let priv = gobj.priv;
3014
+ * never goes past an entry of the reader's, and at the first
3015
+ * entry of the current document: a navigation to another page
3016
+ * with replace keeps the entry's key, so a later document can
3017
+ * sit on the key of a dead marker, over the entries of the one
3018
+ * before it (up to gobj-ui 7.26.50 the walk went into them and
3019
+ * that document was loaded again). After a reload every entry
3020
+ * is the new document's, and its dead ones go.
3021
+ *
3022
+ * With `from` (the index a traversal of the reader's came
3023
+ * from), it goes on over the dead entries that traversal landed
3024
+ * on, the way it was going: down to the first live one under
3025
+ * them, or up to the first live one over them -- there is none
3026
+ * when they are the newest, and nothing moves. Dead entries
3027
+ * under an entry of the reader's are taken off that way: the
3028
+ * start of a shell never goes past one.
3029
+ *
3030
+ * The traversal is this shell's own (expected_pops): its
3031
+ * overlays' markers and the routes it pushes wait for the
3032
+ * landing. At the start, a position the URL holds is put back
3033
+ * on the entry it lands on, as for any back() of ours
3034
+ * (restore_hash). The keys stay dead while their entries
3035
+ * exist: a later Back or Forward onto them goes over them too.
3036
+ * Returns true when it went.
3037
+ ************************************************************/
3038
+ function retire_dead_entries(gobj, from, hash_moved) {
3039
+ let priv = gobj.priv;
3040
+ let reader = typeof from === "number";
2997
3041
  if (__dead_entries__.size === 0 || priv.expected_pops > 0 || !priv.popstate_handler || !current_entry_key()) return false;
2998
3042
  let nav = window.navigation;
2999
3043
  let entries = nav.entries();
3000
3044
  let index = nav.currentEntry.index;
3001
3045
  let alive = new Set(entries.map((e) => e.key));
3002
3046
  for (let key of __dead_entries__) if (!alive.has(key)) __dead_entries__.delete(key);
3047
+ if (reader && (from === index || !__dead_entries__.has(entries[index].key))) return false;
3048
+ let step = reader && from < index ? 1 : -1;
3003
3049
  let landing = index;
3004
- while (landing > 0 && __dead_entries__.has(entries[landing].key)) landing--;
3005
- let steps = index - landing;
3050
+ while (__dead_entries__.has(entries[landing].key)) {
3051
+ let next = landing + step;
3052
+ if (next < 0 || next >= entries.length || !entries[next].sameDocument) break;
3053
+ landing = next;
3054
+ }
3055
+ if (step > 0 && __dead_entries__.has(entries[landing].key)) return false;
3056
+ let steps = landing - index;
3006
3057
  if (steps === 0) return false;
3007
3058
  let landing_hash = "";
3008
3059
  try {
3009
3060
  landing_hash = new URL(entries[landing].url).hash;
3010
3061
  } catch (e) {
3011
- log_warning(`C_YUI_SHELL: the entry under the dead ones has no url: ${e}`);
3062
+ log_warning(`C_YUI_SHELL: the entry past the dead ones has no url: ${e}`);
3012
3063
  return false;
3013
3064
  }
3014
- for (let i = landing + 1; i <= index; i++) __dead_entries__.delete(entries[i].key);
3015
3065
  priv.expected_pops++;
3016
3066
  priv.expected_pop_hash = landing_hash;
3017
- priv.restore_hash = window.location.hash !== landing_hash ? window.location.hash : "";
3067
+ if (reader) {
3068
+ priv.restore_hash = "";
3069
+ if (hash_moved && window.location.hash !== landing_hash) priv.skip_hash = window.location.hash;
3070
+ } else priv.restore_hash = window.location.hash !== landing_hash ? window.location.hash : "";
3018
3071
  try {
3019
- window.history.go(-steps);
3072
+ window.history.go(steps);
3020
3073
  } catch (e) {
3021
3074
  priv.expected_pops--;
3022
3075
  priv.restore_hash = "";
3023
- log_warning(`C_YUI_SHELL: retiring ${steps} dead history entries failed: ${e}`);
3076
+ priv.skip_hash = "";
3077
+ log_warning(`C_YUI_SHELL: going over ${Math.abs(steps)} dead history entries failed: ${e}`);
3024
3078
  return false;
3025
3079
  }
3026
3080
  clear_deferred_timer(gobj);
@@ -3128,6 +3182,8 @@ function push_overlay_marker(gobj, entry) {
3128
3182
  if (below === null || plain) try {
3129
3183
  window.history.replaceState(Object.assign({}, below, { __yui_below__: entry.id }), "");
3130
3184
  stamped = true;
3185
+ let key = current_entry_key();
3186
+ if (key) __dead_entries__.delete(key);
3131
3187
  } catch (e) {
3132
3188
  log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
3133
3189
  }
@@ -9980,8 +10036,11 @@ function json_diff_rows(doc_a, doc_b) {
9980
10036
  * `new Date("YYYY-MM-DDT02:30:00")` answers the EARLIER one
9981
10037
  * (ECMAScript's "compatible" disambiguation). An epoch in the
9982
10038
  * SECOND pass of that hour is shown as 02:30 and comes back
9983
- * one hour earlier: saving the record -- any field of it --
9984
- * moves a writable time column that holds it by -3600 s.
10039
+ * one hour earlier. So neither the form's field nor the cell
10040
+ * editor reads a box that still shows what it was filled
10041
+ * with: they give back the value it was filled from (up to
10042
+ * gobj-ui 7.26.48 the cell, and 7.26.50 the field, wrote
10043
+ * -3600 s on a save of any field of the record).
9985
10044
  * - the night the clocks go forward (spring), one hour does not
9986
10045
  * exist. No epoch is shown in it, so nothing read comes back
9987
10046
  * wrong; a wall time TYPED in it is moved forward by the
@@ -9991,8 +10050,8 @@ function json_diff_rows(doc_a, doc_b) {
9991
10050
  * carry. What is safe: a read-only time column never goes back
9992
10051
  * (treedb_write_plan.js, col_goes_back_to_treedb), and a time
9993
10052
  * pkey2 goes back as the record had it, never through this
9994
- * widget (instance_keys_of). A writable time column edited or
9995
- * merely saved inside the repeated hour is the exposed case.
10053
+ * widget (instance_keys_of). A wall time TYPED inside the
10054
+ * repeated hour is the exposed case: it is the first pass.
9996
10055
  *
9997
10056
  * Copyright (c) 2026, ArtGins.
9998
10057
  * All Rights Reserved.
@@ -12898,7 +12957,8 @@ function get_form_values(gobj, $form) {
12898
12957
  case "input":
12899
12958
  switch (input_type) {
12900
12959
  case "datetime-local":
12901
- value = datetime_local_to_epoch($input.value);
12960
+ if ($input.yui_time_kept && $input.value === $input.yui_time_kept.shown) value = $input.yui_time_kept.value;
12961
+ else value = datetime_local_to_epoch($input.value);
12902
12962
  break;
12903
12963
  default: value = getInputValue($input);
12904
12964
  }
@@ -12966,8 +13026,10 @@ function clear_data(gobj, $form) {
12966
13026
  if (jsoneditor) jsoneditor.set({ text: "" });
12967
13027
  } else if ($input.type === "checkbox") $input.checked = false;
12968
13028
  else if ($input.type === "radio") $input.checked = false;
12969
- else if ($input.type === "datetime-local") $input.value = null;
12970
- else if ($input.type === "color") {
13029
+ else if ($input.type === "datetime-local") {
13030
+ $input.value = null;
13031
+ $input.yui_time_kept = null;
13032
+ } else if ($input.type === "color") {
12971
13033
  $input.value = "#000000";
12972
13034
  if ($input.yui_color_value) {
12973
13035
  $input.yui_color_value.textContent = $input.value;
@@ -13057,6 +13119,7 @@ function set_form_values(gobj, template, $form, record) {
13057
13119
  value = field_desc.default_value;
13058
13120
  modified = true;
13059
13121
  }
13122
+ let stored = value === void 0 ? null : value;
13060
13123
  value = treedb_value_2_form_value(gobj, field_desc, value);
13061
13124
  if (value === void 0) value = null;
13062
13125
  switch (tag) {
@@ -13069,6 +13132,10 @@ function set_form_values(gobj, template, $form, record) {
13069
13132
  switch (input_type) {
13070
13133
  case "datetime-local":
13071
13134
  $input.value = date_to_datetime_local(value);
13135
+ $input.yui_time_kept = {
13136
+ value: stored,
13137
+ shown: $input.value
13138
+ };
13072
13139
  break;
13073
13140
  case "color":
13074
13141
  $input.value = convertColor(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.49",
3
+ "version": "7.26.51",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -39,7 +39,7 @@
39
39
  "devDependencies": {
40
40
  "@rollup/plugin-terser": "^1.0.0",
41
41
  "@vitest/coverage-v8": "^4.1.10",
42
- "@yuneta/gobj-js": "^7.26.27",
42
+ "@yuneta/gobj-js": "^7.26.28",
43
43
  "vite": "^8.3.3",
44
44
  "vitest": "^4.1.10"
45
45
  },