@yuneta/gobj-ui 7.26.51 → 7.26.53
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 +88 -2
- package/dist/gobj-ui.cjs.js +330 -71
- package/dist/gobj-ui.es.js +321 -63
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/c_yui_form.js +48 -5
- package/src/c_yui_json.js +36 -3
- 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_value.js +9 -6
- package/src/form_time_value.test.js +1 -1
- package/src/json_view_helpers.js +8 -3
- package/src/time_text.wiring.test.js +489 -0
- package/src/yui_date_text.js +82 -0
- package/src/yui_time.js +6 -22
- package/src/yui_uplot_time.js +142 -0
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -6857,7 +6857,7 @@ function ac_shell_changed(gobj, event, kw, src) {
|
|
|
6857
6857
|
* language the window was opened in (a reader took the
|
|
6858
6858
|
* aria-labelledby, which changed; the tooltip did not).
|
|
6859
6859
|
************************************************************/
|
|
6860
|
-
function ac_language_changed$
|
|
6860
|
+
function ac_language_changed$12(gobj, event, kw, src) {
|
|
6861
6861
|
let priv = gobj.priv;
|
|
6862
6862
|
for (let entry of priv.windows) {
|
|
6863
6863
|
if (!entry.title_prefix || !entry.$chip) continue;
|
|
@@ -6928,7 +6928,7 @@ function create_gclass$20(gclass_name) {
|
|
|
6928
6928
|
],
|
|
6929
6929
|
[
|
|
6930
6930
|
"EV_LANGUAGE_CHANGED",
|
|
6931
|
-
ac_language_changed$
|
|
6931
|
+
ac_language_changed$12,
|
|
6932
6932
|
null
|
|
6933
6933
|
]
|
|
6934
6934
|
]]], gmt$20, 0, attrs_table$20, PRIVATE_DATA$20, 0, 0, 0, 0);
|
|
@@ -9681,6 +9681,71 @@ function yui_icons_list() {
|
|
|
9681
9681
|
});
|
|
9682
9682
|
return list;
|
|
9683
9683
|
}
|
|
9684
|
+
//#endregion
|
|
9685
|
+
//#region src/yui_date_text.js
|
|
9686
|
+
/***********************************************************************
|
|
9687
|
+
* yui_date_text.js
|
|
9688
|
+
*
|
|
9689
|
+
* A moment as a VIEW shows it as text, and the locale to show it
|
|
9690
|
+
* in. A module of its own, with no i18n key, on purpose: the views
|
|
9691
|
+
* that show a time (C_YUI_FORM, C_YUI_TREEDB_TOPIC_WITH_FORM,
|
|
9692
|
+
* C_YUI_JSON, C_YUI_UPLOT) import it, and validate-locales follows
|
|
9693
|
+
* the modules an app mounts -- importing yui_time.js for this made
|
|
9694
|
+
* every app that shows a time owe the keys of the period picker
|
|
9695
|
+
* (gobj-ui 7.26.52). yui_time.js re-exports both.
|
|
9696
|
+
*
|
|
9697
|
+
* Copyright (c) 2026, ArtGins.
|
|
9698
|
+
* All Rights Reserved.
|
|
9699
|
+
***********************************************************************/
|
|
9700
|
+
/***************************************************************
|
|
9701
|
+
* The locale to format with.
|
|
9702
|
+
*
|
|
9703
|
+
* NEVER at module top level, and never `navigator.language` raw:
|
|
9704
|
+
* Firefox can report the literal STRING "undefined", and every Intl
|
|
9705
|
+
* constructor throws RangeError on it — a module that built its
|
|
9706
|
+
* formatter on import took the whole bundle down with it (that is why
|
|
9707
|
+
* gui_agent refuses to import the gobj-ui barrel).
|
|
9708
|
+
***************************************************************/
|
|
9709
|
+
function safe_locale(locale) {
|
|
9710
|
+
if (typeof locale === "string" && locale && locale !== "undefined") return locale;
|
|
9711
|
+
let nav = typeof navigator !== "undefined" ? navigator.language : null;
|
|
9712
|
+
if (typeof nav === "string" && nav && nav !== "undefined") return nav;
|
|
9713
|
+
return "en";
|
|
9714
|
+
}
|
|
9715
|
+
var DATE_TIME_OPTIONS = {
|
|
9716
|
+
day: "numeric",
|
|
9717
|
+
month: "short",
|
|
9718
|
+
year: "numeric",
|
|
9719
|
+
hour: "2-digit",
|
|
9720
|
+
minute: "2-digit",
|
|
9721
|
+
second: "2-digit",
|
|
9722
|
+
hourCycle: "h23"
|
|
9723
|
+
};
|
|
9724
|
+
/***************************************************************
|
|
9725
|
+
* A moment as a VIEW shows it as text: the day, the month and the
|
|
9726
|
+
* year, then the clock of 24 hours with its seconds, in the APP's
|
|
9727
|
+
* language -- `locale` is the language t() answers in (the views
|
|
9728
|
+
* pass `i18next.language`), never the browser's:
|
|
9729
|
+
*
|
|
9730
|
+
* fmt_date_time(d, "es") -> "14 oct 2026, 15:05:09"
|
|
9731
|
+
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
9732
|
+
*
|
|
9733
|
+
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
9734
|
+
* gives the language-free "2026-10-14 15:05:09".
|
|
9735
|
+
*
|
|
9736
|
+
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
9737
|
+
* the reading C_YUI_JSON writes beside a time field all come from
|
|
9738
|
+
* here, so the same moment reads the same in the three.
|
|
9739
|
+
***************************************************************/
|
|
9740
|
+
function fmt_date_time(date, locale) {
|
|
9741
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
|
9742
|
+
try {
|
|
9743
|
+
return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
|
|
9744
|
+
} catch (e) {
|
|
9745
|
+
let pad = (n) => String(n).padStart(2, "0");
|
|
9746
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
9747
|
+
}
|
|
9748
|
+
}
|
|
9684
9749
|
/************************************************************
|
|
9685
9750
|
* JSON type discriminator (viewer vocabulary)
|
|
9686
9751
|
************************************************************/
|
|
@@ -9832,16 +9897,20 @@ function is_time_field(field) {
|
|
|
9832
9897
|
return TIME_FIELDS.indexOf(field) >= 0;
|
|
9833
9898
|
}
|
|
9834
9899
|
/************************************************************
|
|
9835
|
-
* Format an epoch value as a local wall-clock string
|
|
9900
|
+
* Format an epoch value as a local wall-clock string, 24
|
|
9901
|
+
* hours, in the APP's language `locale` (fmt_date_time() of
|
|
9902
|
+
* yui_time.js, as the time cells of the forms and tables;
|
|
9903
|
+
* up to gobj-ui 7.26.51 it was toLocaleString(): the
|
|
9904
|
+
* browser's language, and 12 hours in English).
|
|
9836
9905
|
* Accepts seconds or milliseconds; returns null when the
|
|
9837
9906
|
* value is not a usable positive timestamp (0 == "unset").
|
|
9838
9907
|
************************************************************/
|
|
9839
|
-
function format_epoch(value) {
|
|
9908
|
+
function format_epoch(value, locale) {
|
|
9840
9909
|
if (typeof value !== "number" || !isFinite(value) || value <= 0) return null;
|
|
9841
9910
|
let ms = Math.abs(value) < 0xe8d4a51000 ? value * 1e3 : value;
|
|
9842
9911
|
let d = new Date(ms);
|
|
9843
9912
|
if (isNaN(d.getTime())) return null;
|
|
9844
|
-
return d
|
|
9913
|
+
return fmt_date_time(d, locale);
|
|
9845
9914
|
}
|
|
9846
9915
|
/************************************************************
|
|
9847
9916
|
* The text view's payload: the document as text, indented
|
|
@@ -10109,15 +10178,17 @@ function epoch_to_time_value(epoch, real_type) {
|
|
|
10109
10178
|
}
|
|
10110
10179
|
/************************************************************
|
|
10111
10180
|
* The value of a time column as a table cell shows it: the
|
|
10112
|
-
* local clock
|
|
10113
|
-
*
|
|
10114
|
-
*
|
|
10115
|
-
*
|
|
10116
|
-
|
|
10117
|
-
|
|
10181
|
+
* local clock, 24 hours, in the APP's language `locale`
|
|
10182
|
+
* (fmt_date_time() of yui_time.js: es "14 oct 2026, 15:05:09").
|
|
10183
|
+
* Up to gobj-ui 7.26.51 the form wrote "2026-10-14 15:05:09" and
|
|
10184
|
+
* the treedb table "14 oct 2026, 03:05:09 p. m.", in the
|
|
10185
|
+
* browser's language. "" for no time; a value that is not one is
|
|
10186
|
+
* shown as it is, so the reader sees what the column holds.
|
|
10187
|
+
************************************************************/
|
|
10188
|
+
function time_value_to_text(value, real_type, locale) {
|
|
10118
10189
|
let date = time_value_to_date(value, real_type);
|
|
10119
10190
|
if (!date) return value === null || value === void 0 ? "" : String(value);
|
|
10120
|
-
return
|
|
10191
|
+
return fmt_date_time(date, locale);
|
|
10121
10192
|
}
|
|
10122
10193
|
//#endregion
|
|
10123
10194
|
//#region src/form_time_cell_editor.js
|
|
@@ -12622,6 +12693,36 @@ function table_column_titles(template) {
|
|
|
12622
12693
|
});
|
|
12623
12694
|
return titles;
|
|
12624
12695
|
}
|
|
12696
|
+
var TIME_CELL_FORMATTERS = /* @__PURE__ */ new WeakSet();
|
|
12697
|
+
/******************************************************************
|
|
12698
|
+
* The formatter of a time cell: the local clock, 24 hours, in the
|
|
12699
|
+
* APP's language (fmt_date_time of yui_time.js, as the cells of
|
|
12700
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
|
|
12701
|
+
******************************************************************/
|
|
12702
|
+
function time_cell_formatter(real_type) {
|
|
12703
|
+
let formatter = function(cell) {
|
|
12704
|
+
return text_node(time_value_to_text(cell.getValue(), real_type, safe_locale(i18next.default.language)));
|
|
12705
|
+
};
|
|
12706
|
+
TIME_CELL_FORMATTERS.add(formatter);
|
|
12707
|
+
return formatter;
|
|
12708
|
+
}
|
|
12709
|
+
/******************************************************************
|
|
12710
|
+
* Draw the time cells of a table again, in the current language.
|
|
12711
|
+
* Cell by cell, never a redraw of the rows: a row's formatter
|
|
12712
|
+
* builds its nested tables anew -- empty. A cell being edited is
|
|
12713
|
+
* its editor's; Tabulator formats it again when the editor closes.
|
|
12714
|
+
******************************************************************/
|
|
12715
|
+
function reformat_time_cells(tabulator) {
|
|
12716
|
+
for (let column of tabulator.getColumns()) {
|
|
12717
|
+
let formatter = column.getDefinition().formatter;
|
|
12718
|
+
if (!TIME_CELL_FORMATTERS.has(formatter)) continue;
|
|
12719
|
+
for (let cell of column.getCells()) {
|
|
12720
|
+
let $cell = cell.getElement();
|
|
12721
|
+
if ($cell.classList.contains("tabulator-editing")) continue;
|
|
12722
|
+
$cell.replaceChildren(formatter(cell));
|
|
12723
|
+
}
|
|
12724
|
+
}
|
|
12725
|
+
}
|
|
12625
12726
|
/******************************************************************
|
|
12626
12727
|
* Convert a template's items in tabulator columns
|
|
12627
12728
|
******************************************************************/
|
|
@@ -12734,9 +12835,7 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12734
12835
|
case "time":
|
|
12735
12836
|
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
12736
12837
|
column.editorParams = { verticalNavigation: "table" };
|
|
12737
|
-
column.formatter =
|
|
12738
|
-
return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
|
|
12739
|
-
};
|
|
12838
|
+
column.formatter = time_cell_formatter(field_desc.real_type);
|
|
12740
12839
|
break;
|
|
12741
12840
|
case "color":
|
|
12742
12841
|
column.editor = "input";
|
|
@@ -13717,7 +13816,7 @@ function ac_name_json_editors(gobj, event, kw, src) {
|
|
|
13717
13816
|
* in the old language until it draws it again, so each is told to
|
|
13718
13817
|
* (a new onRenderMenu), and the render names it again.
|
|
13719
13818
|
************************************************************/
|
|
13720
|
-
function ac_language_changed$
|
|
13819
|
+
function ac_language_changed$11(gobj, event, kw, src) {
|
|
13721
13820
|
let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
|
|
13722
13821
|
if (!$container) return 0;
|
|
13723
13822
|
for (let $editor of $container.querySelectorAll(".jsoneditor")) {
|
|
@@ -13726,7 +13825,10 @@ function ac_language_changed$10(gobj, event, kw, src) {
|
|
|
13726
13825
|
}
|
|
13727
13826
|
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
|
|
13728
13827
|
let tabulator = $table.tabulator;
|
|
13729
|
-
if (tabulator && tabulator.initialized && $table.template)
|
|
13828
|
+
if (tabulator && tabulator.initialized && $table.template) {
|
|
13829
|
+
yui_tabulator_relocalize(tabulator, i18next.t, table_column_titles($table.template));
|
|
13830
|
+
reformat_time_cells(tabulator);
|
|
13831
|
+
}
|
|
13730
13832
|
}
|
|
13731
13833
|
return 0;
|
|
13732
13834
|
}
|
|
@@ -13903,7 +14005,7 @@ function create_gclass$17(gclass_name) {
|
|
|
13903
14005
|
],
|
|
13904
14006
|
[
|
|
13905
14007
|
"EV_LANGUAGE_CHANGED",
|
|
13906
|
-
ac_language_changed$
|
|
14008
|
+
ac_language_changed$11,
|
|
13907
14009
|
null
|
|
13908
14010
|
]
|
|
13909
14011
|
]]];
|
|
@@ -14299,7 +14401,7 @@ function mt_create$16(gobj) {
|
|
|
14299
14401
|
* rewritten in place, and the map's locale with them so a
|
|
14300
14402
|
* control or a popup built later is right too.
|
|
14301
14403
|
***************************************************************/
|
|
14302
|
-
function ac_language_changed$
|
|
14404
|
+
function ac_language_changed$10(gobj, event, kw, src) {
|
|
14303
14405
|
let priv = gobj.priv;
|
|
14304
14406
|
if (priv.xmap) yui_maplibre_relocalize(priv.xmap, i18next.t);
|
|
14305
14407
|
return 0;
|
|
@@ -14867,7 +14969,7 @@ function create_gclass$16(gclass_name) {
|
|
|
14867
14969
|
], [["ST_IDLE", [
|
|
14868
14970
|
[
|
|
14869
14971
|
"EV_LANGUAGE_CHANGED",
|
|
14870
|
-
ac_language_changed$
|
|
14972
|
+
ac_language_changed$10,
|
|
14871
14973
|
null
|
|
14872
14974
|
],
|
|
14873
14975
|
[
|
|
@@ -15016,12 +15118,145 @@ function yui_uplot_axes(axes) {
|
|
|
15016
15118
|
});
|
|
15017
15119
|
}
|
|
15018
15120
|
//#endregion
|
|
15121
|
+
//#region src/yui_uplot_time.js
|
|
15122
|
+
/***********************************************************************
|
|
15123
|
+
* yui_uplot_time.js
|
|
15124
|
+
*
|
|
15125
|
+
* The texts uPlot writes for a moment -- the ticks of a time axis
|
|
15126
|
+
* and the reading of the legend -- in the APP's language, with a
|
|
15127
|
+
* clock of 24 hours, as every other time a gobj-ui view shows
|
|
15128
|
+
* (fmt_date_time of yui_time.js).
|
|
15129
|
+
*
|
|
15130
|
+
* uPlot writes them from templates of its own, in English and
|
|
15131
|
+
* 12 hours: "3pm", "3:05pm", "10/14" (month first), "Oct", and
|
|
15132
|
+
* "2026-10-14 3:05pm" in the legend. Its `fmtDate` option takes
|
|
15133
|
+
* the template and returns the function that writes a Date with
|
|
15134
|
+
* it; this one is given to it:
|
|
15135
|
+
*
|
|
15136
|
+
* legend "{YYYY}-{MM}-{DD} {h}:{mm}{aa}" -> fmt_date_time()
|
|
15137
|
+
* "14 oct 2026, 15:05:09"
|
|
15138
|
+
* "{h}{aa}" "3pm" -> "15:00"
|
|
15139
|
+
* "{h}:{mm}{aa}" "3:05pm" -> "15:05"
|
|
15140
|
+
* "{M}/{D}" "10/14" -> es "14/10", en "10/14"
|
|
15141
|
+
* "{M}/{D}/{YY}" "10/14/26"-> es "14/10/26", en "10/14/26"
|
|
15142
|
+
* "{MMM}" "Oct" -> es "oct", en "Oct"
|
|
15143
|
+
*
|
|
15144
|
+
* The language is asked for on every call, so a redraw after a
|
|
15145
|
+
* language change writes the new one (C_YUI_UPLOT redraws its
|
|
15146
|
+
* axes on EV_LANGUAGE_CHANGED).
|
|
15147
|
+
*
|
|
15148
|
+
* Copyright (c) 2026, ArtGins.
|
|
15149
|
+
* All Rights Reserved.
|
|
15150
|
+
***********************************************************************/
|
|
15151
|
+
var LEGEND_STAMP = "{YYYY}-{MM}-{DD} {h}:{mm}{aa}";
|
|
15152
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
15153
|
+
var __formatters__ = /* @__PURE__ */ new Map();
|
|
15154
|
+
function intl(locale, opts) {
|
|
15155
|
+
let key = locale + "|" + JSON.stringify(opts);
|
|
15156
|
+
let f = __formatters__.get(key);
|
|
15157
|
+
if (!f) {
|
|
15158
|
+
try {
|
|
15159
|
+
f = new Intl.DateTimeFormat(locale, opts);
|
|
15160
|
+
} catch (e) {
|
|
15161
|
+
f = new Intl.DateTimeFormat("en", opts);
|
|
15162
|
+
}
|
|
15163
|
+
__formatters__.set(key, f);
|
|
15164
|
+
}
|
|
15165
|
+
return f;
|
|
15166
|
+
}
|
|
15167
|
+
var WHOLE = [
|
|
15168
|
+
["{M}/{D}/{YY}", (d, loc) => intl(loc, {
|
|
15169
|
+
day: "numeric",
|
|
15170
|
+
month: "numeric",
|
|
15171
|
+
year: "2-digit"
|
|
15172
|
+
}).format(d)],
|
|
15173
|
+
["{M}/{D}", (d, loc) => intl(loc, {
|
|
15174
|
+
day: "numeric",
|
|
15175
|
+
month: "numeric"
|
|
15176
|
+
}).format(d)],
|
|
15177
|
+
["{h}{aa}", (d) => `${pad2(d.getHours())}:00`]
|
|
15178
|
+
];
|
|
15179
|
+
var TOKENS = {
|
|
15180
|
+
YYYY: (d) => String(d.getFullYear()),
|
|
15181
|
+
YY: (d) => String(d.getFullYear()).slice(2),
|
|
15182
|
+
MMMM: (d, loc) => intl(loc, { month: "long" }).format(d),
|
|
15183
|
+
MMM: (d, loc) => intl(loc, { month: "short" }).format(d),
|
|
15184
|
+
MM: (d) => pad2(d.getMonth() + 1),
|
|
15185
|
+
M: (d) => String(d.getMonth() + 1),
|
|
15186
|
+
DD: (d) => pad2(d.getDate()),
|
|
15187
|
+
D: (d) => String(d.getDate()),
|
|
15188
|
+
WWWW: (d, loc) => intl(loc, { weekday: "long" }).format(d),
|
|
15189
|
+
WWW: (d, loc) => intl(loc, { weekday: "short" }).format(d),
|
|
15190
|
+
HH: (d) => pad2(d.getHours()),
|
|
15191
|
+
H: (d) => String(d.getHours()),
|
|
15192
|
+
hh: (d) => pad2(d.getHours()),
|
|
15193
|
+
h: (d) => pad2(d.getHours()),
|
|
15194
|
+
AA: () => "",
|
|
15195
|
+
aa: () => "",
|
|
15196
|
+
a: () => "",
|
|
15197
|
+
mm: (d) => pad2(d.getMinutes()),
|
|
15198
|
+
m: (d) => String(d.getMinutes()),
|
|
15199
|
+
ss: (d) => pad2(d.getSeconds()),
|
|
15200
|
+
s: (d) => String(d.getSeconds()),
|
|
15201
|
+
fff: (d) => String(d.getMilliseconds()).padStart(3, "0")
|
|
15202
|
+
};
|
|
15203
|
+
/***************************************************************
|
|
15204
|
+
* A template -> its parts: literal text, or a function of
|
|
15205
|
+
* (date, locale).
|
|
15206
|
+
***************************************************************/
|
|
15207
|
+
function template_parts(tpl) {
|
|
15208
|
+
let parts = [];
|
|
15209
|
+
let rest = String(tpl);
|
|
15210
|
+
while (rest.length > 0) {
|
|
15211
|
+
let whole = WHOLE.find(([frag]) => rest.startsWith(frag));
|
|
15212
|
+
if (whole) {
|
|
15213
|
+
parts.push(whole[1]);
|
|
15214
|
+
rest = rest.slice(whole[0].length);
|
|
15215
|
+
continue;
|
|
15216
|
+
}
|
|
15217
|
+
let m = /^\{([a-z]+)\}/i.exec(rest);
|
|
15218
|
+
if (m && TOKENS[m[1]]) {
|
|
15219
|
+
parts.push(TOKENS[m[1]]);
|
|
15220
|
+
rest = rest.slice(m[0].length);
|
|
15221
|
+
continue;
|
|
15222
|
+
}
|
|
15223
|
+
let next = rest.indexOf("{", 1);
|
|
15224
|
+
let text = next < 0 ? rest : rest.slice(0, next);
|
|
15225
|
+
parts.push(text);
|
|
15226
|
+
rest = rest.slice(text.length);
|
|
15227
|
+
}
|
|
15228
|
+
return parts;
|
|
15229
|
+
}
|
|
15230
|
+
/***************************************************************
|
|
15231
|
+
* uPlot's `fmtDate` option. `get_locale` answers the app's
|
|
15232
|
+
* language at the moment of the call (the views pass
|
|
15233
|
+
* `() => i18next.language`).
|
|
15234
|
+
***************************************************************/
|
|
15235
|
+
function yui_uplot_fmt_date(get_locale) {
|
|
15236
|
+
let locale = () => safe_locale(typeof get_locale === "function" ? get_locale() : null);
|
|
15237
|
+
return function(tpl) {
|
|
15238
|
+
if (tpl === LEGEND_STAMP) return (date) => fmt_date_time(date, locale());
|
|
15239
|
+
let parts = template_parts(tpl);
|
|
15240
|
+
return function(date) {
|
|
15241
|
+
let loc = locale();
|
|
15242
|
+
let out = "";
|
|
15243
|
+
for (let part of parts) out += typeof part === "string" ? part : part(date, loc);
|
|
15244
|
+
return out;
|
|
15245
|
+
};
|
|
15246
|
+
};
|
|
15247
|
+
}
|
|
15248
|
+
//#endregion
|
|
15019
15249
|
//#region src/c_yui_uplot.js
|
|
15020
15250
|
/***********************************************************************
|
|
15021
15251
|
* c_yui_uplot.js
|
|
15022
15252
|
*
|
|
15023
15253
|
* Graphics, Charts with uPlot
|
|
15024
15254
|
*
|
|
15255
|
+
* A moment uPlot writes -- a tick of a time axis, the reading of
|
|
15256
|
+
* the legend -- is in the app's language with a clock of 24 hours
|
|
15257
|
+
* (yui_uplot_time.js), and is written again on the shell's
|
|
15258
|
+
* EV_LANGUAGE_CHANGED.
|
|
15259
|
+
*
|
|
15025
15260
|
* Copyright (c) 2025-2026, ArtGins.
|
|
15026
15261
|
* All Rights Reserved.
|
|
15027
15262
|
***********************************************************************/
|
|
@@ -15050,7 +15285,10 @@ var attrs_table$15 = [
|
|
|
15050
15285
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "timeout_idle", 0, 5, "Idle timeout (seconds)"),
|
|
15051
15286
|
(0, _yuneta_gobj_js.SDATA_END)()
|
|
15052
15287
|
];
|
|
15053
|
-
var PRIVATE_DATA$15 = {
|
|
15288
|
+
var PRIVATE_DATA$15 = {
|
|
15289
|
+
theme_observer: null,
|
|
15290
|
+
lang_shell: null
|
|
15291
|
+
};
|
|
15054
15292
|
var __gclass__$15 = null;
|
|
15055
15293
|
/******************************
|
|
15056
15294
|
* Framework Methods
|
|
@@ -15068,11 +15306,22 @@ function mt_create$15(gobj) {
|
|
|
15068
15306
|
/***************************************************************
|
|
15069
15307
|
* Framework Method: Start
|
|
15070
15308
|
***************************************************************/
|
|
15071
|
-
function mt_start$15(gobj) {
|
|
15309
|
+
function mt_start$15(gobj) {
|
|
15310
|
+
let priv = gobj.priv;
|
|
15311
|
+
let shell = yui_shell_of(gobj);
|
|
15312
|
+
if (shell) {
|
|
15313
|
+
(0, _yuneta_gobj_js.gobj_subscribe_event)(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
15314
|
+
priv.lang_shell = shell;
|
|
15315
|
+
}
|
|
15316
|
+
}
|
|
15072
15317
|
/***************************************************************
|
|
15073
15318
|
* Framework Method: Stop
|
|
15074
15319
|
***************************************************************/
|
|
15075
|
-
function mt_stop$15(gobj) {
|
|
15320
|
+
function mt_stop$15(gobj) {
|
|
15321
|
+
let priv = gobj.priv;
|
|
15322
|
+
if (priv.lang_shell && !(0, _yuneta_gobj_js.gobj_is_destroying)(priv.lang_shell)) (0, _yuneta_gobj_js.gobj_unsubscribe_event)(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
15323
|
+
priv.lang_shell = null;
|
|
15324
|
+
}
|
|
15076
15325
|
/***************************************************************
|
|
15077
15326
|
* Framework Method: Destroy
|
|
15078
15327
|
***************************************************************/
|
|
@@ -15110,7 +15359,8 @@ function build_ui$14(gobj) {
|
|
|
15110
15359
|
height: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "height"),
|
|
15111
15360
|
series: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "series"),
|
|
15112
15361
|
axes: yui_uplot_axes((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "axes")),
|
|
15113
|
-
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales")
|
|
15362
|
+
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales"),
|
|
15363
|
+
fmtDate: yui_uplot_fmt_date(() => i18next.default.language)
|
|
15114
15364
|
};
|
|
15115
15365
|
let uplot$2 = new uplot.default(uPlot_options, (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "data"), $container);
|
|
15116
15366
|
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "uplot", uplot$2);
|
|
@@ -15232,17 +15482,33 @@ function ac_theme$4(gobj, event, kw, src) {
|
|
|
15232
15482
|
return 0;
|
|
15233
15483
|
}
|
|
15234
15484
|
/******************************************************
|
|
15485
|
+
* The language changed: the ticks of a time axis and the
|
|
15486
|
+
* reading of the legend ask for it when they are written,
|
|
15487
|
+
* so they are written again.
|
|
15488
|
+
******************************************************/
|
|
15489
|
+
function ac_language_changed$9(gobj, event, kw, src) {
|
|
15490
|
+
let uplot$6 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15491
|
+
if (!uplot$6) return 0;
|
|
15492
|
+
try {
|
|
15493
|
+
uplot$6.redraw(true, true);
|
|
15494
|
+
uplot$6.setLegend(null, false);
|
|
15495
|
+
} catch (e) {
|
|
15496
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot redraw the chart: ${e}`);
|
|
15497
|
+
}
|
|
15498
|
+
return 0;
|
|
15499
|
+
}
|
|
15500
|
+
/******************************************************
|
|
15235
15501
|
*
|
|
15236
15502
|
******************************************************/
|
|
15237
15503
|
function ac_del_serie(gobj, event, kw, src) {
|
|
15238
|
-
let uplot$
|
|
15239
|
-
for (let idx = 1; idx < uplot$
|
|
15240
|
-
let serie = uplot$
|
|
15504
|
+
let uplot$7 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15505
|
+
for (let idx = 1; idx < uplot$7.series.length; idx++) {
|
|
15506
|
+
let serie = uplot$7.series[idx];
|
|
15241
15507
|
if (serie.id && serie.id === kw.id) {
|
|
15242
|
-
uplot$
|
|
15243
|
-
let data = uplot$
|
|
15508
|
+
uplot$7.delSeries(idx);
|
|
15509
|
+
let data = uplot$7.data.splice(idx, 1);
|
|
15244
15510
|
if (data.length === 1) data = [[]];
|
|
15245
|
-
uplot$
|
|
15511
|
+
uplot$7.setData(data);
|
|
15246
15512
|
return 0;
|
|
15247
15513
|
}
|
|
15248
15514
|
}
|
|
@@ -15252,9 +15518,9 @@ function ac_del_serie(gobj, event, kw, src) {
|
|
|
15252
15518
|
*
|
|
15253
15519
|
******************************************************/
|
|
15254
15520
|
function ac_clear$1(gobj, event, kw, src) {
|
|
15255
|
-
let uplot$
|
|
15256
|
-
uplot$
|
|
15257
|
-
for (let idx = uplot$
|
|
15521
|
+
let uplot$8 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15522
|
+
uplot$8.setData([[]]);
|
|
15523
|
+
for (let idx = uplot$8.series.length - 1; idx > 0; idx--) uplot$8.delSeries(idx);
|
|
15258
15524
|
return 0;
|
|
15259
15525
|
}
|
|
15260
15526
|
/***************************
|
|
@@ -15279,7 +15545,8 @@ function create_gclass$15(gclass_name) {
|
|
|
15279
15545
|
["EV_ADD_SERIE", 0],
|
|
15280
15546
|
["EV_DEL_SERIE", 0],
|
|
15281
15547
|
["EV_CLEAR", 0],
|
|
15282
|
-
["EV_THEME", 0]
|
|
15548
|
+
["EV_THEME", 0],
|
|
15549
|
+
["EV_LANGUAGE_CHANGED", 0]
|
|
15283
15550
|
], [["ST_IDLE", [
|
|
15284
15551
|
[
|
|
15285
15552
|
"EV_LOAD_DATA",
|
|
@@ -15305,6 +15572,11 @@ function create_gclass$15(gclass_name) {
|
|
|
15305
15572
|
"EV_THEME",
|
|
15306
15573
|
ac_theme$4,
|
|
15307
15574
|
null
|
|
15575
|
+
],
|
|
15576
|
+
[
|
|
15577
|
+
"EV_LANGUAGE_CHANGED",
|
|
15578
|
+
ac_language_changed$9,
|
|
15579
|
+
null
|
|
15308
15580
|
]
|
|
15309
15581
|
]]], gmt$15, 0, attrs_table$15, PRIVATE_DATA$15, 0, 0, 0, 0);
|
|
15310
15582
|
if (!__gclass__$15) return -1;
|
|
@@ -18371,7 +18643,8 @@ var PRIVATE_DATA$13 = {
|
|
|
18371
18643
|
$search_ctl: null,
|
|
18372
18644
|
$expand_btn: null,
|
|
18373
18645
|
$collapse_btn: null,
|
|
18374
|
-
$mode_btns: null
|
|
18646
|
+
$mode_btns: null,
|
|
18647
|
+
lang_shell: null
|
|
18375
18648
|
};
|
|
18376
18649
|
var __gclass__$13 = null;
|
|
18377
18650
|
/******************************
|
|
@@ -18399,13 +18672,22 @@ function mt_create$13(gobj) {
|
|
|
18399
18672
|
* Framework Method: Start
|
|
18400
18673
|
***************************************************************/
|
|
18401
18674
|
function mt_start$13(gobj) {
|
|
18402
|
-
|
|
18675
|
+
let priv = gobj.priv;
|
|
18676
|
+
if (priv.root !== null) (0, _yuneta_gobj_js.gobj_change_state)(gobj, "ST_READY");
|
|
18677
|
+
let shell = yui_shell_of(gobj);
|
|
18678
|
+
if (shell) {
|
|
18679
|
+
(0, _yuneta_gobj_js.gobj_subscribe_event)(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
18680
|
+
priv.lang_shell = shell;
|
|
18681
|
+
}
|
|
18403
18682
|
render_view$1(gobj);
|
|
18404
18683
|
}
|
|
18405
18684
|
/***************************************************************
|
|
18406
18685
|
* Framework Method: Stop
|
|
18407
18686
|
***************************************************************/
|
|
18408
18687
|
function mt_stop$13(gobj) {
|
|
18688
|
+
let priv = gobj.priv;
|
|
18689
|
+
if (priv.lang_shell && !(0, _yuneta_gobj_js.gobj_is_destroying)(priv.lang_shell)) (0, _yuneta_gobj_js.gobj_unsubscribe_event)(priv.lang_shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
18690
|
+
priv.lang_shell = null;
|
|
18409
18691
|
teardown_graph_child$1(gobj);
|
|
18410
18692
|
}
|
|
18411
18693
|
/***************************************************************
|
|
@@ -19104,7 +19386,7 @@ function leaf_row(key, value, depth) {
|
|
|
19104
19386
|
text_node(text)
|
|
19105
19387
|
]);
|
|
19106
19388
|
if (key !== null && is_time_field(String(key))) {
|
|
19107
|
-
let wall = format_epoch(value);
|
|
19389
|
+
let wall = format_epoch(value, safe_locale(i18next.default.language));
|
|
19108
19390
|
if (wall) body.push([
|
|
19109
19391
|
"span",
|
|
19110
19392
|
{ class: "JSON_TIME is-size-7 yui-text-quiet ml-2" },
|
|
@@ -19355,6 +19637,12 @@ function ac_json_item_clicked(gobj, event, kw, src) {
|
|
|
19355
19637
|
}
|
|
19356
19638
|
/************************************************************
|
|
19357
19639
|
* EV_LANGUAGE_CHANGED — re-translate chrome + re-render
|
|
19640
|
+
*
|
|
19641
|
+
* Only the TREE is drawn again: it writes the reading of a
|
|
19642
|
+
* time field in the language of the moment it was drawn. The
|
|
19643
|
+
* text view carries its keys (refresh_language reaches them),
|
|
19644
|
+
* and loading the graph again would throw away the reader's
|
|
19645
|
+
* camera for nothing.
|
|
19358
19646
|
************************************************************/
|
|
19359
19647
|
function ac_language_changed$8(gobj, event, kw, src) {
|
|
19360
19648
|
let priv = gobj.priv;
|
|
@@ -19364,7 +19652,7 @@ function ac_language_changed$8(gobj, event, kw, src) {
|
|
|
19364
19652
|
if (priv.$search) priv.$search.setAttribute("placeholder", (0, i18next.t)("search"));
|
|
19365
19653
|
apply_view_mode$1(gobj);
|
|
19366
19654
|
}
|
|
19367
|
-
|
|
19655
|
+
if (current_view_mode$1(gobj) === "tree") render_tree(gobj);
|
|
19368
19656
|
return 0;
|
|
19369
19657
|
}
|
|
19370
19658
|
/************************************************************
|
|
@@ -33045,26 +33333,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
|
|
|
33045
33333
|
switch (field_desc.real_type) {
|
|
33046
33334
|
case "string":
|
|
33047
33335
|
case "integer":
|
|
33048
|
-
value =
|
|
33049
|
-
if (
|
|
33050
|
-
value = "";
|
|
33051
|
-
break;
|
|
33052
|
-
}
|
|
33053
|
-
const rawLocale = navigator.language;
|
|
33054
|
-
const userLocale = typeof rawLocale === "string" && rawLocale && rawLocale !== "undefined" ? rawLocale : void 0;
|
|
33055
|
-
const formatter = new Intl.DateTimeFormat(userLocale, {
|
|
33056
|
-
day: "numeric",
|
|
33057
|
-
month: "short",
|
|
33058
|
-
year: "numeric",
|
|
33059
|
-
hour: "2-digit",
|
|
33060
|
-
minute: "2-digit",
|
|
33061
|
-
second: "2-digit",
|
|
33062
|
-
hour12: true
|
|
33063
|
-
});
|
|
33064
|
-
value = (0, _yuneta_gobj_js.createElement2)([
|
|
33336
|
+
value = time_value_to_text(value, field_desc.real_type, safe_locale(i18next.default.language));
|
|
33337
|
+
if (value) value = (0, _yuneta_gobj_js.createElement2)([
|
|
33065
33338
|
"span",
|
|
33066
33339
|
{ class: "is-size-7" },
|
|
33067
|
-
|
|
33340
|
+
text_node(value)
|
|
33068
33341
|
]);
|
|
33069
33342
|
}
|
|
33070
33343
|
break;
|
|
@@ -82882,21 +83155,6 @@ var YUI_ROLLING = {
|
|
|
82882
83155
|
* Locale / i18n
|
|
82883
83156
|
***************************/
|
|
82884
83157
|
/***************************************************************
|
|
82885
|
-
* The locale to format with.
|
|
82886
|
-
*
|
|
82887
|
-
* NEVER at module top level, and never `navigator.language` raw:
|
|
82888
|
-
* Firefox can report the literal STRING "undefined", and every Intl
|
|
82889
|
-
* constructor throws RangeError on it — a module that built its
|
|
82890
|
-
* formatter on import took the whole bundle down with it (that is why
|
|
82891
|
-
* gui_agent refuses to import the gobj-ui barrel).
|
|
82892
|
-
***************************************************************/
|
|
82893
|
-
function safe_locale(locale) {
|
|
82894
|
-
if (typeof locale === "string" && locale && locale !== "undefined") return locale;
|
|
82895
|
-
let nav = typeof navigator !== "undefined" ? navigator.language : null;
|
|
82896
|
-
if (typeof nav === "string" && nav && nav !== "undefined") return nav;
|
|
82897
|
-
return "en";
|
|
82898
|
-
}
|
|
82899
|
-
/***************************************************************
|
|
82900
83158
|
* Translate through the APP's translator when it gave us one, and
|
|
82901
83159
|
* degrade to the key itself otherwise — interpolating `{{x}}` by hand,
|
|
82902
83160
|
* so a label never renders raw mustaches at a caller that has no i18n.
|
|
@@ -86258,6 +86516,7 @@ exports.enableElements = enableElements;
|
|
|
86258
86516
|
exports.epoch_to_local_input = epoch_to_local_input;
|
|
86259
86517
|
exports.epoch_to_ms = epoch_to_ms;
|
|
86260
86518
|
exports.expose_view_container = expose_view_container;
|
|
86519
|
+
exports.fmt_date_time = fmt_date_time;
|
|
86261
86520
|
exports.fmt_epoch = fmt_epoch;
|
|
86262
86521
|
exports.getStrokeColor = getStrokeColor;
|
|
86263
86522
|
exports.infer_period = infer_period;
|