@yuneta/gobj-ui 7.26.50 → 7.26.52
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 +199 -34
- package/dist/gobj-ui.cjs.js +1162 -853
- package/dist/gobj-ui.es.js +1153 -845
- package/index.js +1 -0
- package/package.json +2 -2
- package/scripts/validate-locales.mjs +472 -149
- package/src/c_yui_form.js +68 -7
- package/src/c_yui_json.js +36 -3
- package/src/c_yui_shell.js +103 -20
- package/src/c_yui_treedb_topic_with_form.js +13 -28
- package/src/c_yui_uplot.js +51 -2
- package/src/fmt_date_time.test.js +138 -0
- package/src/form_table_rows.wiring.test.js +5 -4
- package/src/form_time_field.wiring.test.js +127 -0
- package/src/form_time_value.js +16 -10
- package/src/form_time_value.test.js +1 -1
- package/src/json_view_helpers.js +8 -3
- package/src/shell_history_debt.wiring.test.js +192 -9
- package/src/time_text.wiring.test.js +489 -0
- package/src/yui_time.js +37 -0
- package/src/yui_uplot_time.js +142 -0
package/src/c_yui_form.js
CHANGED
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
gobj_unsubscribe_event,
|
|
53
53
|
} from "@yuneta/gobj-js";
|
|
54
54
|
|
|
55
|
-
import {t} from "i18next";
|
|
55
|
+
import i18next, {t} from "i18next";
|
|
56
56
|
|
|
57
57
|
import {
|
|
58
58
|
yui_tabulator_name_row_selects,
|
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
time_value_to_text
|
|
101
101
|
} from "./form_time_value.js";
|
|
102
102
|
import {form_time_cell_editor} from "./form_time_cell_editor.js";
|
|
103
|
+
import {safe_locale} from "./yui_time.js";
|
|
103
104
|
import {parse_json_field, json_editor_value} from "./form_json_field.js";
|
|
104
105
|
import {
|
|
105
106
|
json_editor_menu_items,
|
|
@@ -2605,6 +2606,48 @@ function table_column_titles(template)
|
|
|
2605
2606
|
return titles;
|
|
2606
2607
|
}
|
|
2607
2608
|
|
|
2609
|
+
/* The formatters of the time cells, so a language change finds them. */
|
|
2610
|
+
const TIME_CELL_FORMATTERS = new WeakSet();
|
|
2611
|
+
|
|
2612
|
+
/******************************************************************
|
|
2613
|
+
* The formatter of a time cell: the local clock, 24 hours, in the
|
|
2614
|
+
* APP's language (fmt_date_time of yui_time.js, as the cells of
|
|
2615
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
|
|
2616
|
+
******************************************************************/
|
|
2617
|
+
function time_cell_formatter(real_type)
|
|
2618
|
+
{
|
|
2619
|
+
let formatter = function(cell) {
|
|
2620
|
+
return text_node(time_value_to_text(
|
|
2621
|
+
cell.getValue(), real_type, safe_locale(i18next.language)
|
|
2622
|
+
));
|
|
2623
|
+
};
|
|
2624
|
+
TIME_CELL_FORMATTERS.add(formatter);
|
|
2625
|
+
return formatter;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
/******************************************************************
|
|
2629
|
+
* Draw the time cells of a table again, in the current language.
|
|
2630
|
+
* Cell by cell, never a redraw of the rows: a row's formatter
|
|
2631
|
+
* builds its nested tables anew -- empty. A cell being edited is
|
|
2632
|
+
* its editor's; Tabulator formats it again when the editor closes.
|
|
2633
|
+
******************************************************************/
|
|
2634
|
+
function reformat_time_cells(tabulator)
|
|
2635
|
+
{
|
|
2636
|
+
for(let column of tabulator.getColumns()) {
|
|
2637
|
+
let formatter = column.getDefinition().formatter;
|
|
2638
|
+
if(!TIME_CELL_FORMATTERS.has(formatter)) {
|
|
2639
|
+
continue;
|
|
2640
|
+
}
|
|
2641
|
+
for(let cell of column.getCells()) {
|
|
2642
|
+
let $cell = cell.getElement();
|
|
2643
|
+
if($cell.classList.contains("tabulator-editing")) {
|
|
2644
|
+
continue;
|
|
2645
|
+
}
|
|
2646
|
+
$cell.replaceChildren(formatter(cell));
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2608
2651
|
/******************************************************************
|
|
2609
2652
|
* Convert a template's items in tabulator columns
|
|
2610
2653
|
******************************************************************/
|
|
@@ -2808,9 +2851,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2808
2851
|
};
|
|
2809
2852
|
/* The clock, not the epoch: up to 7.26.46 the cell showed
|
|
2810
2853
|
* the raw number. */
|
|
2811
|
-
column.formatter =
|
|
2812
|
-
return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
|
|
2813
|
-
};
|
|
2854
|
+
column.formatter = time_cell_formatter(field_desc.real_type);
|
|
2814
2855
|
break;
|
|
2815
2856
|
|
|
2816
2857
|
case "color":
|
|
@@ -3187,7 +3228,19 @@ function get_form_values(gobj, $form)
|
|
|
3187
3228
|
case "input":
|
|
3188
3229
|
switch(input_type) {
|
|
3189
3230
|
case "datetime-local":
|
|
3190
|
-
|
|
3231
|
+
/* A box still showing what it was filled with
|
|
3232
|
+
* gives back the value it was filled from: read
|
|
3233
|
+
* as a wall time, an instant in the SECOND pass
|
|
3234
|
+
* of the hour the clocks go back is the first
|
|
3235
|
+
* one, and up to gobj-ui 7.26.50 a save with the
|
|
3236
|
+
* field untouched wrote it -3600 s
|
|
3237
|
+
* (form_time_value.js). */
|
|
3238
|
+
if($input.yui_time_kept &&
|
|
3239
|
+
$input.value === $input.yui_time_kept.shown) {
|
|
3240
|
+
value = $input.yui_time_kept.value;
|
|
3241
|
+
} else {
|
|
3242
|
+
value = datetime_local_to_epoch($input.value);
|
|
3243
|
+
}
|
|
3191
3244
|
break;
|
|
3192
3245
|
default:
|
|
3193
3246
|
value = getInputValue($input);
|
|
@@ -3306,6 +3359,7 @@ function clear_data(gobj, $form)
|
|
|
3306
3359
|
|
|
3307
3360
|
} else if($input.type === 'datetime-local') { /* time */
|
|
3308
3361
|
$input.value = null;
|
|
3362
|
+
$input.yui_time_kept = null;
|
|
3309
3363
|
|
|
3310
3364
|
} else if($input.type === 'color') {
|
|
3311
3365
|
/* A colour input holds a colour: the "" a null is written
|
|
@@ -3443,6 +3497,7 @@ function set_form_values(gobj, template, $form, record)
|
|
|
3443
3497
|
value = field_desc.default_value;
|
|
3444
3498
|
modified = true;
|
|
3445
3499
|
}
|
|
3500
|
+
let stored = (value === undefined)? null : value;
|
|
3446
3501
|
value = treedb_value_2_form_value(gobj, field_desc, value);
|
|
3447
3502
|
if(value === undefined) {
|
|
3448
3503
|
/* DOM 'value' setters stringify undefined as "undefined";
|
|
@@ -3466,8 +3521,12 @@ function set_form_values(gobj, template, $form, record)
|
|
|
3466
3521
|
case "input":
|
|
3467
3522
|
switch(input_type) {
|
|
3468
3523
|
case "datetime-local":
|
|
3469
|
-
/* value is a Date (see treedb_value_2_form_value)
|
|
3524
|
+
/* value is a Date (see treedb_value_2_form_value).
|
|
3525
|
+
* The text kept is the one READ BACK: the browser
|
|
3526
|
+
* drops seconds of :00, so the text written never
|
|
3527
|
+
* matches it (get_form_values). */
|
|
3470
3528
|
$input.value = date_to_datetime_local(value);
|
|
3529
|
+
$input.yui_time_kept = {value: stored, shown: $input.value};
|
|
3471
3530
|
break;
|
|
3472
3531
|
case "color":
|
|
3473
3532
|
$input.value = convertColor(value);
|
|
@@ -4328,11 +4387,13 @@ function ac_language_changed(gobj, event, kw, src)
|
|
|
4328
4387
|
* form was built in. Through the table's LOCALE, never by
|
|
4329
4388
|
* updateDefinition(): rebuilding a column re-renders every row, and
|
|
4330
4389
|
* a row's formatter builds its nested tables anew -- empty. A table
|
|
4331
|
-
* not built yet is drawn in the current language when it is.
|
|
4390
|
+
* not built yet is drawn in the current language when it is. The
|
|
4391
|
+
* time cells write their month in the language too. */
|
|
4332
4392
|
for(let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
|
|
4333
4393
|
let tabulator = $table.tabulator;
|
|
4334
4394
|
if(tabulator && tabulator.initialized && $table.template) {
|
|
4335
4395
|
yui_tabulator_relocalize(tabulator, t, table_column_titles($table.template));
|
|
4396
|
+
reformat_time_cells(tabulator);
|
|
4336
4397
|
}
|
|
4337
4398
|
}
|
|
4338
4399
|
return 0;
|
package/src/c_yui_json.js
CHANGED
|
@@ -68,6 +68,8 @@ import {
|
|
|
68
68
|
gobj_read_pointer_attr,
|
|
69
69
|
gobj_parent,
|
|
70
70
|
gobj_subscribe_event,
|
|
71
|
+
gobj_unsubscribe_event,
|
|
72
|
+
gobj_is_destroying,
|
|
71
73
|
gobj_create_pure_child,
|
|
72
74
|
gobj_start,
|
|
73
75
|
gobj_stop,
|
|
@@ -106,9 +108,11 @@ import {
|
|
|
106
108
|
|
|
107
109
|
import {yui_toolbar, yui_toolbar_icon} from "./yui_toolbar.js";
|
|
108
110
|
import {register_c_yui_json_graph} from "./c_yui_json_graph.js";
|
|
111
|
+
import {yui_shell_of} from "./c_yui_shell.js";
|
|
109
112
|
import {attach_clear} from "./yui_inputs.js";
|
|
110
113
|
|
|
111
|
-
import {t} from "i18next";
|
|
114
|
+
import i18next, {t} from "i18next";
|
|
115
|
+
import {safe_locale} from "./yui_time.js";
|
|
112
116
|
|
|
113
117
|
import "./c_yui_json.css";
|
|
114
118
|
import {text_node} from "./yui_text.js";
|
|
@@ -197,6 +201,7 @@ let PRIVATE_DATA = {
|
|
|
197
201
|
$expand_btn: null, // "expand loaded" button (hidden in text view)
|
|
198
202
|
$collapse_btn: null,// "collapse all" button (hidden in text view)
|
|
199
203
|
$mode_btns: null, // Map<mode, HTMLElement> of the view switch
|
|
204
|
+
lang_shell: null, // the shell whose EV_LANGUAGE_CHANGED we hear
|
|
200
205
|
};
|
|
201
206
|
|
|
202
207
|
let __gclass__ = null;
|
|
@@ -255,6 +260,17 @@ function mt_start(gobj)
|
|
|
255
260
|
if(priv.root !== null) {
|
|
256
261
|
gobj_change_state(gobj, "ST_READY");
|
|
257
262
|
}
|
|
263
|
+
|
|
264
|
+
/* The reading beside a time field is written in the app's language
|
|
265
|
+
* when the tree is drawn: the shell's language switch draws it again
|
|
266
|
+
* (ac_language_changed). No host forwarded the event, so up to
|
|
267
|
+
* gobj-ui 7.26.51 that action never ran. */
|
|
268
|
+
let shell = yui_shell_of(gobj);
|
|
269
|
+
if(shell) {
|
|
270
|
+
gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
271
|
+
priv.lang_shell = shell;
|
|
272
|
+
}
|
|
273
|
+
|
|
258
274
|
render_view(gobj);
|
|
259
275
|
}
|
|
260
276
|
|
|
@@ -263,6 +279,15 @@ function mt_start(gobj)
|
|
|
263
279
|
***************************************************************/
|
|
264
280
|
function mt_stop(gobj)
|
|
265
281
|
{
|
|
282
|
+
let priv = gobj.priv;
|
|
283
|
+
|
|
284
|
+
/* The shell it subscribed to, if it is still there: a logout may
|
|
285
|
+
* have destroyed it, and its subscriptions with it. */
|
|
286
|
+
if(priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) {
|
|
287
|
+
gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
288
|
+
}
|
|
289
|
+
priv.lang_shell = null;
|
|
290
|
+
|
|
266
291
|
/*
|
|
267
292
|
* The graph child dies with the parent's RUNNING state, not with
|
|
268
293
|
* its destruction, and the difference is not cosmetic:
|
|
@@ -1001,7 +1026,7 @@ function leaf_row(key, value, depth)
|
|
|
1001
1026
|
body.push(['span', {class: 'JSON_VALUE JSON_TYPE_' + type.toUpperCase()}, text_node(text)]);
|
|
1002
1027
|
|
|
1003
1028
|
if(key !== null && is_time_field(String(key))) {
|
|
1004
|
-
let wall = format_epoch(value);
|
|
1029
|
+
let wall = format_epoch(value, safe_locale(i18next.language));
|
|
1005
1030
|
if(wall) {
|
|
1006
1031
|
body.push(['span', {class: 'JSON_TIME is-size-7 yui-text-quiet ml-2'}, wall]);
|
|
1007
1032
|
}
|
|
@@ -1337,6 +1362,12 @@ function ac_json_item_clicked(gobj, event, kw, src)
|
|
|
1337
1362
|
|
|
1338
1363
|
/************************************************************
|
|
1339
1364
|
* EV_LANGUAGE_CHANGED — re-translate chrome + re-render
|
|
1365
|
+
*
|
|
1366
|
+
* Only the TREE is drawn again: it writes the reading of a
|
|
1367
|
+
* time field in the language of the moment it was drawn. The
|
|
1368
|
+
* text view carries its keys (refresh_language reaches them),
|
|
1369
|
+
* and loading the graph again would throw away the reader's
|
|
1370
|
+
* camera for nothing.
|
|
1340
1371
|
************************************************************/
|
|
1341
1372
|
function ac_language_changed(gobj, event, kw, src)
|
|
1342
1373
|
{
|
|
@@ -1349,7 +1380,9 @@ function ac_language_changed(gobj, event, kw, src)
|
|
|
1349
1380
|
}
|
|
1350
1381
|
apply_view_mode(gobj);
|
|
1351
1382
|
}
|
|
1352
|
-
|
|
1383
|
+
if(current_view_mode(gobj) === "tree") {
|
|
1384
|
+
render_tree(gobj);
|
|
1385
|
+
}
|
|
1353
1386
|
return 0;
|
|
1354
1387
|
}
|
|
1355
1388
|
|
package/src/c_yui_shell.js
CHANGED
|
@@ -104,8 +104,11 @@ let __retiring_shell__ = null;
|
|
|
104
104
|
* the markers of its overlays and the action entries of its `stay`
|
|
105
105
|
* routes. They are dead -- nothing closes or opens on them any more --
|
|
106
106
|
* and the next shell takes them off with ONE history.go(-n) at its
|
|
107
|
-
* start, heard by its own expected_pops
|
|
108
|
-
*
|
|
107
|
+
* start, heard by its own expected_pops, and goes on over them when a
|
|
108
|
+
* Back or Forward of the reader's lands on them (retire_dead_entries()).
|
|
109
|
+
* A key stays here while its entry exists, and leaves when a live shell
|
|
110
|
+
* makes the entry its own again. A stopped shell moves no history: it
|
|
111
|
+
* would not hear the landing. */
|
|
109
112
|
let __dead_entries__ = new Set();
|
|
110
113
|
|
|
111
114
|
/* A history.back() of a shell that stopped before it landed. Nothing
|
|
@@ -256,6 +259,11 @@ let PRIVATE_DATA = {
|
|
|
256
259
|
* markers and the action entries of its `stay` routes. Dead once
|
|
257
260
|
* it stops (__dead_entries__). */
|
|
258
261
|
own_entries: [],
|
|
262
|
+
/* The index of the entry a traversal comes FROM, told by the
|
|
263
|
+
* Navigation API's currententrychange before its popstate: which
|
|
264
|
+
* way a reader's traversal goes over dead entries. */
|
|
265
|
+
traverse_from: -1,
|
|
266
|
+
entry_change_handler: null,
|
|
259
267
|
popstate_handler: null,
|
|
260
268
|
/* Avatar item support — every toolbar item with type:"avatar"
|
|
261
269
|
* registers its <span> here so refresh_avatars() can repaint
|
|
@@ -412,10 +420,21 @@ function mt_start(gobj)
|
|
|
412
420
|
return;
|
|
413
421
|
}
|
|
414
422
|
note_late_landing(gobj, ev);
|
|
423
|
+
let from = p.traverse_from;
|
|
424
|
+
p.traverse_from = -1;
|
|
415
425
|
/* A traversal that moved the hash is followed by a
|
|
416
426
|
* hashchange, QUEUED: it runs after this handler, and it is
|
|
417
427
|
* the one that navigates (and drains). */
|
|
418
428
|
let hash_moved = window.location.hash !== p.last_hash;
|
|
429
|
+
if(p.expected_pops === 0 && from >= 0 &&
|
|
430
|
+
retire_dead_entries(gobj, from, hash_moved)) {
|
|
431
|
+
/* A Back or Forward of the reader's onto dead entries
|
|
432
|
+
* goes on over them: what it lands on is not this one. */
|
|
433
|
+
if(!p.skip_hash) {
|
|
434
|
+
p.last_hash = window.location.hash;
|
|
435
|
+
}
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
419
438
|
if(p.expected_pops > 0 &&
|
|
420
439
|
window.location.hash !== p.expected_pop_hash) {
|
|
421
440
|
/* Not the landing of ours: it was dropped. Whatever
|
|
@@ -546,6 +565,18 @@ function mt_start(gobj)
|
|
|
546
565
|
}
|
|
547
566
|
};
|
|
548
567
|
window.addEventListener("popstate", priv.popstate_handler);
|
|
568
|
+
let nav = window.navigation;
|
|
569
|
+
if(nav && typeof nav.addEventListener === "function") {
|
|
570
|
+
priv.entry_change_handler = (ev) => {
|
|
571
|
+
let p = gobj.priv;
|
|
572
|
+
if(!p) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
p.traverse_from = (ev && ev.navigationType === "traverse" && ev.from &&
|
|
576
|
+
typeof ev.from.index === "number")? ev.from.index : -1;
|
|
577
|
+
};
|
|
578
|
+
nav.addEventListener("currententrychange", priv.entry_change_handler);
|
|
579
|
+
}
|
|
549
580
|
keep_dead_entries_across_reload();
|
|
550
581
|
adopt_orphan_back(gobj);
|
|
551
582
|
}
|
|
@@ -632,6 +663,14 @@ function mt_stop(gobj)
|
|
|
632
663
|
window.removeEventListener("popstate", priv.popstate_handler);
|
|
633
664
|
priv.popstate_handler = null;
|
|
634
665
|
}
|
|
666
|
+
if(priv.entry_change_handler) {
|
|
667
|
+
let nav = window.navigation;
|
|
668
|
+
if(nav && typeof nav.removeEventListener === "function") {
|
|
669
|
+
nav.removeEventListener("currententrychange", priv.entry_change_handler);
|
|
670
|
+
}
|
|
671
|
+
priv.entry_change_handler = null;
|
|
672
|
+
}
|
|
673
|
+
priv.traverse_from = -1;
|
|
635
674
|
/* Nothing listens for the landings any more. An overlay that
|
|
636
675
|
* waited for one gets no marker: it says so, so neither a later
|
|
637
676
|
* dismissal retires one nor a traversal waits for it. */
|
|
@@ -2895,7 +2934,9 @@ function retire_overlays(gobj)
|
|
|
2895
2934
|
*
|
|
2896
2935
|
* A page with no next shell keeps them: with no router on the
|
|
2897
2936
|
* page, a Back over the app's own entries changes nothing on
|
|
2898
|
-
* screen anyway, and the next shell retires them all the same
|
|
2937
|
+
* screen anyway, and the next shell retires them all the same --
|
|
2938
|
+
* at its start, or when a traversal of the reader's lands on them
|
|
2939
|
+
* if the reader moved meanwhile.
|
|
2899
2940
|
************************************************************/
|
|
2900
2941
|
function hand_over_history(gobj)
|
|
2901
2942
|
{
|
|
@@ -3070,6 +3111,7 @@ function note_own_entry(gobj)
|
|
|
3070
3111
|
if(!key || priv.own_entries.includes(key)) {
|
|
3071
3112
|
return;
|
|
3072
3113
|
}
|
|
3114
|
+
__dead_entries__.delete(key);
|
|
3073
3115
|
priv.own_entries.push(key);
|
|
3074
3116
|
if(priv.own_entries.length > OWN_ENTRIES_PRUNE_AT) {
|
|
3075
3117
|
/* Entries cut off by a push are gone for good. */
|
|
@@ -3082,16 +3124,34 @@ function note_own_entry(gobj)
|
|
|
3082
3124
|
* Take off, with ONE history.go(-n), the dead entries a
|
|
3083
3125
|
* stopped shell left under the current one (hand_over_history).
|
|
3084
3126
|
* The walk stops at the first entry that is not dead, so it
|
|
3085
|
-
* never goes past an entry of the reader's
|
|
3086
|
-
*
|
|
3087
|
-
*
|
|
3088
|
-
* the
|
|
3089
|
-
*
|
|
3090
|
-
*
|
|
3127
|
+
* never goes past an entry of the reader's, and at the first
|
|
3128
|
+
* entry of the current document: a navigation to another page
|
|
3129
|
+
* with replace keeps the entry's key, so a later document can
|
|
3130
|
+
* sit on the key of a dead marker, over the entries of the one
|
|
3131
|
+
* before it (up to gobj-ui 7.26.50 the walk went into them and
|
|
3132
|
+
* that document was loaded again). After a reload every entry
|
|
3133
|
+
* is the new document's, and its dead ones go.
|
|
3134
|
+
*
|
|
3135
|
+
* With `from` (the index a traversal of the reader's came
|
|
3136
|
+
* from), it goes on over the dead entries that traversal landed
|
|
3137
|
+
* on, the way it was going: down to the first live one under
|
|
3138
|
+
* them, or up to the first live one over them -- there is none
|
|
3139
|
+
* when they are the newest, and nothing moves. Dead entries
|
|
3140
|
+
* under an entry of the reader's are taken off that way: the
|
|
3141
|
+
* start of a shell never goes past one.
|
|
3142
|
+
*
|
|
3143
|
+
* The traversal is this shell's own (expected_pops): its
|
|
3144
|
+
* overlays' markers and the routes it pushes wait for the
|
|
3145
|
+
* landing. At the start, a position the URL holds is put back
|
|
3146
|
+
* on the entry it lands on, as for any back() of ours
|
|
3147
|
+
* (restore_hash). The keys stay dead while their entries
|
|
3148
|
+
* exist: a later Back or Forward onto them goes over them too.
|
|
3149
|
+
* Returns true when it went.
|
|
3091
3150
|
************************************************************/
|
|
3092
|
-
function retire_dead_entries(gobj)
|
|
3151
|
+
function retire_dead_entries(gobj, from, hash_moved)
|
|
3093
3152
|
{
|
|
3094
3153
|
let priv = gobj.priv;
|
|
3154
|
+
let reader = (typeof from === "number");
|
|
3095
3155
|
if(__dead_entries__.size === 0 || priv.expected_pops > 0 ||
|
|
3096
3156
|
!priv.popstate_handler || !current_entry_key()) {
|
|
3097
3157
|
return false;
|
|
@@ -3105,11 +3165,22 @@ function retire_dead_entries(gobj)
|
|
|
3105
3165
|
__dead_entries__.delete(key);
|
|
3106
3166
|
}
|
|
3107
3167
|
}
|
|
3168
|
+
if(reader && (from === index || !__dead_entries__.has(entries[index].key))) {
|
|
3169
|
+
return false;
|
|
3170
|
+
}
|
|
3171
|
+
let step = (reader && from < index)? 1 : -1;
|
|
3108
3172
|
let landing = index;
|
|
3109
|
-
while(
|
|
3110
|
-
landing
|
|
3173
|
+
while(__dead_entries__.has(entries[landing].key)) {
|
|
3174
|
+
let next = landing + step;
|
|
3175
|
+
if(next < 0 || next >= entries.length || !entries[next].sameDocument) {
|
|
3176
|
+
break;
|
|
3177
|
+
}
|
|
3178
|
+
landing = next;
|
|
3111
3179
|
}
|
|
3112
|
-
|
|
3180
|
+
if(step > 0 && __dead_entries__.has(entries[landing].key)) {
|
|
3181
|
+
return false;
|
|
3182
|
+
}
|
|
3183
|
+
let steps = landing - index;
|
|
3113
3184
|
if(steps === 0) {
|
|
3114
3185
|
return false;
|
|
3115
3186
|
}
|
|
@@ -3117,21 +3188,28 @@ function retire_dead_entries(gobj)
|
|
|
3117
3188
|
try {
|
|
3118
3189
|
landing_hash = new URL(entries[landing].url).hash;
|
|
3119
3190
|
} catch(e) {
|
|
3120
|
-
log_warning(`C_YUI_SHELL: the entry
|
|
3191
|
+
log_warning(`C_YUI_SHELL: the entry past the dead ones has no url: ${e}`);
|
|
3121
3192
|
return false;
|
|
3122
3193
|
}
|
|
3123
|
-
for(let i = landing + 1; i <= index; i++) {
|
|
3124
|
-
__dead_entries__.delete(entries[i].key);
|
|
3125
|
-
}
|
|
3126
3194
|
priv.expected_pops++;
|
|
3127
3195
|
priv.expected_pop_hash = landing_hash;
|
|
3128
|
-
|
|
3196
|
+
if(reader) {
|
|
3197
|
+
priv.restore_hash = "";
|
|
3198
|
+
/* The hashchange of the landing on the dead entry is queued
|
|
3199
|
+
* before ours lands, and is not the reader's destination. */
|
|
3200
|
+
if(hash_moved && window.location.hash !== landing_hash) {
|
|
3201
|
+
priv.skip_hash = window.location.hash;
|
|
3202
|
+
}
|
|
3203
|
+
} else {
|
|
3204
|
+
priv.restore_hash = (window.location.hash !== landing_hash)? window.location.hash : "";
|
|
3205
|
+
}
|
|
3129
3206
|
try {
|
|
3130
|
-
window.history.go(
|
|
3207
|
+
window.history.go(steps);
|
|
3131
3208
|
} catch(e) {
|
|
3132
3209
|
priv.expected_pops--;
|
|
3133
3210
|
priv.restore_hash = "";
|
|
3134
|
-
|
|
3211
|
+
priv.skip_hash = "";
|
|
3212
|
+
log_warning(`C_YUI_SHELL: going over ${Math.abs(steps)} dead history entries failed: ${e}`);
|
|
3135
3213
|
return false;
|
|
3136
3214
|
}
|
|
3137
3215
|
clear_deferred_timer(gobj); // a wait that just ended goes on: bound it again
|
|
@@ -3317,6 +3395,11 @@ function push_overlay_marker(gobj, entry)
|
|
|
3317
3395
|
window.history.replaceState(
|
|
3318
3396
|
Object.assign({}, below, { __yui_below__: entry.id }), "");
|
|
3319
3397
|
stamped = true;
|
|
3398
|
+
/* A Back onto it closes this overlay now. */
|
|
3399
|
+
let key = current_entry_key();
|
|
3400
|
+
if(key) {
|
|
3401
|
+
__dead_entries__.delete(key);
|
|
3402
|
+
}
|
|
3320
3403
|
} catch(e) {
|
|
3321
3404
|
log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
|
|
3322
3405
|
}
|
|
@@ -98,7 +98,8 @@ import {
|
|
|
98
98
|
} from "./lib_icons.js";
|
|
99
99
|
import {row_matches} from "./yui_row_search.js";
|
|
100
100
|
|
|
101
|
-
import {t} from "i18next";
|
|
101
|
+
import i18next, {t} from "i18next";
|
|
102
|
+
import {safe_locale} from "./yui_time.js";
|
|
102
103
|
|
|
103
104
|
import {yui_toolbar_icon} from "./yui_toolbar.js";
|
|
104
105
|
|
|
@@ -123,7 +124,7 @@ import {cell_text, hook_cell_spec} from "./table_cell_text.js";
|
|
|
123
124
|
|
|
124
125
|
import { TabulatorFull as Tabulator } from "tabulator-tables";
|
|
125
126
|
import {text_node, text_list_item_formatter} from "./yui_text.js";
|
|
126
|
-
import {
|
|
127
|
+
import {time_value_to_text} from "./form_time_value.js";
|
|
127
128
|
|
|
128
129
|
/***************************************************************
|
|
129
130
|
* Constants
|
|
@@ -2271,33 +2272,17 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field)
|
|
|
2271
2272
|
case "string":
|
|
2272
2273
|
case "integer":
|
|
2273
2274
|
/* An ISO text for a string column (up to 7.26.46 read
|
|
2274
|
-
* with parseInt, as 2026 seconds), none for no time.
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2275
|
+
* with parseInt, as 2026 seconds), none for no time.
|
|
2276
|
+
* The APP's language and 24 hours, as C_YUI_FORM's
|
|
2277
|
+
* cells (up to 7.26.51 the browser's language, 12
|
|
2278
|
+
* hours). A language change re-runs setColumns(),
|
|
2279
|
+
* which re-runs this. */
|
|
2280
|
+
value = time_value_to_text(
|
|
2281
|
+
value, field_desc.real_type, safe_locale(i18next.language)
|
|
2282
|
+
);
|
|
2283
|
+
if(value) {
|
|
2284
|
+
value = createElement2(['span', {class: 'is-size-7'}, text_node(value)]);
|
|
2279
2285
|
}
|
|
2280
|
-
|
|
2281
|
-
const rawLocale = navigator.language;
|
|
2282
|
-
// Playwright Firefox without locale config and some embedded
|
|
2283
|
-
// webviews report navigator.language as the literal string
|
|
2284
|
-
// "undefined" — would throw RangeError in Intl.DateTimeFormat.
|
|
2285
|
-
const userLocale = (typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined")
|
|
2286
|
-
? rawLocale
|
|
2287
|
-
: undefined;
|
|
2288
|
-
const opts = {
|
|
2289
|
-
day: 'numeric',
|
|
2290
|
-
month: 'short', // 'long' for full month name, 'short' for abbreviated, 'narrow' for shortest
|
|
2291
|
-
year: 'numeric',
|
|
2292
|
-
hour: '2-digit',
|
|
2293
|
-
minute: '2-digit',
|
|
2294
|
-
second: '2-digit',
|
|
2295
|
-
hour12: true, // Use true for AM/PM or false for 24-hour format, depending on locale preference
|
|
2296
|
-
// timeZoneName: 'short' // Options are 'short' or 'long'
|
|
2297
|
-
};
|
|
2298
|
-
|
|
2299
|
-
const formatter = new Intl.DateTimeFormat(userLocale, opts);
|
|
2300
|
-
value = createElement2(['span', {class: 'is-size-7'}, formatter.format(value)]);
|
|
2301
2286
|
break;
|
|
2302
2287
|
}
|
|
2303
2288
|
break;
|
package/src/c_yui_uplot.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Graphics, Charts with uPlot
|
|
5
5
|
*
|
|
6
|
+
* A moment uPlot writes -- a tick of a time axis, the reading of
|
|
7
|
+
* the legend -- is in the app's language with a clock of 24 hours
|
|
8
|
+
* (yui_uplot_time.js), and is written again on the shell's
|
|
9
|
+
* EV_LANGUAGE_CHANGED.
|
|
10
|
+
*
|
|
6
11
|
* Copyright (c) 2025-2026, ArtGins.
|
|
7
12
|
* All Rights Reserved.
|
|
8
13
|
***********************************************************************/
|
|
@@ -18,6 +23,8 @@ import {
|
|
|
18
23
|
gobj_read_pointer_attr,
|
|
19
24
|
gobj_parent,
|
|
20
25
|
gobj_subscribe_event,
|
|
26
|
+
gobj_unsubscribe_event,
|
|
27
|
+
gobj_is_destroying,
|
|
21
28
|
gobj_read_attr,
|
|
22
29
|
gobj_read_str_attr,
|
|
23
30
|
gobj_write_attr,
|
|
@@ -34,6 +41,9 @@ import {yui_watch_theme} from "./yui_theme.js";
|
|
|
34
41
|
/* The ink of the axes -- the X and the Y -- and the palette of the
|
|
35
42
|
* series, on both schemes: see yui_uplot_ink.js. */
|
|
36
43
|
import {yui_uplot_axes, YUI_UPLOT_PALETTE} from "./yui_uplot_ink.js";
|
|
44
|
+
import {yui_uplot_fmt_date} from "./yui_uplot_time.js";
|
|
45
|
+
import {yui_shell_of} from "./c_yui_shell.js";
|
|
46
|
+
import i18next from "i18next";
|
|
37
47
|
|
|
38
48
|
|
|
39
49
|
/***************************************************************
|
|
@@ -66,6 +76,7 @@ SDATA_END()
|
|
|
66
76
|
|
|
67
77
|
let PRIVATE_DATA = {
|
|
68
78
|
theme_observer: null, /* the DOM's data-theme, as an EV_THEME */
|
|
79
|
+
lang_shell: null, /* the shell whose EV_LANGUAGE_CHANGED we hear */
|
|
69
80
|
};
|
|
70
81
|
|
|
71
82
|
let __gclass__ = null;
|
|
@@ -107,6 +118,13 @@ function mt_create(gobj)
|
|
|
107
118
|
***************************************************************/
|
|
108
119
|
function mt_start(gobj)
|
|
109
120
|
{
|
|
121
|
+
let priv = gobj.priv;
|
|
122
|
+
|
|
123
|
+
let shell = yui_shell_of(gobj);
|
|
124
|
+
if(shell) {
|
|
125
|
+
gobj_subscribe_event(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
126
|
+
priv.lang_shell = shell;
|
|
127
|
+
}
|
|
110
128
|
}
|
|
111
129
|
|
|
112
130
|
/***************************************************************
|
|
@@ -114,6 +132,14 @@ function mt_start(gobj)
|
|
|
114
132
|
***************************************************************/
|
|
115
133
|
function mt_stop(gobj)
|
|
116
134
|
{
|
|
135
|
+
let priv = gobj.priv;
|
|
136
|
+
|
|
137
|
+
/* The shell it subscribed to, if it is still there: a logout may
|
|
138
|
+
* have destroyed it, and its subscriptions with it. */
|
|
139
|
+
if(priv.lang_shell && !gobj_is_destroying(priv.lang_shell)) {
|
|
140
|
+
gobj_unsubscribe_event(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
141
|
+
}
|
|
142
|
+
priv.lang_shell = null;
|
|
117
143
|
}
|
|
118
144
|
|
|
119
145
|
/***************************************************************
|
|
@@ -172,6 +198,7 @@ function build_ui(gobj)
|
|
|
172
198
|
series: gobj_read_attr(gobj, "series"),
|
|
173
199
|
axes: yui_uplot_axes(gobj_read_attr(gobj, "axes")),
|
|
174
200
|
scales: gobj_read_attr(gobj, "scales"),
|
|
201
|
+
fmtDate: yui_uplot_fmt_date(() => i18next.language),
|
|
175
202
|
};
|
|
176
203
|
let uplot = new uPlot(
|
|
177
204
|
uPlot_options,
|
|
@@ -437,6 +464,26 @@ function ac_theme(gobj, event, kw, src)
|
|
|
437
464
|
return 0;
|
|
438
465
|
}
|
|
439
466
|
|
|
467
|
+
/******************************************************
|
|
468
|
+
* The language changed: the ticks of a time axis and the
|
|
469
|
+
* reading of the legend ask for it when they are written,
|
|
470
|
+
* so they are written again.
|
|
471
|
+
******************************************************/
|
|
472
|
+
function ac_language_changed(gobj, event, kw, src)
|
|
473
|
+
{
|
|
474
|
+
let uplot = gobj_read_attr(gobj, "uplot");
|
|
475
|
+
if(!uplot) {
|
|
476
|
+
return 0;
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
uplot.redraw(true, true);
|
|
480
|
+
uplot.setLegend(null, false);
|
|
481
|
+
} catch(e) {
|
|
482
|
+
log_error(`${gobj_short_name(gobj)}: cannot redraw the chart: ${e}`);
|
|
483
|
+
}
|
|
484
|
+
return 0;
|
|
485
|
+
}
|
|
486
|
+
|
|
440
487
|
/******************************************************
|
|
441
488
|
*
|
|
442
489
|
******************************************************/
|
|
@@ -511,7 +558,8 @@ function create_gclass(gclass_name)
|
|
|
511
558
|
["EV_ADD_SERIE", ac_add_serie, null],
|
|
512
559
|
["EV_DEL_SERIE", ac_del_serie, null],
|
|
513
560
|
["EV_CLEAR", ac_clear, null],
|
|
514
|
-
["EV_THEME", ac_theme, null]
|
|
561
|
+
["EV_THEME", ac_theme, null],
|
|
562
|
+
["EV_LANGUAGE_CHANGED", ac_language_changed, null]
|
|
515
563
|
]]
|
|
516
564
|
];
|
|
517
565
|
|
|
@@ -523,7 +571,8 @@ function create_gclass(gclass_name)
|
|
|
523
571
|
["EV_ADD_SERIE", 0],
|
|
524
572
|
["EV_DEL_SERIE", 0],
|
|
525
573
|
["EV_CLEAR", 0],
|
|
526
|
-
["EV_THEME", 0]
|
|
574
|
+
["EV_THEME", 0],
|
|
575
|
+
["EV_LANGUAGE_CHANGED", 0]
|
|
527
576
|
];
|
|
528
577
|
|
|
529
578
|
__gclass__ = gclass_create(
|