@yuneta/gobj-ui 7.26.51 → 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 +88 -2
- package/dist/gobj-ui.cjs.js +1267 -1025
- package/dist/gobj-ui.es.js +1258 -1017
- 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_time.js +37 -0
- 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,450 +9681,1074 @@ function yui_icons_list() {
|
|
|
9681
9681
|
});
|
|
9682
9682
|
return list;
|
|
9683
9683
|
}
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
|
|
9688
|
-
if (value === null) return "null";
|
|
9689
|
-
if (Array.isArray(value)) return "array";
|
|
9690
|
-
switch (typeof value) {
|
|
9691
|
-
case "string": return "string";
|
|
9692
|
-
case "number": return "number";
|
|
9693
|
-
case "boolean": return "boolean";
|
|
9694
|
-
case "object": return "object";
|
|
9695
|
-
default: return "unknown";
|
|
9696
|
-
}
|
|
9697
|
-
}
|
|
9698
|
-
/************************************************************
|
|
9699
|
-
* Detect a kw_collapse() sentinel.
|
|
9684
|
+
//#endregion
|
|
9685
|
+
//#region src/yui_time.js
|
|
9686
|
+
/***********************************************************************
|
|
9687
|
+
* yui_time.js
|
|
9700
9688
|
*
|
|
9701
|
-
*
|
|
9702
|
-
* { "__collapsed__": { "path": ..., "size": N } }
|
|
9703
|
-
* and an over-limit array with:
|
|
9704
|
-
* [ { "__collapsed__": { "path": ..., "size": N } } ]
|
|
9689
|
+
* Time, without a DOM: epochs, and the algebra of PERIODS.
|
|
9705
9690
|
*
|
|
9706
|
-
*
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9691
|
+
* Two things live here, and they are the two halves of every date
|
|
9692
|
+
* UI the projects keep rewriting:
|
|
9693
|
+
*
|
|
9694
|
+
* 1) EPOCH <-> the local wall clock. A timestamp travels in the
|
|
9695
|
+
* producer's own unit — seconds, or milliseconds when a topic
|
|
9696
|
+
* says so — and every conversion crosses that `ms` flag. Getting
|
|
9697
|
+
* it wrong puts the same instant on two different clocks in one
|
|
9698
|
+
* screen (it did: a picker asking "from 18:55" local returned
|
|
9699
|
+
* rows a table labelled 16:55).
|
|
9700
|
+
*
|
|
9701
|
+
* 2) The PERIOD. A period is not an enum of five names: it is a
|
|
9702
|
+
* BUCKET, and a bucket is `count` of a `unit`:
|
|
9703
|
+
*
|
|
9704
|
+
* {id: "day", unit: "day", count: 1}
|
|
9705
|
+
* {id: "week", unit: "week", count: 1} ISO, Mon-first
|
|
9706
|
+
* {id: "bimester", unit: "month", count: 2}
|
|
9707
|
+
* {id: "quarter", unit: "month", count: 3}
|
|
9708
|
+
* {id: "semester", unit: "month", count: 6}
|
|
9709
|
+
* {id: "decade", unit: "year", count: 10}
|
|
9710
|
+
* {id: "15min", unit: "minute", count: 15}
|
|
9711
|
+
*
|
|
9712
|
+
* Given that pair, ONE implementation answers every question a
|
|
9713
|
+
* date navigator asks — where does the bucket holding this
|
|
9714
|
+
* instant start and end, what is the previous/next one, what do
|
|
9715
|
+
* I call it — so an app that wants quarters declares a quarter
|
|
9716
|
+
* instead of asking for a new component.
|
|
9717
|
+
*
|
|
9718
|
+
* Buckets are ALIGNED, never "count back from now": months align to
|
|
9719
|
+
* the year (which is why 2, 3, 4, 6 and 12 fall on clean calendar
|
|
9720
|
+
* boundaries), weeks to Monday, hours to local midnight. "Last 7
|
|
9721
|
+
* days" is a different animal — a rolling window — and it is not a
|
|
9722
|
+
* period: see `rolling_bounds()`.
|
|
9723
|
+
*
|
|
9724
|
+
* Everything here is LOCAL time (the user reads a local clock) and
|
|
9725
|
+
* DST-safe: it never adds 86400000 ms to cross a day, it builds the
|
|
9726
|
+
* next date from calendar fields and lets the platform do it.
|
|
9727
|
+
*
|
|
9728
|
+
* Copyright (c) 2026, ArtGins.
|
|
9729
|
+
* All Rights Reserved.
|
|
9730
|
+
***********************************************************************/
|
|
9731
|
+
/***************************************************************
|
|
9732
|
+
* Constants
|
|
9733
|
+
***************************************************************/
|
|
9734
|
+
var MS_DAY = 864e5;
|
|
9735
|
+
var PERIOD_UNITS = [
|
|
9736
|
+
"minute",
|
|
9737
|
+
"hour",
|
|
9738
|
+
"day",
|
|
9739
|
+
"week",
|
|
9740
|
+
"month",
|
|
9741
|
+
"year"
|
|
9742
|
+
];
|
|
9743
|
+
var YUI_PERIODS = {
|
|
9744
|
+
minute: {
|
|
9745
|
+
id: "minute",
|
|
9746
|
+
unit: "minute",
|
|
9747
|
+
count: 1
|
|
9748
|
+
},
|
|
9749
|
+
"5min": {
|
|
9750
|
+
id: "5min",
|
|
9751
|
+
unit: "minute",
|
|
9752
|
+
count: 5
|
|
9753
|
+
},
|
|
9754
|
+
"15min": {
|
|
9755
|
+
id: "15min",
|
|
9756
|
+
unit: "minute",
|
|
9757
|
+
count: 15
|
|
9758
|
+
},
|
|
9759
|
+
hour: {
|
|
9760
|
+
id: "hour",
|
|
9761
|
+
unit: "hour",
|
|
9762
|
+
count: 1
|
|
9763
|
+
},
|
|
9764
|
+
day: {
|
|
9765
|
+
id: "day",
|
|
9766
|
+
unit: "day",
|
|
9767
|
+
count: 1
|
|
9768
|
+
},
|
|
9769
|
+
week: {
|
|
9770
|
+
id: "week",
|
|
9771
|
+
unit: "week",
|
|
9772
|
+
count: 1
|
|
9773
|
+
},
|
|
9774
|
+
fortnight: {
|
|
9775
|
+
id: "fortnight",
|
|
9776
|
+
unit: "week",
|
|
9777
|
+
count: 2
|
|
9778
|
+
},
|
|
9779
|
+
month: {
|
|
9780
|
+
id: "month",
|
|
9781
|
+
unit: "month",
|
|
9782
|
+
count: 1
|
|
9783
|
+
},
|
|
9784
|
+
bimester: {
|
|
9785
|
+
id: "bimester",
|
|
9786
|
+
unit: "month",
|
|
9787
|
+
count: 2
|
|
9788
|
+
},
|
|
9789
|
+
quarter: {
|
|
9790
|
+
id: "quarter",
|
|
9791
|
+
unit: "month",
|
|
9792
|
+
count: 3
|
|
9793
|
+
},
|
|
9794
|
+
semester: {
|
|
9795
|
+
id: "semester",
|
|
9796
|
+
unit: "month",
|
|
9797
|
+
count: 6
|
|
9798
|
+
},
|
|
9799
|
+
year: {
|
|
9800
|
+
id: "year",
|
|
9801
|
+
unit: "year",
|
|
9802
|
+
count: 1
|
|
9803
|
+
},
|
|
9804
|
+
decade: {
|
|
9805
|
+
id: "decade",
|
|
9806
|
+
unit: "year",
|
|
9807
|
+
count: 10
|
|
9720
9808
|
}
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9809
|
+
};
|
|
9810
|
+
var YUI_PERIODS_DEFAULT = [
|
|
9811
|
+
"hour",
|
|
9812
|
+
"day",
|
|
9813
|
+
"week",
|
|
9814
|
+
"month",
|
|
9815
|
+
"year"
|
|
9816
|
+
];
|
|
9817
|
+
var YUI_ROLLING = {
|
|
9818
|
+
"1h": {
|
|
9819
|
+
id: "1h",
|
|
9820
|
+
secs: 3600,
|
|
9821
|
+
label: "last hour"
|
|
9822
|
+
},
|
|
9823
|
+
"6h": {
|
|
9824
|
+
id: "6h",
|
|
9825
|
+
secs: 21600,
|
|
9826
|
+
label: "last 6h"
|
|
9827
|
+
},
|
|
9828
|
+
"24h": {
|
|
9829
|
+
id: "24h",
|
|
9830
|
+
secs: 86400,
|
|
9831
|
+
label: "last 24h"
|
|
9832
|
+
},
|
|
9833
|
+
"7d": {
|
|
9834
|
+
id: "7d",
|
|
9835
|
+
secs: 604800,
|
|
9836
|
+
label: "last 7 days"
|
|
9837
|
+
},
|
|
9838
|
+
"30d": {
|
|
9839
|
+
id: "30d",
|
|
9840
|
+
secs: 2592e3,
|
|
9841
|
+
label: "last 30 days"
|
|
9731
9842
|
}
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9843
|
+
};
|
|
9844
|
+
/***************************
|
|
9845
|
+
* Locale / i18n
|
|
9846
|
+
***************************/
|
|
9847
|
+
/***************************************************************
|
|
9848
|
+
* The locale to format with.
|
|
9849
|
+
*
|
|
9850
|
+
* NEVER at module top level, and never `navigator.language` raw:
|
|
9851
|
+
* Firefox can report the literal STRING "undefined", and every Intl
|
|
9852
|
+
* constructor throws RangeError on it — a module that built its
|
|
9853
|
+
* formatter on import took the whole bundle down with it (that is why
|
|
9854
|
+
* gui_agent refuses to import the gobj-ui barrel).
|
|
9855
|
+
***************************************************************/
|
|
9856
|
+
function safe_locale(locale) {
|
|
9857
|
+
if (typeof locale === "string" && locale && locale !== "undefined") return locale;
|
|
9858
|
+
let nav = typeof navigator !== "undefined" ? navigator.language : null;
|
|
9859
|
+
if (typeof nav === "string" && nav && nav !== "undefined") return nav;
|
|
9860
|
+
return "en";
|
|
9741
9861
|
}
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9862
|
+
/***************************************************************
|
|
9863
|
+
* Translate through the APP's translator when it gave us one, and
|
|
9864
|
+
* degrade to the key itself otherwise — interpolating `{{x}}` by hand,
|
|
9865
|
+
* so a label never renders raw mustaches at a caller that has no i18n.
|
|
9866
|
+
***************************************************************/
|
|
9867
|
+
function tr(t, key, params) {
|
|
9868
|
+
if (typeof t === "function") return t(key, params);
|
|
9869
|
+
let s = key;
|
|
9870
|
+
for (let k in params || {}) s = s.replaceAll(`{{${k}}}`, String(params[k]));
|
|
9871
|
+
return s;
|
|
9745
9872
|
}
|
|
9746
|
-
|
|
9747
|
-
*
|
|
9748
|
-
*
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
else return;
|
|
9873
|
+
/***************************************************************
|
|
9874
|
+
* Intl formatters, built PER CALL (see safe_locale). They are cheap
|
|
9875
|
+
* next to a repaint, and caching them would need a locale-change hook
|
|
9876
|
+
* the library has no business owning.
|
|
9877
|
+
***************************************************************/
|
|
9878
|
+
function fmt_intl(date, locale, opts) {
|
|
9879
|
+
try {
|
|
9880
|
+
return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
|
|
9881
|
+
} catch (e) {
|
|
9882
|
+
return date.toDateString();
|
|
9757
9883
|
}
|
|
9758
|
-
return v;
|
|
9759
9884
|
}
|
|
9760
|
-
|
|
9761
|
-
*
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
*
|
|
9765
|
-
*
|
|
9766
|
-
|
|
9767
|
-
function
|
|
9768
|
-
if (
|
|
9769
|
-
|
|
9770
|
-
if (parent === null || parent === void 0 || typeof parent !== "object") return root;
|
|
9771
|
-
let last = segments[segments.length - 1];
|
|
9772
|
-
if (Array.isArray(parent)) parent[Number(last)] = new_value;
|
|
9773
|
-
else parent[last] = new_value;
|
|
9774
|
-
return root;
|
|
9885
|
+
/***************************
|
|
9886
|
+
* Epoch <-> clock
|
|
9887
|
+
***************************/
|
|
9888
|
+
/***************************************************************
|
|
9889
|
+
* Epoch in the producer's unit -> milliseconds, and back.
|
|
9890
|
+
* `ms` true means the value already IS milliseconds.
|
|
9891
|
+
***************************************************************/
|
|
9892
|
+
function epoch_to_ms(value, ms) {
|
|
9893
|
+
if (!value) return 0;
|
|
9894
|
+
return ms ? value : value * 1e3;
|
|
9775
9895
|
}
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
*
|
|
9780
|
-
* Collapsed (not-yet-loaded) subtrees can't be searched, so
|
|
9781
|
-
* they never match on content — only their key can match,
|
|
9782
|
-
* which the renderer checks separately.
|
|
9783
|
-
************************************************************/
|
|
9784
|
-
function subtree_matches(value, term) {
|
|
9785
|
-
if (!term) return true;
|
|
9786
|
-
if (is_collapsed(value)) return false;
|
|
9787
|
-
let type = json_type(value);
|
|
9788
|
-
if (type === "object") {
|
|
9789
|
-
for (let [k, v] of Object.entries(value)) {
|
|
9790
|
-
if (String(k).toLowerCase().includes(term)) return true;
|
|
9791
|
-
if (subtree_matches(v, term)) return true;
|
|
9792
|
-
}
|
|
9793
|
-
return false;
|
|
9794
|
-
}
|
|
9795
|
-
if (type === "array") {
|
|
9796
|
-
for (let v of value) if (subtree_matches(v, term)) return true;
|
|
9797
|
-
return false;
|
|
9798
|
-
}
|
|
9799
|
-
return String(value).toLowerCase().includes(term);
|
|
9896
|
+
function ms_to_epoch(value_ms, ms) {
|
|
9897
|
+
if (!value_ms) return 0;
|
|
9898
|
+
return ms ? value_ms : Math.floor(value_ms / 1e3);
|
|
9800
9899
|
}
|
|
9801
|
-
|
|
9802
|
-
*
|
|
9803
|
-
*
|
|
9804
|
-
*
|
|
9805
|
-
*
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
* only the long pair listed, `to_t` got its date and the
|
|
9813
|
-
* `fr_t` right above it did not, which reads as a broken
|
|
9814
|
-
* annotator rather than a missing name.
|
|
9815
|
-
************************************************************/
|
|
9816
|
-
var TIME_FIELDS = [
|
|
9817
|
-
"__t__",
|
|
9818
|
-
"__tm__",
|
|
9819
|
-
"t",
|
|
9820
|
-
"tm",
|
|
9821
|
-
"time",
|
|
9822
|
-
"from_t",
|
|
9823
|
-
"to_t",
|
|
9824
|
-
"from_tm",
|
|
9825
|
-
"to_tm",
|
|
9826
|
-
"fr_t",
|
|
9827
|
-
"fr_tm",
|
|
9828
|
-
"t_input",
|
|
9829
|
-
"t_output"
|
|
9830
|
-
];
|
|
9831
|
-
function is_time_field(field) {
|
|
9832
|
-
return TIME_FIELDS.indexOf(field) >= 0;
|
|
9900
|
+
/***************************************************************
|
|
9901
|
+
* The LOCAL wall-clock string an `<input type="datetime-local">` takes
|
|
9902
|
+
* ("YYYY-MM-DDTHH:MM:SS", which needs step=1 to keep the seconds), and
|
|
9903
|
+
* the parse back. Empty / unparseable -> 0, which is exactly how a
|
|
9904
|
+
* match condition reads an absent bound.
|
|
9905
|
+
***************************************************************/
|
|
9906
|
+
function epoch_to_local_input(value, ms) {
|
|
9907
|
+
if (!value) return "";
|
|
9908
|
+
let d = new Date(epoch_to_ms(value, ms));
|
|
9909
|
+
let pad = (n) => String(n).padStart(2, "0");
|
|
9910
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
9833
9911
|
}
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
function format_epoch(value) {
|
|
9840
|
-
if (typeof value !== "number" || !isFinite(value) || value <= 0) return null;
|
|
9841
|
-
let ms = Math.abs(value) < 0xe8d4a51000 ? value * 1e3 : value;
|
|
9842
|
-
let d = new Date(ms);
|
|
9843
|
-
if (isNaN(d.getTime())) return null;
|
|
9844
|
-
return d.toLocaleString();
|
|
9912
|
+
function local_input_to_epoch(v, ms) {
|
|
9913
|
+
if (!v) return 0;
|
|
9914
|
+
let parsed = Date.parse(v);
|
|
9915
|
+
if (Number.isNaN(parsed)) return 0;
|
|
9916
|
+
return ms_to_epoch(parsed, ms);
|
|
9845
9917
|
}
|
|
9846
|
-
|
|
9847
|
-
*
|
|
9848
|
-
*
|
|
9849
|
-
*
|
|
9850
|
-
*
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
function json_text_dump(root, max_chars) {
|
|
9855
|
-
let text;
|
|
9918
|
+
/***************************************************************
|
|
9919
|
+
* A timestamp for a table cell: the local wall clock, space-separated,
|
|
9920
|
+
* keeping the milliseconds when the producer bothered to send them (a
|
|
9921
|
+
* topic that sets sf_t_ms usually appends several records inside the
|
|
9922
|
+
* same second, and a column that hides that shows a column of ties).
|
|
9923
|
+
***************************************************************/
|
|
9924
|
+
function fmt_epoch(value, ms) {
|
|
9925
|
+
if (!value) return "";
|
|
9856
9926
|
try {
|
|
9857
|
-
|
|
9927
|
+
let s = epoch_to_local_input(value, ms).replace("T", " ");
|
|
9928
|
+
if (ms) s += `.${String(value % 1e3).padStart(3, "0")}`;
|
|
9929
|
+
return s;
|
|
9858
9930
|
} catch (e) {
|
|
9859
|
-
return
|
|
9860
|
-
text: "",
|
|
9861
|
-
capped: false,
|
|
9862
|
-
error: String(e)
|
|
9863
|
-
};
|
|
9931
|
+
return String(value);
|
|
9864
9932
|
}
|
|
9865
|
-
if (text === void 0) return {
|
|
9866
|
-
text: "",
|
|
9867
|
-
capped: false,
|
|
9868
|
-
error: "not representable as JSON"
|
|
9869
|
-
};
|
|
9870
|
-
if (typeof max_chars === "number" && max_chars > 0 && text.length > max_chars) return {
|
|
9871
|
-
text: text.slice(0, max_chars),
|
|
9872
|
-
capped: true
|
|
9873
|
-
};
|
|
9874
|
-
return {
|
|
9875
|
-
text,
|
|
9876
|
-
capped: false
|
|
9877
|
-
};
|
|
9878
9933
|
}
|
|
9879
|
-
|
|
9880
|
-
|
|
9934
|
+
var DATE_TIME_OPTIONS = {
|
|
9935
|
+
day: "numeric",
|
|
9936
|
+
month: "short",
|
|
9937
|
+
year: "numeric",
|
|
9938
|
+
hour: "2-digit",
|
|
9939
|
+
minute: "2-digit",
|
|
9940
|
+
second: "2-digit",
|
|
9941
|
+
hourCycle: "h23"
|
|
9942
|
+
};
|
|
9943
|
+
/***************************************************************
|
|
9944
|
+
* A moment as a VIEW shows it as text: the day, the month and the
|
|
9945
|
+
* year, then the clock of 24 hours with its seconds, in the APP's
|
|
9946
|
+
* language -- `locale` is the language t() answers in (the views
|
|
9947
|
+
* pass `i18next.language`), never the browser's:
|
|
9881
9948
|
*
|
|
9882
|
-
*
|
|
9883
|
-
*
|
|
9949
|
+
* fmt_date_time(d, "es") -> "14 oct 2026, 15:05:09"
|
|
9950
|
+
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
9884
9951
|
*
|
|
9885
|
-
*
|
|
9886
|
-
*
|
|
9887
|
-
* document in the view you just left is the whole point of
|
|
9888
|
-
* remembering it. `fallback` is the floor.
|
|
9952
|
+
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
9953
|
+
* gives the language-free "2026-10-14 15:05:09".
|
|
9889
9954
|
*
|
|
9890
|
-
*
|
|
9891
|
-
*
|
|
9892
|
-
*
|
|
9893
|
-
|
|
9894
|
-
function
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9955
|
+
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
9956
|
+
* the reading C_YUI_JSON writes beside a time field all come from
|
|
9957
|
+
* here, so the same moment reads the same in the three.
|
|
9958
|
+
***************************************************************/
|
|
9959
|
+
function fmt_date_time(date, locale) {
|
|
9960
|
+
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
|
9961
|
+
try {
|
|
9962
|
+
return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
|
|
9963
|
+
} catch (e) {
|
|
9964
|
+
return epoch_to_local_input(date.getTime(), true).replace("T", " ");
|
|
9965
|
+
}
|
|
9899
9966
|
}
|
|
9900
|
-
|
|
9901
|
-
*
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
*
|
|
9905
|
-
*
|
|
9906
|
-
*
|
|
9907
|
-
*
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
* document, and printing `[object Object]` beside the size
|
|
9912
|
-
* would be worse than printing nothing.
|
|
9913
|
-
*
|
|
9914
|
-
* Cut at `max_chars`, because this rides on a row whose job
|
|
9915
|
-
* is to stay one line.
|
|
9916
|
-
************************************************************/
|
|
9917
|
-
function container_label(value, max_chars) {
|
|
9918
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return "";
|
|
9919
|
-
if (!Object.prototype.hasOwnProperty.call(value, "id")) return "";
|
|
9920
|
-
let id = value.id;
|
|
9921
|
-
let t = typeof id;
|
|
9922
|
-
if (t !== "string" && t !== "number" && t !== "boolean") return "";
|
|
9923
|
-
let text = String(id).trim();
|
|
9924
|
-
if (text === "") return "";
|
|
9925
|
-
let cap = typeof max_chars === "number" && max_chars > 0 ? max_chars : 0;
|
|
9926
|
-
if (cap && text.length > cap) return text.slice(0, cap) + "…";
|
|
9927
|
-
return text;
|
|
9967
|
+
/***************************
|
|
9968
|
+
* Calendar atoms
|
|
9969
|
+
***************************/
|
|
9970
|
+
/***************************************************************
|
|
9971
|
+
* The day number of a date, counting local calendar days from
|
|
9972
|
+
* 1970-01-01. Built from the FIELDS (Date.UTC of y/m/d), never from
|
|
9973
|
+
* the timestamp: a DST day is 23 or 25 hours long, so dividing a local
|
|
9974
|
+
* epoch by 86400000 drifts a day twice a year.
|
|
9975
|
+
***************************************************************/
|
|
9976
|
+
function day_number(d) {
|
|
9977
|
+
return Math.floor(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_DAY);
|
|
9928
9978
|
}
|
|
9929
|
-
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
function is_plain_object(v) {
|
|
9933
|
-
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
9979
|
+
function date_from_day_number(n) {
|
|
9980
|
+
let d = /* @__PURE__ */ new Date(n * MS_DAY);
|
|
9981
|
+
return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
9934
9982
|
}
|
|
9935
|
-
|
|
9936
|
-
*
|
|
9937
|
-
*
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
* say, and pushed everything below it one level down.
|
|
9944
|
-
*
|
|
9945
|
-
* An EMPTY container inside counts as content: `{0}` is
|
|
9946
|
-
* something the card has to show, and there is no child card
|
|
9947
|
-
* to show it instead.
|
|
9948
|
-
************************************************************/
|
|
9949
|
-
function is_pure_collection(value) {
|
|
9950
|
-
let entries = is_plain_object(value) ? Object.entries(value) : Array.isArray(value) ? value.map((v, i) => [i, v]) : [];
|
|
9951
|
-
if (entries.length === 0) return false;
|
|
9952
|
-
for (let [, v] of entries) if (!has_branch(v)) return false;
|
|
9953
|
-
return true;
|
|
9983
|
+
/***************************************************************
|
|
9984
|
+
* The Monday of the week a date falls in (ISO: the week starts on
|
|
9985
|
+
* Monday, and Sunday closes it).
|
|
9986
|
+
***************************************************************/
|
|
9987
|
+
function start_of_iso_week(d) {
|
|
9988
|
+
let day = d.getDay();
|
|
9989
|
+
let back = day === 0 ? 6 : day - 1;
|
|
9990
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate() - back);
|
|
9954
9991
|
}
|
|
9955
|
-
|
|
9956
|
-
*
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9992
|
+
/***************************************************************
|
|
9993
|
+
* The ISO week a date belongs to: {week, year}. The YEAR is the ISO
|
|
9994
|
+
* week-year, not the calendar year — 2026-12-31 lives in week 1 of
|
|
9995
|
+
* 2027, and a label that said "week 1 2026" would name a week six
|
|
9996
|
+
* months away.
|
|
9997
|
+
***************************************************************/
|
|
9998
|
+
function iso_week(d) {
|
|
9999
|
+
let monday = start_of_iso_week(d);
|
|
10000
|
+
let thursday = new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + 3);
|
|
10001
|
+
let jan1 = new Date(thursday.getFullYear(), 0, 1);
|
|
10002
|
+
return {
|
|
10003
|
+
week: Math.floor((day_number(thursday) - day_number(jan1)) / 7) + 1,
|
|
10004
|
+
year: thursday.getFullYear()
|
|
10005
|
+
};
|
|
9960
10006
|
}
|
|
9961
|
-
|
|
9962
|
-
*
|
|
9963
|
-
*
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
for (let v of entries) if (has_branch(v)) n++;
|
|
9969
|
-
return n;
|
|
10007
|
+
/***************************************************************
|
|
10008
|
+
* The index of the ISO week a date falls in, counting weeks from the
|
|
10009
|
+
* Monday of the epoch week. It is what aligns a MULTI-week bucket (a
|
|
10010
|
+
* fortnight) to a Monday instead of to whatever day 1970-01-01 was.
|
|
10011
|
+
***************************************************************/
|
|
10012
|
+
function week_index(d) {
|
|
10013
|
+
return Math.floor((day_number(start_of_iso_week(d)) + 3) / 7);
|
|
9970
10014
|
}
|
|
9971
|
-
|
|
9972
|
-
*
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
*
|
|
9976
|
-
*
|
|
10015
|
+
/***************************
|
|
10016
|
+
* Period algebra
|
|
10017
|
+
***************************/
|
|
10018
|
+
/***************************************************************
|
|
10019
|
+
* Normalize whatever a caller hands us into a spec: an id of the
|
|
10020
|
+
* catalog, or a spec of its own. Returns null for anything that is not
|
|
10021
|
+
* a bucket (a "span" / "custom" mode of a navigator has no algebra).
|
|
10022
|
+
***************************************************************/
|
|
10023
|
+
function period_spec(period) {
|
|
10024
|
+
if (!period) return null;
|
|
10025
|
+
let spec = typeof period === "string" ? YUI_PERIODS[period] : period;
|
|
10026
|
+
if (!spec || !spec.unit) return null;
|
|
10027
|
+
if (PERIOD_UNITS.indexOf(spec.unit) < 0) return null;
|
|
10028
|
+
let count = parseInt(spec.count, 10);
|
|
10029
|
+
if (!(count > 0)) count = 1;
|
|
10030
|
+
return {
|
|
10031
|
+
id: spec.id || spec.unit,
|
|
10032
|
+
unit: spec.unit,
|
|
10033
|
+
count
|
|
10034
|
+
};
|
|
10035
|
+
}
|
|
10036
|
+
/***************************************************************
|
|
10037
|
+
* The START of the bucket that holds `anchor_ms`, as a local Date.
|
|
9977
10038
|
*
|
|
9978
|
-
*
|
|
9979
|
-
*
|
|
10039
|
+
* Alignment is what makes a bucket a bucket. Each unit floors against
|
|
10040
|
+
* the natural origin of the unit above it, so the boundaries are the
|
|
10041
|
+
* ones a human already has in their head:
|
|
9980
10042
|
*
|
|
9981
|
-
*
|
|
9982
|
-
*
|
|
9983
|
-
*
|
|
10043
|
+
* minute -> the hour (a 15min bucket starts at :00/:15/:30/:45)
|
|
10044
|
+
* hour -> local midnight (a 6h bucket starts at 00/06/12/18)
|
|
10045
|
+
* day -> 1970-01-01 (count=1 is the plain day; a 10-day
|
|
10046
|
+
* bucket has no calendar origin to
|
|
10047
|
+
* align to, so it aligns to the epoch)
|
|
10048
|
+
* week -> the epoch week, Monday-first (ISO)
|
|
10049
|
+
* month -> January (which is why 2/3/4/6/12 give calendar
|
|
10050
|
+
* bimesters, quarters and semesters)
|
|
10051
|
+
* year -> year 0 (a decade starts at 2020, not 2021)
|
|
10052
|
+
***************************************************************/
|
|
10053
|
+
function period_start(period, anchor_ms) {
|
|
10054
|
+
let spec = period_spec(period);
|
|
10055
|
+
if (!spec) return null;
|
|
10056
|
+
let d = new Date(anchor_ms);
|
|
10057
|
+
let n = spec.count;
|
|
10058
|
+
switch (spec.unit) {
|
|
10059
|
+
case "minute": {
|
|
10060
|
+
let m = Math.floor(d.getMinutes() / n) * n;
|
|
10061
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), m);
|
|
10062
|
+
}
|
|
10063
|
+
case "hour": {
|
|
10064
|
+
let h = Math.floor(d.getHours() / n) * n;
|
|
10065
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h);
|
|
10066
|
+
}
|
|
10067
|
+
case "day": return date_from_day_number(Math.floor(day_number(d) / n) * n);
|
|
10068
|
+
case "week": return date_from_day_number(Math.floor(week_index(d) / n) * n * 7 - 3);
|
|
10069
|
+
case "month": {
|
|
10070
|
+
let mi = d.getFullYear() * 12 + d.getMonth();
|
|
10071
|
+
let s = Math.floor(mi / n) * n;
|
|
10072
|
+
return new Date(Math.floor(s / 12), s % 12, 1);
|
|
10073
|
+
}
|
|
10074
|
+
case "year": {
|
|
10075
|
+
let y = Math.floor(d.getFullYear() / n) * n;
|
|
10076
|
+
return new Date(y, 0, 1);
|
|
10077
|
+
}
|
|
10078
|
+
default: return null;
|
|
10079
|
+
}
|
|
10080
|
+
}
|
|
10081
|
+
/***************************************************************
|
|
10082
|
+
* The start of the bucket `delta` buckets away (delta may be negative).
|
|
10083
|
+
* Calendar arithmetic, never millisecond arithmetic: `new Date(y, m+3, 1)`
|
|
10084
|
+
* overflows the year by itself, and stepping a day across a DST change
|
|
10085
|
+
* keeps landing on midnight.
|
|
10086
|
+
***************************************************************/
|
|
10087
|
+
function period_shift(period, anchor_ms, delta) {
|
|
10088
|
+
let spec = period_spec(period);
|
|
10089
|
+
if (!spec) return anchor_ms;
|
|
10090
|
+
let s = period_start(spec, anchor_ms);
|
|
10091
|
+
let step = spec.count * (delta || 0);
|
|
10092
|
+
switch (spec.unit) {
|
|
10093
|
+
case "minute": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours(), s.getMinutes() + step).getTime();
|
|
10094
|
+
case "hour": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours() + step).getTime();
|
|
10095
|
+
case "day": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step).getTime();
|
|
10096
|
+
case "week": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step * 7).getTime();
|
|
10097
|
+
case "month": return new Date(s.getFullYear(), s.getMonth() + step, 1).getTime();
|
|
10098
|
+
case "year": return new Date(s.getFullYear() + step, 0, 1).getTime();
|
|
10099
|
+
default: return anchor_ms;
|
|
10100
|
+
}
|
|
10101
|
+
}
|
|
10102
|
+
/***************************************************************
|
|
10103
|
+
* The bucket holding `anchor_ms`, as {from, to} in MILLISECONDS.
|
|
9984
10104
|
*
|
|
9985
|
-
*
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
10105
|
+
* `to` is INCLUSIVE — the last millisecond of the bucket, not the first
|
|
10106
|
+
* of the next one. Both ends of a match condition are inclusive, and an
|
|
10107
|
+
* exclusive end handed to one silently swallows the record that landed
|
|
10108
|
+
* exactly on the boundary.
|
|
10109
|
+
***************************************************************/
|
|
10110
|
+
function period_bounds(period, anchor_ms) {
|
|
10111
|
+
let spec = period_spec(period);
|
|
10112
|
+
if (!spec) return {
|
|
10113
|
+
from: 0,
|
|
10114
|
+
to: 0
|
|
10115
|
+
};
|
|
10116
|
+
return {
|
|
10117
|
+
from: period_start(spec, anchor_ms).getTime(),
|
|
10118
|
+
to: period_shift(spec, anchor_ms, 1) - 1
|
|
9992
10119
|
};
|
|
9993
|
-
let kind_a = kind_of(doc_a);
|
|
9994
|
-
if (kind_a === "scalar" || kind_a !== kind_of(doc_b)) {
|
|
9995
|
-
if (JSON.stringify(doc_a) === JSON.stringify(doc_b)) return [];
|
|
9996
|
-
return [{
|
|
9997
|
-
id: "",
|
|
9998
|
-
kind: "changed",
|
|
9999
|
-
from: doc_a,
|
|
10000
|
-
to: doc_b
|
|
10001
|
-
}];
|
|
10002
|
-
}
|
|
10003
|
-
let diff = (0, _yuneta_gobj_js.flat_diff)((0, _yuneta_gobj_js.json2flat)(doc_a), (0, _yuneta_gobj_js.json2flat)(doc_b));
|
|
10004
|
-
let rows = [];
|
|
10005
|
-
for (const id of Object.keys(diff.added)) rows.push({
|
|
10006
|
-
id,
|
|
10007
|
-
kind: "added",
|
|
10008
|
-
to: diff.added[id]
|
|
10009
|
-
});
|
|
10010
|
-
for (const id of Object.keys(diff.removed)) rows.push({
|
|
10011
|
-
id,
|
|
10012
|
-
kind: "removed",
|
|
10013
|
-
from: diff.removed[id]
|
|
10014
|
-
});
|
|
10015
|
-
for (const id of Object.keys(diff.changed)) rows.push({
|
|
10016
|
-
id,
|
|
10017
|
-
kind: "changed",
|
|
10018
|
-
from: diff.changed[id].from,
|
|
10019
|
-
to: diff.changed[id].to
|
|
10020
|
-
});
|
|
10021
|
-
const collator = new Intl.Collator("en", { numeric: true });
|
|
10022
|
-
rows.sort((x, y) => collator.compare(x.id, y.id));
|
|
10023
|
-
return rows;
|
|
10024
10120
|
}
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
*
|
|
10121
|
+
/***************************************************************
|
|
10122
|
+
* The same bucket, in the unit the CONSUMER speaks (a tranger topic
|
|
10123
|
+
* keeps its timestamps in seconds, unless its system_flag says
|
|
10124
|
+
* milliseconds). This is the function a query builder calls.
|
|
10125
|
+
***************************************************************/
|
|
10126
|
+
function period_bounds_epoch(period, anchor_ms, ms) {
|
|
10127
|
+
let b = period_bounds(period, anchor_ms);
|
|
10128
|
+
if (!b.from) return {
|
|
10129
|
+
from: 0,
|
|
10130
|
+
to: 0
|
|
10131
|
+
};
|
|
10132
|
+
return {
|
|
10133
|
+
from: ms_to_epoch(b.from, ms),
|
|
10134
|
+
to: ms_to_epoch(b.to, ms)
|
|
10135
|
+
};
|
|
10136
|
+
}
|
|
10137
|
+
/***************************************************************
|
|
10138
|
+
* A ROLLING window: `secs` back from now. Not a bucket — it has no
|
|
10139
|
+
* previous and no next, it just ends at `now`.
|
|
10029
10140
|
*
|
|
10030
|
-
*
|
|
10031
|
-
*
|
|
10032
|
-
*
|
|
10033
|
-
|
|
10141
|
+
* The `to` end is left OPEN (0). An iterator with no upper bound keeps
|
|
10142
|
+
* matching the records that land while the card is on screen; pinning
|
|
10143
|
+
* it to "now" would freeze the window at the instant the user clicked.
|
|
10144
|
+
***************************************************************/
|
|
10145
|
+
function rolling_bounds(rolling, ms, now_ms) {
|
|
10146
|
+
let r = typeof rolling === "string" ? YUI_ROLLING[rolling] : rolling;
|
|
10147
|
+
if (!r || !r.secs) return {
|
|
10148
|
+
from: 0,
|
|
10149
|
+
to: 0
|
|
10150
|
+
};
|
|
10151
|
+
return {
|
|
10152
|
+
from: ms_to_epoch((now_ms === void 0 ? Date.now() : now_ms) - r.secs * 1e3, ms),
|
|
10153
|
+
to: 0
|
|
10154
|
+
};
|
|
10155
|
+
}
|
|
10156
|
+
/***************************************************************
|
|
10157
|
+
* Is this the LAST bucket — the one `now` falls in? It is what greys
|
|
10158
|
+
* out the "next" arrow, and what tells the navigator it is already home.
|
|
10159
|
+
***************************************************************/
|
|
10160
|
+
function is_current_period(period, anchor_ms, now_ms) {
|
|
10161
|
+
let spec = period_spec(period);
|
|
10162
|
+
if (!spec) return false;
|
|
10163
|
+
let now = now_ms === void 0 ? Date.now() : now_ms;
|
|
10164
|
+
let a = period_start(spec, anchor_ms);
|
|
10165
|
+
let b = period_start(spec, now);
|
|
10166
|
+
return !!a && !!b && a.getTime() === b.getTime();
|
|
10167
|
+
}
|
|
10168
|
+
/***************************************************************
|
|
10169
|
+
* Recognize the bucket a {from, to} pair came from, so a range that
|
|
10170
|
+
* travelled through a URL, a saved view or a backend answer comes back
|
|
10171
|
+
* as the period the user picked instead of as a hand-typed range.
|
|
10034
10172
|
*
|
|
10035
|
-
*
|
|
10036
|
-
*
|
|
10037
|
-
*
|
|
10173
|
+
* `from`/`to` are in the CONSUMER's unit (`ms`), and so is the
|
|
10174
|
+
* comparison — that is the whole trap: a bucket ends on the last
|
|
10175
|
+
* MILLISECOND (…23:59:59.999), and a consumer that keeps seconds stored
|
|
10176
|
+
* it truncated (…23:59:59). Comparing in milliseconds, a week saved by a
|
|
10177
|
+
* seconds-based topic came back as "no bucket at all", every time.
|
|
10038
10178
|
*
|
|
10039
|
-
*
|
|
10040
|
-
*
|
|
10041
|
-
*
|
|
10042
|
-
*
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10179
|
+
* Only an EXACT match counts: both ends must land on the bucket's own
|
|
10180
|
+
* boundaries, as that consumer would have written them. `candidates` are
|
|
10181
|
+
* ids/specs, tried in order. Returns {period, anchor} (anchor in ms) or
|
|
10182
|
+
* null.
|
|
10183
|
+
***************************************************************/
|
|
10184
|
+
function infer_period(from, to, candidates, ms) {
|
|
10185
|
+
if (!from || !to || to <= from) return null;
|
|
10186
|
+
let from_ms = epoch_to_ms(from, ms);
|
|
10187
|
+
for (let candidate of candidates || Object.keys(YUI_PERIODS)) {
|
|
10188
|
+
let spec = period_spec(candidate);
|
|
10189
|
+
if (!spec) continue;
|
|
10190
|
+
let b = period_bounds_epoch(spec, from_ms, ms);
|
|
10191
|
+
if (b.from === from && b.to === to) return {
|
|
10192
|
+
period: spec,
|
|
10193
|
+
anchor: from_ms
|
|
10194
|
+
};
|
|
10195
|
+
}
|
|
10196
|
+
return null;
|
|
10197
|
+
}
|
|
10198
|
+
/***************************
|
|
10199
|
+
* Period labels
|
|
10200
|
+
***************************/
|
|
10201
|
+
/***************************************************************
|
|
10202
|
+
* The name of a GRANULARITY (what the segmented control shows):
|
|
10203
|
+
* the spec's own id as an i18n key, so an app that declares
|
|
10204
|
+
* {id: "quarter"} gets "Trimestre" the moment it adds the key.
|
|
10205
|
+
***************************************************************/
|
|
10206
|
+
function period_name(period, t) {
|
|
10207
|
+
let spec = period_spec(period);
|
|
10208
|
+
if (!spec) return tr(t, String(period && period.id || period || ""));
|
|
10209
|
+
return tr(t, spec.id);
|
|
10210
|
+
}
|
|
10211
|
+
/***************************************************************
|
|
10212
|
+
* The name of the bucket a navigator is PARKED on: what goes between
|
|
10213
|
+
* the two arrows.
|
|
10053
10214
|
*
|
|
10054
|
-
*
|
|
10055
|
-
*
|
|
10056
|
-
*
|
|
10057
|
-
*
|
|
10058
|
-
*
|
|
10059
|
-
*
|
|
10215
|
+
* day -> "Today" / "Yesterday" / "13 jul 2026"
|
|
10216
|
+
* week -> "Week 27" (+ year when it is not this one)
|
|
10217
|
+
* month -> "July" (+ year when it is not this one)
|
|
10218
|
+
* quarter -> "Q3 2026" (unit month, count 3)
|
|
10219
|
+
* semester -> "H2 2026" (unit month, count 6)
|
|
10220
|
+
* year -> "2026"
|
|
10221
|
+
* decade -> "2020 – 2029"
|
|
10222
|
+
* any other -> the bucket's own edges: "1 jul – 31 aug 2026"
|
|
10060
10223
|
*
|
|
10061
|
-
*
|
|
10062
|
-
*
|
|
10063
|
-
|
|
10224
|
+
* The named ones are named because a range reads worse than a name;
|
|
10225
|
+
* everything an app invents falls back to the range, which is always
|
|
10226
|
+
* true and never wrong.
|
|
10227
|
+
***************************************************************/
|
|
10228
|
+
function period_label(period, anchor_ms, t, locale) {
|
|
10229
|
+
let spec = period_spec(period);
|
|
10230
|
+
if (!spec) return "";
|
|
10231
|
+
let loc = safe_locale(locale);
|
|
10232
|
+
let start = period_start(spec, anchor_ms);
|
|
10233
|
+
let end = new Date(period_bounds(spec, anchor_ms).to);
|
|
10234
|
+
let now = /* @__PURE__ */ new Date();
|
|
10235
|
+
let this_year = start.getFullYear() === now.getFullYear();
|
|
10236
|
+
if (spec.unit === "day" && spec.count === 1) {
|
|
10237
|
+
let diff = day_number(start) - day_number(now);
|
|
10238
|
+
if (diff === 0) return tr(t, "today");
|
|
10239
|
+
if (diff === -1) return tr(t, "yesterday");
|
|
10240
|
+
if (diff === 1) return tr(t, "tomorrow");
|
|
10241
|
+
return fmt_intl(start, loc, this_year ? {
|
|
10242
|
+
day: "numeric",
|
|
10243
|
+
month: "short"
|
|
10244
|
+
} : {
|
|
10245
|
+
day: "numeric",
|
|
10246
|
+
month: "short",
|
|
10247
|
+
year: "numeric"
|
|
10248
|
+
});
|
|
10249
|
+
}
|
|
10250
|
+
if (spec.unit === "hour" && spec.count === 1) {
|
|
10251
|
+
let hh = fmt_intl(start, loc, {
|
|
10252
|
+
hour: "2-digit",
|
|
10253
|
+
minute: "2-digit"
|
|
10254
|
+
});
|
|
10255
|
+
if (day_number(start) === day_number(now)) return hh;
|
|
10256
|
+
return `${hh} · ${fmt_intl(start, loc, {
|
|
10257
|
+
day: "numeric",
|
|
10258
|
+
month: "short"
|
|
10259
|
+
})}`;
|
|
10260
|
+
}
|
|
10261
|
+
if (spec.unit === "week" && spec.count === 1) {
|
|
10262
|
+
let away = week_index(start) - week_index(now);
|
|
10263
|
+
if (away === 0) return tr(t, "this week");
|
|
10264
|
+
if (away === -1) return tr(t, "last week");
|
|
10265
|
+
let w = iso_week(start);
|
|
10266
|
+
return w.year === now.getFullYear() ? tr(t, "week {{n}}", { n: w.week }) : tr(t, "week {{n}} {{y}}", {
|
|
10267
|
+
n: w.week,
|
|
10268
|
+
y: w.year
|
|
10269
|
+
});
|
|
10270
|
+
}
|
|
10271
|
+
if (spec.unit === "month" && spec.count === 1) return fmt_intl(start, loc, this_year ? { month: "long" } : {
|
|
10272
|
+
month: "long",
|
|
10273
|
+
year: "numeric"
|
|
10274
|
+
});
|
|
10275
|
+
if (spec.unit === "month" && (spec.count === 3 || spec.count === 6)) {
|
|
10276
|
+
let n = Math.floor(start.getMonth() / spec.count) + 1;
|
|
10277
|
+
return tr(t, spec.count === 3 ? "quarter {{n}} {{y}}" : "semester {{n}} {{y}}", {
|
|
10278
|
+
n,
|
|
10279
|
+
y: start.getFullYear()
|
|
10280
|
+
});
|
|
10281
|
+
}
|
|
10282
|
+
if (spec.unit === "year") {
|
|
10283
|
+
if (spec.count === 1) return String(start.getFullYear());
|
|
10284
|
+
return `${start.getFullYear()} – ${end.getFullYear()}`;
|
|
10285
|
+
}
|
|
10286
|
+
let opts = spec.unit === "minute" || spec.unit === "hour" ? {
|
|
10287
|
+
day: "numeric",
|
|
10288
|
+
month: "short",
|
|
10289
|
+
hour: "2-digit",
|
|
10290
|
+
minute: "2-digit"
|
|
10291
|
+
} : {
|
|
10292
|
+
day: "numeric",
|
|
10293
|
+
month: "short"
|
|
10294
|
+
};
|
|
10295
|
+
if (start.getFullYear() !== end.getFullYear()) {
|
|
10296
|
+
let y_opts = Object.assign({ year: "numeric" }, opts);
|
|
10297
|
+
return `${fmt_intl(start, loc, y_opts)} – ${fmt_intl(end, loc, y_opts)}`;
|
|
10298
|
+
}
|
|
10299
|
+
let span = `${fmt_intl(start, loc, opts)} – ${fmt_intl(end, loc, opts)}`;
|
|
10300
|
+
return this_year ? span : `${span} ${start.getFullYear()}`;
|
|
10301
|
+
}
|
|
10064
10302
|
/************************************************************
|
|
10065
|
-
*
|
|
10066
|
-
* WITH seconds: the input is built with `step: 1`, which is what
|
|
10067
|
-
* lets it hold them. Written as "YYYY-MM-DDTHH:mm" it lost them on
|
|
10068
|
-
* every save of any field.
|
|
10303
|
+
* JSON type discriminator (viewer vocabulary)
|
|
10069
10304
|
************************************************************/
|
|
10070
|
-
function
|
|
10071
|
-
if (
|
|
10072
|
-
|
|
10073
|
-
|
|
10305
|
+
function json_type(value) {
|
|
10306
|
+
if (value === null) return "null";
|
|
10307
|
+
if (Array.isArray(value)) return "array";
|
|
10308
|
+
switch (typeof value) {
|
|
10309
|
+
case "string": return "string";
|
|
10310
|
+
case "number": return "number";
|
|
10311
|
+
case "boolean": return "boolean";
|
|
10312
|
+
case "object": return "object";
|
|
10313
|
+
default: return "unknown";
|
|
10314
|
+
}
|
|
10074
10315
|
}
|
|
10075
10316
|
/************************************************************
|
|
10076
|
-
*
|
|
10317
|
+
* Detect a kw_collapse() sentinel.
|
|
10318
|
+
*
|
|
10319
|
+
* The kernel replaces an over-limit dict with:
|
|
10320
|
+
* { "__collapsed__": { "path": ..., "size": N } }
|
|
10321
|
+
* and an over-limit array with:
|
|
10322
|
+
* [ { "__collapsed__": { "path": ..., "size": N } } ]
|
|
10323
|
+
*
|
|
10324
|
+
* Returns { size, path, is_array } or null.
|
|
10077
10325
|
************************************************************/
|
|
10078
|
-
function
|
|
10079
|
-
if (!value)
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10326
|
+
function is_collapsed(value) {
|
|
10327
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
10328
|
+
let keys = Object.keys(value);
|
|
10329
|
+
if (keys.length === 1 && keys[0] === "__collapsed__") {
|
|
10330
|
+
let c = value.__collapsed__ || {};
|
|
10331
|
+
return {
|
|
10332
|
+
size: c.size,
|
|
10333
|
+
path: c.path,
|
|
10334
|
+
is_array: false
|
|
10335
|
+
};
|
|
10336
|
+
}
|
|
10337
|
+
return null;
|
|
10338
|
+
}
|
|
10339
|
+
if (Array.isArray(value) && value.length === 1) {
|
|
10340
|
+
let e = value[0];
|
|
10341
|
+
if (e && typeof e === "object" && !Array.isArray(e) && Object.keys(e).length === 1 && e.__collapsed__) {
|
|
10342
|
+
let c = e.__collapsed__ || {};
|
|
10343
|
+
return {
|
|
10344
|
+
size: c.size,
|
|
10345
|
+
path: c.path,
|
|
10346
|
+
is_array: true
|
|
10347
|
+
};
|
|
10348
|
+
}
|
|
10349
|
+
}
|
|
10350
|
+
return null;
|
|
10083
10351
|
}
|
|
10084
10352
|
/************************************************************
|
|
10085
|
-
*
|
|
10086
|
-
* none. A `string` column holds an ISO text, any other an epoch
|
|
10087
|
-
* in SECONDS. The form's time field and the cell editor of a
|
|
10088
|
-
* table read it here, so the two agree: up to gobj-ui 7.26.46 the
|
|
10089
|
-
* field read every column with parseInt -- an ISO text as the
|
|
10090
|
-
* year 2026 in SECONDS, in January 1970 -- and showed an empty
|
|
10091
|
-
* one as January 1970 too, which a save then wrote back as 0.
|
|
10353
|
+
* Join / split absolute path segments (kernel convention)
|
|
10092
10354
|
************************************************************/
|
|
10093
|
-
function
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10355
|
+
function seg_join(segments) {
|
|
10356
|
+
return segments.map(function(s) {
|
|
10357
|
+
return String(s);
|
|
10358
|
+
}).join("`");
|
|
10359
|
+
}
|
|
10360
|
+
function seg_split(path) {
|
|
10361
|
+
if (path === "" || path === null || path === void 0) return [];
|
|
10362
|
+
return path.split("`");
|
|
10097
10363
|
}
|
|
10098
10364
|
/************************************************************
|
|
10099
|
-
*
|
|
10100
|
-
*
|
|
10101
|
-
* other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
|
|
10102
|
-
* `string` column too.
|
|
10365
|
+
* Walk a JSON tree by absolute segments; undefined if the
|
|
10366
|
+
* path does not resolve.
|
|
10103
10367
|
************************************************************/
|
|
10104
|
-
function
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10368
|
+
function get_by_segments(root, segments) {
|
|
10369
|
+
let v = root;
|
|
10370
|
+
for (let seg of segments) {
|
|
10371
|
+
if (v === null || v === void 0) return;
|
|
10372
|
+
if (Array.isArray(v)) v = v[Number(seg)];
|
|
10373
|
+
else if (typeof v === "object") v = v[seg];
|
|
10374
|
+
else return;
|
|
10375
|
+
}
|
|
10376
|
+
return v;
|
|
10109
10377
|
}
|
|
10110
10378
|
/************************************************************
|
|
10111
|
-
*
|
|
10112
|
-
*
|
|
10113
|
-
*
|
|
10114
|
-
*
|
|
10115
|
-
*
|
|
10379
|
+
* Set a value at absolute segments (mutates root).
|
|
10380
|
+
*
|
|
10381
|
+
* segments == [] means "replace the whole root" — the caller
|
|
10382
|
+
* must use the RETURNED value in that case (a primitive/array
|
|
10383
|
+
* root cannot be mutated in place).
|
|
10116
10384
|
************************************************************/
|
|
10117
|
-
function
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10385
|
+
function set_by_segments(root, segments, new_value) {
|
|
10386
|
+
if (segments.length === 0) return new_value;
|
|
10387
|
+
let parent = get_by_segments(root, segments.slice(0, -1));
|
|
10388
|
+
if (parent === null || parent === void 0 || typeof parent !== "object") return root;
|
|
10389
|
+
let last = segments[segments.length - 1];
|
|
10390
|
+
if (Array.isArray(parent)) parent[Number(last)] = new_value;
|
|
10391
|
+
else parent[last] = new_value;
|
|
10392
|
+
return root;
|
|
10121
10393
|
}
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
*
|
|
10126
|
-
*
|
|
10127
|
-
*
|
|
10394
|
+
/************************************************************
|
|
10395
|
+
* Does `value` (or any loaded descendant / its own key)
|
|
10396
|
+
* contain the lower-cased search term?
|
|
10397
|
+
*
|
|
10398
|
+
* Collapsed (not-yet-loaded) subtrees can't be searched, so
|
|
10399
|
+
* they never match on content — only their key can match,
|
|
10400
|
+
* which the renderer checks separately.
|
|
10401
|
+
************************************************************/
|
|
10402
|
+
function subtree_matches(value, term) {
|
|
10403
|
+
if (!term) return true;
|
|
10404
|
+
if (is_collapsed(value)) return false;
|
|
10405
|
+
let type = json_type(value);
|
|
10406
|
+
if (type === "object") {
|
|
10407
|
+
for (let [k, v] of Object.entries(value)) {
|
|
10408
|
+
if (String(k).toLowerCase().includes(term)) return true;
|
|
10409
|
+
if (subtree_matches(v, term)) return true;
|
|
10410
|
+
}
|
|
10411
|
+
return false;
|
|
10412
|
+
}
|
|
10413
|
+
if (type === "array") {
|
|
10414
|
+
for (let v of value) if (subtree_matches(v, term)) return true;
|
|
10415
|
+
return false;
|
|
10416
|
+
}
|
|
10417
|
+
return String(value).toLowerCase().includes(term);
|
|
10418
|
+
}
|
|
10419
|
+
/************************************************************
|
|
10420
|
+
* Fields whose numeric value is an epoch timestamp.
|
|
10421
|
+
*
|
|
10422
|
+
* THE ONE LIST. C_YUI_FORM's jsoneditor takes its
|
|
10423
|
+
* `timestampTag` from here: it used to carry its own copy,
|
|
10424
|
+
* and a copy is how the two stopped agreeing.
|
|
10425
|
+
*
|
|
10426
|
+
* TWO SPELLINGS, AND LAS DOS SON DEL BACKEND. timeranger2
|
|
10427
|
+
* writes `from_t`/`from_tm` in the match_cond of a query and
|
|
10428
|
+
* `fr_t`/`fr_tm` in the metadata of a topic and of a file --
|
|
10429
|
+
* which is what a Raw JSON of a treedb actually shows. With
|
|
10430
|
+
* only the long pair listed, `to_t` got its date and the
|
|
10431
|
+
* `fr_t` right above it did not, which reads as a broken
|
|
10432
|
+
* annotator rather than a missing name.
|
|
10433
|
+
************************************************************/
|
|
10434
|
+
var TIME_FIELDS = [
|
|
10435
|
+
"__t__",
|
|
10436
|
+
"__tm__",
|
|
10437
|
+
"t",
|
|
10438
|
+
"tm",
|
|
10439
|
+
"time",
|
|
10440
|
+
"from_t",
|
|
10441
|
+
"to_t",
|
|
10442
|
+
"from_tm",
|
|
10443
|
+
"to_tm",
|
|
10444
|
+
"fr_t",
|
|
10445
|
+
"fr_tm",
|
|
10446
|
+
"t_input",
|
|
10447
|
+
"t_output"
|
|
10448
|
+
];
|
|
10449
|
+
function is_time_field(field) {
|
|
10450
|
+
return TIME_FIELDS.indexOf(field) >= 0;
|
|
10451
|
+
}
|
|
10452
|
+
/************************************************************
|
|
10453
|
+
* Format an epoch value as a local wall-clock string, 24
|
|
10454
|
+
* hours, in the APP's language `locale` (fmt_date_time() of
|
|
10455
|
+
* yui_time.js, as the time cells of the forms and tables;
|
|
10456
|
+
* up to gobj-ui 7.26.51 it was toLocaleString(): the
|
|
10457
|
+
* browser's language, and 12 hours in English).
|
|
10458
|
+
* Accepts seconds or milliseconds; returns null when the
|
|
10459
|
+
* value is not a usable positive timestamp (0 == "unset").
|
|
10460
|
+
************************************************************/
|
|
10461
|
+
function format_epoch(value, locale) {
|
|
10462
|
+
if (typeof value !== "number" || !isFinite(value) || value <= 0) return null;
|
|
10463
|
+
let ms = Math.abs(value) < 0xe8d4a51000 ? value * 1e3 : value;
|
|
10464
|
+
let d = new Date(ms);
|
|
10465
|
+
if (isNaN(d.getTime())) return null;
|
|
10466
|
+
return fmt_date_time(d, locale);
|
|
10467
|
+
}
|
|
10468
|
+
/************************************************************
|
|
10469
|
+
* The text view's payload: the document as text, indented
|
|
10470
|
+
* four characters, cut at `max_chars`.
|
|
10471
|
+
*
|
|
10472
|
+
* Returns {text, capped}. `capped` is what the caller
|
|
10473
|
+
* announces under the dump — a cut that is not announced
|
|
10474
|
+
* reads as a document that ends there.
|
|
10475
|
+
************************************************************/
|
|
10476
|
+
function json_text_dump(root, max_chars) {
|
|
10477
|
+
let text;
|
|
10478
|
+
try {
|
|
10479
|
+
text = JSON.stringify(root, null, 4);
|
|
10480
|
+
} catch (e) {
|
|
10481
|
+
return {
|
|
10482
|
+
text: "",
|
|
10483
|
+
capped: false,
|
|
10484
|
+
error: String(e)
|
|
10485
|
+
};
|
|
10486
|
+
}
|
|
10487
|
+
if (text === void 0) return {
|
|
10488
|
+
text: "",
|
|
10489
|
+
capped: false,
|
|
10490
|
+
error: "not representable as JSON"
|
|
10491
|
+
};
|
|
10492
|
+
if (typeof max_chars === "number" && max_chars > 0 && text.length > max_chars) return {
|
|
10493
|
+
text: text.slice(0, max_chars),
|
|
10494
|
+
capped: true
|
|
10495
|
+
};
|
|
10496
|
+
return {
|
|
10497
|
+
text,
|
|
10498
|
+
capped: false
|
|
10499
|
+
};
|
|
10500
|
+
}
|
|
10501
|
+
/************************************************************
|
|
10502
|
+
* Which view a freshly mounted viewer opens on.
|
|
10503
|
+
*
|
|
10504
|
+
* Three answers, in order of authority: what the HOST asked
|
|
10505
|
+
* for, what the READER chose last time, and `fallback`.
|
|
10506
|
+
*
|
|
10507
|
+
* The host wins because a viewer mounted to show a graph has
|
|
10508
|
+
* to show one. The memory comes next, because reopening a
|
|
10509
|
+
* document in the view you just left is the whole point of
|
|
10510
|
+
* remembering it. `fallback` is the floor.
|
|
10511
|
+
*
|
|
10512
|
+
* Anything not in `modes` is treated as unsaid, which covers
|
|
10513
|
+
* an absent value, an empty one, and a stored string from an
|
|
10514
|
+
* older release that named a view no longer offered.
|
|
10515
|
+
************************************************************/
|
|
10516
|
+
function pick_view_mode(asked, remembered, modes, fallback) {
|
|
10517
|
+
let known = (m) => Array.isArray(modes) && modes.indexOf(m) >= 0;
|
|
10518
|
+
if (known(asked)) return asked;
|
|
10519
|
+
if (known(remembered)) return remembered;
|
|
10520
|
+
return fallback;
|
|
10521
|
+
}
|
|
10522
|
+
/************************************************************
|
|
10523
|
+
* The short label a container row carries beside its size.
|
|
10524
|
+
*
|
|
10525
|
+
* An array of dicts that carry an `id` is a list of RECORDS,
|
|
10526
|
+
* and a row that says only `2: {15}` makes you open all
|
|
10527
|
+
* fifteen fields of every one of them to find out WHICH
|
|
10528
|
+
* record it is. The id is the one field that answers that,
|
|
10529
|
+
* so the row says it without being opened.
|
|
10530
|
+
*
|
|
10531
|
+
* Only a SCALAR id, and only when it is really there: an `id`
|
|
10532
|
+
* that is itself a dict or a list is not a name, it is more
|
|
10533
|
+
* document, and printing `[object Object]` beside the size
|
|
10534
|
+
* would be worse than printing nothing.
|
|
10535
|
+
*
|
|
10536
|
+
* Cut at `max_chars`, because this rides on a row whose job
|
|
10537
|
+
* is to stay one line.
|
|
10538
|
+
************************************************************/
|
|
10539
|
+
function container_label(value, max_chars) {
|
|
10540
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return "";
|
|
10541
|
+
if (!Object.prototype.hasOwnProperty.call(value, "id")) return "";
|
|
10542
|
+
let id = value.id;
|
|
10543
|
+
let t = typeof id;
|
|
10544
|
+
if (t !== "string" && t !== "number" && t !== "boolean") return "";
|
|
10545
|
+
let text = String(id).trim();
|
|
10546
|
+
if (text === "") return "";
|
|
10547
|
+
let cap = typeof max_chars === "number" && max_chars > 0 ? max_chars : 0;
|
|
10548
|
+
if (cap && text.length > cap) return text.slice(0, cap) + "…";
|
|
10549
|
+
return text;
|
|
10550
|
+
}
|
|
10551
|
+
/************************************************************
|
|
10552
|
+
* A dict, in the JSON sense: not an array and not null.
|
|
10553
|
+
************************************************************/
|
|
10554
|
+
function is_plain_object(v) {
|
|
10555
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
10556
|
+
}
|
|
10557
|
+
/************************************************************
|
|
10558
|
+
* Does this container hold ONLY other containers?
|
|
10559
|
+
*
|
|
10560
|
+
* Such a value is not a thing, it is a LIST of things -- and a
|
|
10561
|
+
* list is fully described by the row that names it in its
|
|
10562
|
+
* parent, plus the edges to what it holds. Drawing it as a
|
|
10563
|
+
* card of its own put a node in the middle of the graph with no
|
|
10564
|
+
* data in it, saying nothing the parent's row did not already
|
|
10565
|
+
* say, and pushed everything below it one level down.
|
|
10566
|
+
*
|
|
10567
|
+
* An EMPTY container inside counts as content: `{0}` is
|
|
10568
|
+
* something the card has to show, and there is no child card
|
|
10569
|
+
* to show it instead.
|
|
10570
|
+
************************************************************/
|
|
10571
|
+
function is_pure_collection(value) {
|
|
10572
|
+
let entries = is_plain_object(value) ? Object.entries(value) : Array.isArray(value) ? value.map((v, i) => [i, v]) : [];
|
|
10573
|
+
if (entries.length === 0) return false;
|
|
10574
|
+
for (let [, v] of entries) if (!has_branch(v)) return false;
|
|
10575
|
+
return true;
|
|
10576
|
+
}
|
|
10577
|
+
/************************************************************
|
|
10578
|
+
* A value that gets a card, or children, of its own.
|
|
10579
|
+
************************************************************/
|
|
10580
|
+
function has_branch(value) {
|
|
10581
|
+
return is_plain_object(value) && Object.keys(value).length > 0 || Array.isArray(value) && value.length > 0;
|
|
10582
|
+
}
|
|
10583
|
+
/************************************************************
|
|
10584
|
+
* How many branches a container has, which is what the fold
|
|
10585
|
+
* chip counts.
|
|
10586
|
+
************************************************************/
|
|
10587
|
+
function count_branches(value) {
|
|
10588
|
+
let entries = is_plain_object(value) ? Object.values(value) : Array.isArray(value) ? value : [];
|
|
10589
|
+
let n = 0;
|
|
10590
|
+
for (let v of entries) if (has_branch(v)) n++;
|
|
10591
|
+
return n;
|
|
10592
|
+
}
|
|
10593
|
+
/************************************************************
|
|
10594
|
+
* What differs between two documents: one row per id of
|
|
10595
|
+
* their flat form (json2flat), sorted by id in natural order,
|
|
10596
|
+
* so `[2]` comes before `[10]`:
|
|
10597
|
+
*
|
|
10598
|
+
* [{id, kind: "added"|"removed"|"changed", from?, to?}]
|
|
10599
|
+
*
|
|
10600
|
+
* `from` is the first document's value and `to` the second's:
|
|
10601
|
+
* an added row has no `from`, a removed row no `to`.
|
|
10602
|
+
*
|
|
10603
|
+
* Two roots that are not containers of the same kind have no
|
|
10604
|
+
* ids in common to compare by: they are one value each, and
|
|
10605
|
+
* the row that says they differ has the empty id.
|
|
10606
|
+
*
|
|
10607
|
+
* Throws what json2flat throws (a document too deep).
|
|
10608
|
+
************************************************************/
|
|
10609
|
+
function json_diff_rows(doc_a, doc_b) {
|
|
10610
|
+
const kind_of = (v) => {
|
|
10611
|
+
if (Array.isArray(v)) return "array";
|
|
10612
|
+
if (v !== null && typeof v === "object") return "object";
|
|
10613
|
+
return "scalar";
|
|
10614
|
+
};
|
|
10615
|
+
let kind_a = kind_of(doc_a);
|
|
10616
|
+
if (kind_a === "scalar" || kind_a !== kind_of(doc_b)) {
|
|
10617
|
+
if (JSON.stringify(doc_a) === JSON.stringify(doc_b)) return [];
|
|
10618
|
+
return [{
|
|
10619
|
+
id: "",
|
|
10620
|
+
kind: "changed",
|
|
10621
|
+
from: doc_a,
|
|
10622
|
+
to: doc_b
|
|
10623
|
+
}];
|
|
10624
|
+
}
|
|
10625
|
+
let diff = (0, _yuneta_gobj_js.flat_diff)((0, _yuneta_gobj_js.json2flat)(doc_a), (0, _yuneta_gobj_js.json2flat)(doc_b));
|
|
10626
|
+
let rows = [];
|
|
10627
|
+
for (const id of Object.keys(diff.added)) rows.push({
|
|
10628
|
+
id,
|
|
10629
|
+
kind: "added",
|
|
10630
|
+
to: diff.added[id]
|
|
10631
|
+
});
|
|
10632
|
+
for (const id of Object.keys(diff.removed)) rows.push({
|
|
10633
|
+
id,
|
|
10634
|
+
kind: "removed",
|
|
10635
|
+
from: diff.removed[id]
|
|
10636
|
+
});
|
|
10637
|
+
for (const id of Object.keys(diff.changed)) rows.push({
|
|
10638
|
+
id,
|
|
10639
|
+
kind: "changed",
|
|
10640
|
+
from: diff.changed[id].from,
|
|
10641
|
+
to: diff.changed[id].to
|
|
10642
|
+
});
|
|
10643
|
+
const collator = new Intl.Collator("en", { numeric: true });
|
|
10644
|
+
rows.sort((x, y) => collator.compare(x.id, y.id));
|
|
10645
|
+
return rows;
|
|
10646
|
+
}
|
|
10647
|
+
//#endregion
|
|
10648
|
+
//#region src/form_time_value.js
|
|
10649
|
+
/****************************************************************************
|
|
10650
|
+
* form_time_value.js
|
|
10651
|
+
*
|
|
10652
|
+
* A treedb `time` / `now` column is an epoch in SECONDS, and a form
|
|
10653
|
+
* shows it in a `datetime-local` input. These two convert between
|
|
10654
|
+
* them, and they must be each other's inverse: a writable time
|
|
10655
|
+
* column travels back on EVERY save of the record.
|
|
10656
|
+
*
|
|
10657
|
+
* KNOWN LIMIT -- the change of hour. A `datetime-local` holds a
|
|
10658
|
+
* LOCAL WALL time and no offset, and a wall time is not always
|
|
10659
|
+
* one instant:
|
|
10660
|
+
*
|
|
10661
|
+
* - the night the clocks go back (autumn), one hour happens
|
|
10662
|
+
* twice. "02:30" names two instants an hour apart, and
|
|
10663
|
+
* `new Date("YYYY-MM-DDT02:30:00")` answers the EARLIER one
|
|
10664
|
+
* (ECMAScript's "compatible" disambiguation). An epoch in the
|
|
10665
|
+
* SECOND pass of that hour is shown as 02:30 and comes back
|
|
10666
|
+
* one hour earlier. So neither the form's field nor the cell
|
|
10667
|
+
* editor reads a box that still shows what it was filled
|
|
10668
|
+
* with: they give back the value it was filled from (up to
|
|
10669
|
+
* gobj-ui 7.26.48 the cell, and 7.26.50 the field, wrote
|
|
10670
|
+
* -3600 s on a save of any field of the record).
|
|
10671
|
+
* - the night the clocks go forward (spring), one hour does not
|
|
10672
|
+
* exist. No epoch is shown in it, so nothing read comes back
|
|
10673
|
+
* wrong; a wall time TYPED in it is moved forward by the
|
|
10674
|
+
* browser.
|
|
10675
|
+
*
|
|
10676
|
+
* Not fixable here without the offset, which the input cannot
|
|
10677
|
+
* carry. What is safe: a read-only time column never goes back
|
|
10678
|
+
* (treedb_write_plan.js, col_goes_back_to_treedb), and a time
|
|
10679
|
+
* pkey2 goes back as the record had it, never through this
|
|
10680
|
+
* widget (instance_keys_of). A wall time TYPED inside the
|
|
10681
|
+
* repeated hour is the exposed case: it is the first pass.
|
|
10682
|
+
*
|
|
10683
|
+
* Copyright (c) 2026, ArtGins.
|
|
10684
|
+
* All Rights Reserved.
|
|
10685
|
+
****************************************************************************/
|
|
10686
|
+
/************************************************************
|
|
10687
|
+
* A Date -> the value of a `datetime-local` input, in local time,
|
|
10688
|
+
* WITH seconds: the input is built with `step: 1`, which is what
|
|
10689
|
+
* lets it hold them. Written as "YYYY-MM-DDTHH:mm" it lost them on
|
|
10690
|
+
* every save of any field.
|
|
10691
|
+
************************************************************/
|
|
10692
|
+
function date_to_datetime_local(value) {
|
|
10693
|
+
if (!(value instanceof Date) || isNaN(value.getTime())) return "";
|
|
10694
|
+
let pad = (n) => String(n).padStart(2, "0");
|
|
10695
|
+
return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}T${pad(value.getHours())}:${pad(value.getMinutes())}:${pad(value.getSeconds())}`;
|
|
10696
|
+
}
|
|
10697
|
+
/************************************************************
|
|
10698
|
+
* The value of a `datetime-local` input -> epoch in seconds
|
|
10699
|
+
************************************************************/
|
|
10700
|
+
function datetime_local_to_epoch(value) {
|
|
10701
|
+
if (!value) return null;
|
|
10702
|
+
const date = new Date(value);
|
|
10703
|
+
if (isNaN(date.getTime())) return null;
|
|
10704
|
+
return Math.floor(date.getTime() / 1e3);
|
|
10705
|
+
}
|
|
10706
|
+
/************************************************************
|
|
10707
|
+
* The value of a time column -> a Date, or null when it holds
|
|
10708
|
+
* none. A `string` column holds an ISO text, any other an epoch
|
|
10709
|
+
* in SECONDS. The form's time field and the cell editor of a
|
|
10710
|
+
* table read it here, so the two agree: up to gobj-ui 7.26.46 the
|
|
10711
|
+
* field read every column with parseInt -- an ISO text as the
|
|
10712
|
+
* year 2026 in SECONDS, in January 1970 -- and showed an empty
|
|
10713
|
+
* one as January 1970 too, which a save then wrote back as 0.
|
|
10714
|
+
************************************************************/
|
|
10715
|
+
function time_value_to_date(value, real_type) {
|
|
10716
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
10717
|
+
let date = real_type === "string" ? new Date(String(value)) : /* @__PURE__ */ new Date(Number(value) * 1e3);
|
|
10718
|
+
return isNaN(date.getTime()) ? null : date;
|
|
10719
|
+
}
|
|
10720
|
+
/************************************************************
|
|
10721
|
+
* An epoch in seconds (null: no time) -> the value of a time
|
|
10722
|
+
* column: an ISO text for a `string` column, the epoch for any
|
|
10723
|
+
* other. Up to gobj-ui 7.26.46 the field wrote the epoch into a
|
|
10724
|
+
* `string` column too.
|
|
10725
|
+
************************************************************/
|
|
10726
|
+
function epoch_to_time_value(epoch, real_type) {
|
|
10727
|
+
if (epoch === null || epoch === void 0) return null;
|
|
10728
|
+
if (typeof epoch !== "number" || !Number.isFinite(epoch)) return epoch;
|
|
10729
|
+
if (real_type === "string") return (/* @__PURE__ */ new Date(epoch * 1e3)).toISOString();
|
|
10730
|
+
return epoch;
|
|
10731
|
+
}
|
|
10732
|
+
/************************************************************
|
|
10733
|
+
* The value of a time column as a table cell shows it: the
|
|
10734
|
+
* local clock, 24 hours, in the APP's language `locale`
|
|
10735
|
+
* (fmt_date_time() of yui_time.js: es "14 oct 2026, 15:05:09").
|
|
10736
|
+
* Up to gobj-ui 7.26.51 the form wrote "2026-10-14 15:05:09" and
|
|
10737
|
+
* the treedb table "14 oct 2026, 03:05:09 p. m.", in the
|
|
10738
|
+
* browser's language. "" for no time; a value that is not one is
|
|
10739
|
+
* shown as it is, so the reader sees what the column holds.
|
|
10740
|
+
************************************************************/
|
|
10741
|
+
function time_value_to_text(value, real_type, locale) {
|
|
10742
|
+
let date = time_value_to_date(value, real_type);
|
|
10743
|
+
if (!date) return value === null || value === void 0 ? "" : String(value);
|
|
10744
|
+
return fmt_date_time(date, locale);
|
|
10745
|
+
}
|
|
10746
|
+
//#endregion
|
|
10747
|
+
//#region src/form_time_cell_editor.js
|
|
10748
|
+
/****************************************************************************
|
|
10749
|
+
* form_time_cell_editor.js
|
|
10750
|
+
*
|
|
10751
|
+
* The cell editor of a `time` / `now` column in a table of
|
|
10128
10752
|
* C_YUI_FORM: a `datetime-local` box, as the form's own time
|
|
10129
10753
|
* field, converting with the same helpers (form_time_value.js)
|
|
10130
10754
|
* -- an epoch in SECONDS for an integer column, an ISO text
|
|
@@ -12622,6 +13246,36 @@ function table_column_titles(template) {
|
|
|
12622
13246
|
});
|
|
12623
13247
|
return titles;
|
|
12624
13248
|
}
|
|
13249
|
+
var TIME_CELL_FORMATTERS = /* @__PURE__ */ new WeakSet();
|
|
13250
|
+
/******************************************************************
|
|
13251
|
+
* The formatter of a time cell: the local clock, 24 hours, in the
|
|
13252
|
+
* APP's language (fmt_date_time of yui_time.js, as the cells of
|
|
13253
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM): es "14 oct 2026, 15:05:09".
|
|
13254
|
+
******************************************************************/
|
|
13255
|
+
function time_cell_formatter(real_type) {
|
|
13256
|
+
let formatter = function(cell) {
|
|
13257
|
+
return text_node(time_value_to_text(cell.getValue(), real_type, safe_locale(i18next.default.language)));
|
|
13258
|
+
};
|
|
13259
|
+
TIME_CELL_FORMATTERS.add(formatter);
|
|
13260
|
+
return formatter;
|
|
13261
|
+
}
|
|
13262
|
+
/******************************************************************
|
|
13263
|
+
* Draw the time cells of a table again, in the current language.
|
|
13264
|
+
* Cell by cell, never a redraw of the rows: a row's formatter
|
|
13265
|
+
* builds its nested tables anew -- empty. A cell being edited is
|
|
13266
|
+
* its editor's; Tabulator formats it again when the editor closes.
|
|
13267
|
+
******************************************************************/
|
|
13268
|
+
function reformat_time_cells(tabulator) {
|
|
13269
|
+
for (let column of tabulator.getColumns()) {
|
|
13270
|
+
let formatter = column.getDefinition().formatter;
|
|
13271
|
+
if (!TIME_CELL_FORMATTERS.has(formatter)) continue;
|
|
13272
|
+
for (let cell of column.getCells()) {
|
|
13273
|
+
let $cell = cell.getElement();
|
|
13274
|
+
if ($cell.classList.contains("tabulator-editing")) continue;
|
|
13275
|
+
$cell.replaceChildren(formatter(cell));
|
|
13276
|
+
}
|
|
13277
|
+
}
|
|
13278
|
+
}
|
|
12625
13279
|
/******************************************************************
|
|
12626
13280
|
* Convert a template's items in tabulator columns
|
|
12627
13281
|
******************************************************************/
|
|
@@ -12734,9 +13388,7 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
12734
13388
|
case "time":
|
|
12735
13389
|
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
12736
13390
|
column.editorParams = { verticalNavigation: "table" };
|
|
12737
|
-
column.formatter =
|
|
12738
|
-
return text_node(time_value_to_text(cell.getValue(), field_desc.real_type));
|
|
12739
|
-
};
|
|
13391
|
+
column.formatter = time_cell_formatter(field_desc.real_type);
|
|
12740
13392
|
break;
|
|
12741
13393
|
case "color":
|
|
12742
13394
|
column.editor = "input";
|
|
@@ -13717,7 +14369,7 @@ function ac_name_json_editors(gobj, event, kw, src) {
|
|
|
13717
14369
|
* in the old language until it draws it again, so each is told to
|
|
13718
14370
|
* (a new onRenderMenu), and the render names it again.
|
|
13719
14371
|
************************************************************/
|
|
13720
|
-
function ac_language_changed$
|
|
14372
|
+
function ac_language_changed$11(gobj, event, kw, src) {
|
|
13721
14373
|
let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
|
|
13722
14374
|
if (!$container) return 0;
|
|
13723
14375
|
for (let $editor of $container.querySelectorAll(".jsoneditor")) {
|
|
@@ -13726,7 +14378,10 @@ function ac_language_changed$10(gobj, event, kw, src) {
|
|
|
13726
14378
|
}
|
|
13727
14379
|
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
|
|
13728
14380
|
let tabulator = $table.tabulator;
|
|
13729
|
-
if (tabulator && tabulator.initialized && $table.template)
|
|
14381
|
+
if (tabulator && tabulator.initialized && $table.template) {
|
|
14382
|
+
yui_tabulator_relocalize(tabulator, i18next.t, table_column_titles($table.template));
|
|
14383
|
+
reformat_time_cells(tabulator);
|
|
14384
|
+
}
|
|
13730
14385
|
}
|
|
13731
14386
|
return 0;
|
|
13732
14387
|
}
|
|
@@ -13903,7 +14558,7 @@ function create_gclass$17(gclass_name) {
|
|
|
13903
14558
|
],
|
|
13904
14559
|
[
|
|
13905
14560
|
"EV_LANGUAGE_CHANGED",
|
|
13906
|
-
ac_language_changed$
|
|
14561
|
+
ac_language_changed$11,
|
|
13907
14562
|
null
|
|
13908
14563
|
]
|
|
13909
14564
|
]]];
|
|
@@ -14299,7 +14954,7 @@ function mt_create$16(gobj) {
|
|
|
14299
14954
|
* rewritten in place, and the map's locale with them so a
|
|
14300
14955
|
* control or a popup built later is right too.
|
|
14301
14956
|
***************************************************************/
|
|
14302
|
-
function ac_language_changed$
|
|
14957
|
+
function ac_language_changed$10(gobj, event, kw, src) {
|
|
14303
14958
|
let priv = gobj.priv;
|
|
14304
14959
|
if (priv.xmap) yui_maplibre_relocalize(priv.xmap, i18next.t);
|
|
14305
14960
|
return 0;
|
|
@@ -14867,7 +15522,7 @@ function create_gclass$16(gclass_name) {
|
|
|
14867
15522
|
], [["ST_IDLE", [
|
|
14868
15523
|
[
|
|
14869
15524
|
"EV_LANGUAGE_CHANGED",
|
|
14870
|
-
ac_language_changed$
|
|
15525
|
+
ac_language_changed$10,
|
|
14871
15526
|
null
|
|
14872
15527
|
],
|
|
14873
15528
|
[
|
|
@@ -15016,12 +15671,145 @@ function yui_uplot_axes(axes) {
|
|
|
15016
15671
|
});
|
|
15017
15672
|
}
|
|
15018
15673
|
//#endregion
|
|
15674
|
+
//#region src/yui_uplot_time.js
|
|
15675
|
+
/***********************************************************************
|
|
15676
|
+
* yui_uplot_time.js
|
|
15677
|
+
*
|
|
15678
|
+
* The texts uPlot writes for a moment -- the ticks of a time axis
|
|
15679
|
+
* and the reading of the legend -- in the APP's language, with a
|
|
15680
|
+
* clock of 24 hours, as every other time a gobj-ui view shows
|
|
15681
|
+
* (fmt_date_time of yui_time.js).
|
|
15682
|
+
*
|
|
15683
|
+
* uPlot writes them from templates of its own, in English and
|
|
15684
|
+
* 12 hours: "3pm", "3:05pm", "10/14" (month first), "Oct", and
|
|
15685
|
+
* "2026-10-14 3:05pm" in the legend. Its `fmtDate` option takes
|
|
15686
|
+
* the template and returns the function that writes a Date with
|
|
15687
|
+
* it; this one is given to it:
|
|
15688
|
+
*
|
|
15689
|
+
* legend "{YYYY}-{MM}-{DD} {h}:{mm}{aa}" -> fmt_date_time()
|
|
15690
|
+
* "14 oct 2026, 15:05:09"
|
|
15691
|
+
* "{h}{aa}" "3pm" -> "15:00"
|
|
15692
|
+
* "{h}:{mm}{aa}" "3:05pm" -> "15:05"
|
|
15693
|
+
* "{M}/{D}" "10/14" -> es "14/10", en "10/14"
|
|
15694
|
+
* "{M}/{D}/{YY}" "10/14/26"-> es "14/10/26", en "10/14/26"
|
|
15695
|
+
* "{MMM}" "Oct" -> es "oct", en "Oct"
|
|
15696
|
+
*
|
|
15697
|
+
* The language is asked for on every call, so a redraw after a
|
|
15698
|
+
* language change writes the new one (C_YUI_UPLOT redraws its
|
|
15699
|
+
* axes on EV_LANGUAGE_CHANGED).
|
|
15700
|
+
*
|
|
15701
|
+
* Copyright (c) 2026, ArtGins.
|
|
15702
|
+
* All Rights Reserved.
|
|
15703
|
+
***********************************************************************/
|
|
15704
|
+
var LEGEND_STAMP = "{YYYY}-{MM}-{DD} {h}:{mm}{aa}";
|
|
15705
|
+
var pad2 = (n) => String(n).padStart(2, "0");
|
|
15706
|
+
var __formatters__ = /* @__PURE__ */ new Map();
|
|
15707
|
+
function intl(locale, opts) {
|
|
15708
|
+
let key = locale + "|" + JSON.stringify(opts);
|
|
15709
|
+
let f = __formatters__.get(key);
|
|
15710
|
+
if (!f) {
|
|
15711
|
+
try {
|
|
15712
|
+
f = new Intl.DateTimeFormat(locale, opts);
|
|
15713
|
+
} catch (e) {
|
|
15714
|
+
f = new Intl.DateTimeFormat("en", opts);
|
|
15715
|
+
}
|
|
15716
|
+
__formatters__.set(key, f);
|
|
15717
|
+
}
|
|
15718
|
+
return f;
|
|
15719
|
+
}
|
|
15720
|
+
var WHOLE = [
|
|
15721
|
+
["{M}/{D}/{YY}", (d, loc) => intl(loc, {
|
|
15722
|
+
day: "numeric",
|
|
15723
|
+
month: "numeric",
|
|
15724
|
+
year: "2-digit"
|
|
15725
|
+
}).format(d)],
|
|
15726
|
+
["{M}/{D}", (d, loc) => intl(loc, {
|
|
15727
|
+
day: "numeric",
|
|
15728
|
+
month: "numeric"
|
|
15729
|
+
}).format(d)],
|
|
15730
|
+
["{h}{aa}", (d) => `${pad2(d.getHours())}:00`]
|
|
15731
|
+
];
|
|
15732
|
+
var TOKENS = {
|
|
15733
|
+
YYYY: (d) => String(d.getFullYear()),
|
|
15734
|
+
YY: (d) => String(d.getFullYear()).slice(2),
|
|
15735
|
+
MMMM: (d, loc) => intl(loc, { month: "long" }).format(d),
|
|
15736
|
+
MMM: (d, loc) => intl(loc, { month: "short" }).format(d),
|
|
15737
|
+
MM: (d) => pad2(d.getMonth() + 1),
|
|
15738
|
+
M: (d) => String(d.getMonth() + 1),
|
|
15739
|
+
DD: (d) => pad2(d.getDate()),
|
|
15740
|
+
D: (d) => String(d.getDate()),
|
|
15741
|
+
WWWW: (d, loc) => intl(loc, { weekday: "long" }).format(d),
|
|
15742
|
+
WWW: (d, loc) => intl(loc, { weekday: "short" }).format(d),
|
|
15743
|
+
HH: (d) => pad2(d.getHours()),
|
|
15744
|
+
H: (d) => String(d.getHours()),
|
|
15745
|
+
hh: (d) => pad2(d.getHours()),
|
|
15746
|
+
h: (d) => pad2(d.getHours()),
|
|
15747
|
+
AA: () => "",
|
|
15748
|
+
aa: () => "",
|
|
15749
|
+
a: () => "",
|
|
15750
|
+
mm: (d) => pad2(d.getMinutes()),
|
|
15751
|
+
m: (d) => String(d.getMinutes()),
|
|
15752
|
+
ss: (d) => pad2(d.getSeconds()),
|
|
15753
|
+
s: (d) => String(d.getSeconds()),
|
|
15754
|
+
fff: (d) => String(d.getMilliseconds()).padStart(3, "0")
|
|
15755
|
+
};
|
|
15756
|
+
/***************************************************************
|
|
15757
|
+
* A template -> its parts: literal text, or a function of
|
|
15758
|
+
* (date, locale).
|
|
15759
|
+
***************************************************************/
|
|
15760
|
+
function template_parts(tpl) {
|
|
15761
|
+
let parts = [];
|
|
15762
|
+
let rest = String(tpl);
|
|
15763
|
+
while (rest.length > 0) {
|
|
15764
|
+
let whole = WHOLE.find(([frag]) => rest.startsWith(frag));
|
|
15765
|
+
if (whole) {
|
|
15766
|
+
parts.push(whole[1]);
|
|
15767
|
+
rest = rest.slice(whole[0].length);
|
|
15768
|
+
continue;
|
|
15769
|
+
}
|
|
15770
|
+
let m = /^\{([a-z]+)\}/i.exec(rest);
|
|
15771
|
+
if (m && TOKENS[m[1]]) {
|
|
15772
|
+
parts.push(TOKENS[m[1]]);
|
|
15773
|
+
rest = rest.slice(m[0].length);
|
|
15774
|
+
continue;
|
|
15775
|
+
}
|
|
15776
|
+
let next = rest.indexOf("{", 1);
|
|
15777
|
+
let text = next < 0 ? rest : rest.slice(0, next);
|
|
15778
|
+
parts.push(text);
|
|
15779
|
+
rest = rest.slice(text.length);
|
|
15780
|
+
}
|
|
15781
|
+
return parts;
|
|
15782
|
+
}
|
|
15783
|
+
/***************************************************************
|
|
15784
|
+
* uPlot's `fmtDate` option. `get_locale` answers the app's
|
|
15785
|
+
* language at the moment of the call (the views pass
|
|
15786
|
+
* `() => i18next.language`).
|
|
15787
|
+
***************************************************************/
|
|
15788
|
+
function yui_uplot_fmt_date(get_locale) {
|
|
15789
|
+
let locale = () => safe_locale(typeof get_locale === "function" ? get_locale() : null);
|
|
15790
|
+
return function(tpl) {
|
|
15791
|
+
if (tpl === LEGEND_STAMP) return (date) => fmt_date_time(date, locale());
|
|
15792
|
+
let parts = template_parts(tpl);
|
|
15793
|
+
return function(date) {
|
|
15794
|
+
let loc = locale();
|
|
15795
|
+
let out = "";
|
|
15796
|
+
for (let part of parts) out += typeof part === "string" ? part : part(date, loc);
|
|
15797
|
+
return out;
|
|
15798
|
+
};
|
|
15799
|
+
};
|
|
15800
|
+
}
|
|
15801
|
+
//#endregion
|
|
15019
15802
|
//#region src/c_yui_uplot.js
|
|
15020
15803
|
/***********************************************************************
|
|
15021
15804
|
* c_yui_uplot.js
|
|
15022
15805
|
*
|
|
15023
15806
|
* Graphics, Charts with uPlot
|
|
15024
15807
|
*
|
|
15808
|
+
* A moment uPlot writes -- a tick of a time axis, the reading of
|
|
15809
|
+
* the legend -- is in the app's language with a clock of 24 hours
|
|
15810
|
+
* (yui_uplot_time.js), and is written again on the shell's
|
|
15811
|
+
* EV_LANGUAGE_CHANGED.
|
|
15812
|
+
*
|
|
15025
15813
|
* Copyright (c) 2025-2026, ArtGins.
|
|
15026
15814
|
* All Rights Reserved.
|
|
15027
15815
|
***********************************************************************/
|
|
@@ -15050,7 +15838,10 @@ var attrs_table$15 = [
|
|
|
15050
15838
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_INTEGER, "timeout_idle", 0, 5, "Idle timeout (seconds)"),
|
|
15051
15839
|
(0, _yuneta_gobj_js.SDATA_END)()
|
|
15052
15840
|
];
|
|
15053
|
-
var PRIVATE_DATA$15 = {
|
|
15841
|
+
var PRIVATE_DATA$15 = {
|
|
15842
|
+
theme_observer: null,
|
|
15843
|
+
lang_shell: null
|
|
15844
|
+
};
|
|
15054
15845
|
var __gclass__$15 = null;
|
|
15055
15846
|
/******************************
|
|
15056
15847
|
* Framework Methods
|
|
@@ -15068,11 +15859,22 @@ function mt_create$15(gobj) {
|
|
|
15068
15859
|
/***************************************************************
|
|
15069
15860
|
* Framework Method: Start
|
|
15070
15861
|
***************************************************************/
|
|
15071
|
-
function mt_start$15(gobj) {
|
|
15862
|
+
function mt_start$15(gobj) {
|
|
15863
|
+
let priv = gobj.priv;
|
|
15864
|
+
let shell = yui_shell_of(gobj);
|
|
15865
|
+
if (shell) {
|
|
15866
|
+
(0, _yuneta_gobj_js.gobj_subscribe_event)(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
15867
|
+
priv.lang_shell = shell;
|
|
15868
|
+
}
|
|
15869
|
+
}
|
|
15072
15870
|
/***************************************************************
|
|
15073
15871
|
* Framework Method: Stop
|
|
15074
15872
|
***************************************************************/
|
|
15075
|
-
function mt_stop$15(gobj) {
|
|
15873
|
+
function mt_stop$15(gobj) {
|
|
15874
|
+
let priv = gobj.priv;
|
|
15875
|
+
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);
|
|
15876
|
+
priv.lang_shell = null;
|
|
15877
|
+
}
|
|
15076
15878
|
/***************************************************************
|
|
15077
15879
|
* Framework Method: Destroy
|
|
15078
15880
|
***************************************************************/
|
|
@@ -15110,7 +15912,8 @@ function build_ui$14(gobj) {
|
|
|
15110
15912
|
height: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "height"),
|
|
15111
15913
|
series: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "series"),
|
|
15112
15914
|
axes: yui_uplot_axes((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "axes")),
|
|
15113
|
-
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales")
|
|
15915
|
+
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales"),
|
|
15916
|
+
fmtDate: yui_uplot_fmt_date(() => i18next.default.language)
|
|
15114
15917
|
};
|
|
15115
15918
|
let uplot$2 = new uplot.default(uPlot_options, (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "data"), $container);
|
|
15116
15919
|
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "uplot", uplot$2);
|
|
@@ -15232,17 +16035,33 @@ function ac_theme$4(gobj, event, kw, src) {
|
|
|
15232
16035
|
return 0;
|
|
15233
16036
|
}
|
|
15234
16037
|
/******************************************************
|
|
16038
|
+
* The language changed: the ticks of a time axis and the
|
|
16039
|
+
* reading of the legend ask for it when they are written,
|
|
16040
|
+
* so they are written again.
|
|
16041
|
+
******************************************************/
|
|
16042
|
+
function ac_language_changed$9(gobj, event, kw, src) {
|
|
16043
|
+
let uplot$6 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
16044
|
+
if (!uplot$6) return 0;
|
|
16045
|
+
try {
|
|
16046
|
+
uplot$6.redraw(true, true);
|
|
16047
|
+
uplot$6.setLegend(null, false);
|
|
16048
|
+
} catch (e) {
|
|
16049
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot redraw the chart: ${e}`);
|
|
16050
|
+
}
|
|
16051
|
+
return 0;
|
|
16052
|
+
}
|
|
16053
|
+
/******************************************************
|
|
15235
16054
|
*
|
|
15236
16055
|
******************************************************/
|
|
15237
16056
|
function ac_del_serie(gobj, event, kw, src) {
|
|
15238
|
-
let uplot$
|
|
15239
|
-
for (let idx = 1; idx < uplot$
|
|
15240
|
-
let serie = uplot$
|
|
16057
|
+
let uplot$7 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
16058
|
+
for (let idx = 1; idx < uplot$7.series.length; idx++) {
|
|
16059
|
+
let serie = uplot$7.series[idx];
|
|
15241
16060
|
if (serie.id && serie.id === kw.id) {
|
|
15242
|
-
uplot$
|
|
15243
|
-
let data = uplot$
|
|
16061
|
+
uplot$7.delSeries(idx);
|
|
16062
|
+
let data = uplot$7.data.splice(idx, 1);
|
|
15244
16063
|
if (data.length === 1) data = [[]];
|
|
15245
|
-
uplot$
|
|
16064
|
+
uplot$7.setData(data);
|
|
15246
16065
|
return 0;
|
|
15247
16066
|
}
|
|
15248
16067
|
}
|
|
@@ -15252,9 +16071,9 @@ function ac_del_serie(gobj, event, kw, src) {
|
|
|
15252
16071
|
*
|
|
15253
16072
|
******************************************************/
|
|
15254
16073
|
function ac_clear$1(gobj, event, kw, src) {
|
|
15255
|
-
let uplot$
|
|
15256
|
-
uplot$
|
|
15257
|
-
for (let idx = uplot$
|
|
16074
|
+
let uplot$8 = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
16075
|
+
uplot$8.setData([[]]);
|
|
16076
|
+
for (let idx = uplot$8.series.length - 1; idx > 0; idx--) uplot$8.delSeries(idx);
|
|
15258
16077
|
return 0;
|
|
15259
16078
|
}
|
|
15260
16079
|
/***************************
|
|
@@ -15279,7 +16098,8 @@ function create_gclass$15(gclass_name) {
|
|
|
15279
16098
|
["EV_ADD_SERIE", 0],
|
|
15280
16099
|
["EV_DEL_SERIE", 0],
|
|
15281
16100
|
["EV_CLEAR", 0],
|
|
15282
|
-
["EV_THEME", 0]
|
|
16101
|
+
["EV_THEME", 0],
|
|
16102
|
+
["EV_LANGUAGE_CHANGED", 0]
|
|
15283
16103
|
], [["ST_IDLE", [
|
|
15284
16104
|
[
|
|
15285
16105
|
"EV_LOAD_DATA",
|
|
@@ -15305,6 +16125,11 @@ function create_gclass$15(gclass_name) {
|
|
|
15305
16125
|
"EV_THEME",
|
|
15306
16126
|
ac_theme$4,
|
|
15307
16127
|
null
|
|
16128
|
+
],
|
|
16129
|
+
[
|
|
16130
|
+
"EV_LANGUAGE_CHANGED",
|
|
16131
|
+
ac_language_changed$9,
|
|
16132
|
+
null
|
|
15308
16133
|
]
|
|
15309
16134
|
]]], gmt$15, 0, attrs_table$15, PRIVATE_DATA$15, 0, 0, 0, 0);
|
|
15310
16135
|
if (!__gclass__$15) return -1;
|
|
@@ -18371,7 +19196,8 @@ var PRIVATE_DATA$13 = {
|
|
|
18371
19196
|
$search_ctl: null,
|
|
18372
19197
|
$expand_btn: null,
|
|
18373
19198
|
$collapse_btn: null,
|
|
18374
|
-
$mode_btns: null
|
|
19199
|
+
$mode_btns: null,
|
|
19200
|
+
lang_shell: null
|
|
18375
19201
|
};
|
|
18376
19202
|
var __gclass__$13 = null;
|
|
18377
19203
|
/******************************
|
|
@@ -18399,13 +19225,22 @@ function mt_create$13(gobj) {
|
|
|
18399
19225
|
* Framework Method: Start
|
|
18400
19226
|
***************************************************************/
|
|
18401
19227
|
function mt_start$13(gobj) {
|
|
18402
|
-
|
|
19228
|
+
let priv = gobj.priv;
|
|
19229
|
+
if (priv.root !== null) (0, _yuneta_gobj_js.gobj_change_state)(gobj, "ST_READY");
|
|
19230
|
+
let shell = yui_shell_of(gobj);
|
|
19231
|
+
if (shell) {
|
|
19232
|
+
(0, _yuneta_gobj_js.gobj_subscribe_event)(shell, "EV_LANGUAGE_CHANGED", {}, gobj);
|
|
19233
|
+
priv.lang_shell = shell;
|
|
19234
|
+
}
|
|
18403
19235
|
render_view$1(gobj);
|
|
18404
19236
|
}
|
|
18405
19237
|
/***************************************************************
|
|
18406
19238
|
* Framework Method: Stop
|
|
18407
19239
|
***************************************************************/
|
|
18408
19240
|
function mt_stop$13(gobj) {
|
|
19241
|
+
let priv = gobj.priv;
|
|
19242
|
+
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);
|
|
19243
|
+
priv.lang_shell = null;
|
|
18409
19244
|
teardown_graph_child$1(gobj);
|
|
18410
19245
|
}
|
|
18411
19246
|
/***************************************************************
|
|
@@ -19104,7 +19939,7 @@ function leaf_row(key, value, depth) {
|
|
|
19104
19939
|
text_node(text)
|
|
19105
19940
|
]);
|
|
19106
19941
|
if (key !== null && is_time_field(String(key))) {
|
|
19107
|
-
let wall = format_epoch(value);
|
|
19942
|
+
let wall = format_epoch(value, safe_locale(i18next.default.language));
|
|
19108
19943
|
if (wall) body.push([
|
|
19109
19944
|
"span",
|
|
19110
19945
|
{ class: "JSON_TIME is-size-7 yui-text-quiet ml-2" },
|
|
@@ -19355,6 +20190,12 @@ function ac_json_item_clicked(gobj, event, kw, src) {
|
|
|
19355
20190
|
}
|
|
19356
20191
|
/************************************************************
|
|
19357
20192
|
* EV_LANGUAGE_CHANGED — re-translate chrome + re-render
|
|
20193
|
+
*
|
|
20194
|
+
* Only the TREE is drawn again: it writes the reading of a
|
|
20195
|
+
* time field in the language of the moment it was drawn. The
|
|
20196
|
+
* text view carries its keys (refresh_language reaches them),
|
|
20197
|
+
* and loading the graph again would throw away the reader's
|
|
20198
|
+
* camera for nothing.
|
|
19358
20199
|
************************************************************/
|
|
19359
20200
|
function ac_language_changed$8(gobj, event, kw, src) {
|
|
19360
20201
|
let priv = gobj.priv;
|
|
@@ -19364,7 +20205,7 @@ function ac_language_changed$8(gobj, event, kw, src) {
|
|
|
19364
20205
|
if (priv.$search) priv.$search.setAttribute("placeholder", (0, i18next.t)("search"));
|
|
19365
20206
|
apply_view_mode$1(gobj);
|
|
19366
20207
|
}
|
|
19367
|
-
|
|
20208
|
+
if (current_view_mode$1(gobj) === "tree") render_tree(gobj);
|
|
19368
20209
|
return 0;
|
|
19369
20210
|
}
|
|
19370
20211
|
/************************************************************
|
|
@@ -33045,26 +33886,11 @@ function transform__treedb_value_2_table_value(gobj, col, value, row, field) {
|
|
|
33045
33886
|
switch (field_desc.real_type) {
|
|
33046
33887
|
case "string":
|
|
33047
33888
|
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)([
|
|
33889
|
+
value = time_value_to_text(value, field_desc.real_type, safe_locale(i18next.default.language));
|
|
33890
|
+
if (value) value = (0, _yuneta_gobj_js.createElement2)([
|
|
33065
33891
|
"span",
|
|
33066
33892
|
{ class: "is-size-7" },
|
|
33067
|
-
|
|
33893
|
+
text_node(value)
|
|
33068
33894
|
]);
|
|
33069
33895
|
}
|
|
33070
33896
|
break;
|
|
@@ -82719,591 +83545,6 @@ function register_c_yui_schema_editor() {
|
|
|
82719
83545
|
return create_gclass$1(GCLASS_NAME$1);
|
|
82720
83546
|
}
|
|
82721
83547
|
//#endregion
|
|
82722
|
-
//#region src/yui_time.js
|
|
82723
|
-
/***********************************************************************
|
|
82724
|
-
* yui_time.js
|
|
82725
|
-
*
|
|
82726
|
-
* Time, without a DOM: epochs, and the algebra of PERIODS.
|
|
82727
|
-
*
|
|
82728
|
-
* Two things live here, and they are the two halves of every date
|
|
82729
|
-
* UI the projects keep rewriting:
|
|
82730
|
-
*
|
|
82731
|
-
* 1) EPOCH <-> the local wall clock. A timestamp travels in the
|
|
82732
|
-
* producer's own unit — seconds, or milliseconds when a topic
|
|
82733
|
-
* says so — and every conversion crosses that `ms` flag. Getting
|
|
82734
|
-
* it wrong puts the same instant on two different clocks in one
|
|
82735
|
-
* screen (it did: a picker asking "from 18:55" local returned
|
|
82736
|
-
* rows a table labelled 16:55).
|
|
82737
|
-
*
|
|
82738
|
-
* 2) The PERIOD. A period is not an enum of five names: it is a
|
|
82739
|
-
* BUCKET, and a bucket is `count` of a `unit`:
|
|
82740
|
-
*
|
|
82741
|
-
* {id: "day", unit: "day", count: 1}
|
|
82742
|
-
* {id: "week", unit: "week", count: 1} ISO, Mon-first
|
|
82743
|
-
* {id: "bimester", unit: "month", count: 2}
|
|
82744
|
-
* {id: "quarter", unit: "month", count: 3}
|
|
82745
|
-
* {id: "semester", unit: "month", count: 6}
|
|
82746
|
-
* {id: "decade", unit: "year", count: 10}
|
|
82747
|
-
* {id: "15min", unit: "minute", count: 15}
|
|
82748
|
-
*
|
|
82749
|
-
* Given that pair, ONE implementation answers every question a
|
|
82750
|
-
* date navigator asks — where does the bucket holding this
|
|
82751
|
-
* instant start and end, what is the previous/next one, what do
|
|
82752
|
-
* I call it — so an app that wants quarters declares a quarter
|
|
82753
|
-
* instead of asking for a new component.
|
|
82754
|
-
*
|
|
82755
|
-
* Buckets are ALIGNED, never "count back from now": months align to
|
|
82756
|
-
* the year (which is why 2, 3, 4, 6 and 12 fall on clean calendar
|
|
82757
|
-
* boundaries), weeks to Monday, hours to local midnight. "Last 7
|
|
82758
|
-
* days" is a different animal — a rolling window — and it is not a
|
|
82759
|
-
* period: see `rolling_bounds()`.
|
|
82760
|
-
*
|
|
82761
|
-
* Everything here is LOCAL time (the user reads a local clock) and
|
|
82762
|
-
* DST-safe: it never adds 86400000 ms to cross a day, it builds the
|
|
82763
|
-
* next date from calendar fields and lets the platform do it.
|
|
82764
|
-
*
|
|
82765
|
-
* Copyright (c) 2026, ArtGins.
|
|
82766
|
-
* All Rights Reserved.
|
|
82767
|
-
***********************************************************************/
|
|
82768
|
-
/***************************************************************
|
|
82769
|
-
* Constants
|
|
82770
|
-
***************************************************************/
|
|
82771
|
-
var MS_DAY = 864e5;
|
|
82772
|
-
var PERIOD_UNITS = [
|
|
82773
|
-
"minute",
|
|
82774
|
-
"hour",
|
|
82775
|
-
"day",
|
|
82776
|
-
"week",
|
|
82777
|
-
"month",
|
|
82778
|
-
"year"
|
|
82779
|
-
];
|
|
82780
|
-
var YUI_PERIODS = {
|
|
82781
|
-
minute: {
|
|
82782
|
-
id: "minute",
|
|
82783
|
-
unit: "minute",
|
|
82784
|
-
count: 1
|
|
82785
|
-
},
|
|
82786
|
-
"5min": {
|
|
82787
|
-
id: "5min",
|
|
82788
|
-
unit: "minute",
|
|
82789
|
-
count: 5
|
|
82790
|
-
},
|
|
82791
|
-
"15min": {
|
|
82792
|
-
id: "15min",
|
|
82793
|
-
unit: "minute",
|
|
82794
|
-
count: 15
|
|
82795
|
-
},
|
|
82796
|
-
hour: {
|
|
82797
|
-
id: "hour",
|
|
82798
|
-
unit: "hour",
|
|
82799
|
-
count: 1
|
|
82800
|
-
},
|
|
82801
|
-
day: {
|
|
82802
|
-
id: "day",
|
|
82803
|
-
unit: "day",
|
|
82804
|
-
count: 1
|
|
82805
|
-
},
|
|
82806
|
-
week: {
|
|
82807
|
-
id: "week",
|
|
82808
|
-
unit: "week",
|
|
82809
|
-
count: 1
|
|
82810
|
-
},
|
|
82811
|
-
fortnight: {
|
|
82812
|
-
id: "fortnight",
|
|
82813
|
-
unit: "week",
|
|
82814
|
-
count: 2
|
|
82815
|
-
},
|
|
82816
|
-
month: {
|
|
82817
|
-
id: "month",
|
|
82818
|
-
unit: "month",
|
|
82819
|
-
count: 1
|
|
82820
|
-
},
|
|
82821
|
-
bimester: {
|
|
82822
|
-
id: "bimester",
|
|
82823
|
-
unit: "month",
|
|
82824
|
-
count: 2
|
|
82825
|
-
},
|
|
82826
|
-
quarter: {
|
|
82827
|
-
id: "quarter",
|
|
82828
|
-
unit: "month",
|
|
82829
|
-
count: 3
|
|
82830
|
-
},
|
|
82831
|
-
semester: {
|
|
82832
|
-
id: "semester",
|
|
82833
|
-
unit: "month",
|
|
82834
|
-
count: 6
|
|
82835
|
-
},
|
|
82836
|
-
year: {
|
|
82837
|
-
id: "year",
|
|
82838
|
-
unit: "year",
|
|
82839
|
-
count: 1
|
|
82840
|
-
},
|
|
82841
|
-
decade: {
|
|
82842
|
-
id: "decade",
|
|
82843
|
-
unit: "year",
|
|
82844
|
-
count: 10
|
|
82845
|
-
}
|
|
82846
|
-
};
|
|
82847
|
-
var YUI_PERIODS_DEFAULT = [
|
|
82848
|
-
"hour",
|
|
82849
|
-
"day",
|
|
82850
|
-
"week",
|
|
82851
|
-
"month",
|
|
82852
|
-
"year"
|
|
82853
|
-
];
|
|
82854
|
-
var YUI_ROLLING = {
|
|
82855
|
-
"1h": {
|
|
82856
|
-
id: "1h",
|
|
82857
|
-
secs: 3600,
|
|
82858
|
-
label: "last hour"
|
|
82859
|
-
},
|
|
82860
|
-
"6h": {
|
|
82861
|
-
id: "6h",
|
|
82862
|
-
secs: 21600,
|
|
82863
|
-
label: "last 6h"
|
|
82864
|
-
},
|
|
82865
|
-
"24h": {
|
|
82866
|
-
id: "24h",
|
|
82867
|
-
secs: 86400,
|
|
82868
|
-
label: "last 24h"
|
|
82869
|
-
},
|
|
82870
|
-
"7d": {
|
|
82871
|
-
id: "7d",
|
|
82872
|
-
secs: 604800,
|
|
82873
|
-
label: "last 7 days"
|
|
82874
|
-
},
|
|
82875
|
-
"30d": {
|
|
82876
|
-
id: "30d",
|
|
82877
|
-
secs: 2592e3,
|
|
82878
|
-
label: "last 30 days"
|
|
82879
|
-
}
|
|
82880
|
-
};
|
|
82881
|
-
/***************************
|
|
82882
|
-
* Locale / i18n
|
|
82883
|
-
***************************/
|
|
82884
|
-
/***************************************************************
|
|
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
|
-
* Translate through the APP's translator when it gave us one, and
|
|
82901
|
-
* degrade to the key itself otherwise — interpolating `{{x}}` by hand,
|
|
82902
|
-
* so a label never renders raw mustaches at a caller that has no i18n.
|
|
82903
|
-
***************************************************************/
|
|
82904
|
-
function tr(t, key, params) {
|
|
82905
|
-
if (typeof t === "function") return t(key, params);
|
|
82906
|
-
let s = key;
|
|
82907
|
-
for (let k in params || {}) s = s.replaceAll(`{{${k}}}`, String(params[k]));
|
|
82908
|
-
return s;
|
|
82909
|
-
}
|
|
82910
|
-
/***************************************************************
|
|
82911
|
-
* Intl formatters, built PER CALL (see safe_locale). They are cheap
|
|
82912
|
-
* next to a repaint, and caching them would need a locale-change hook
|
|
82913
|
-
* the library has no business owning.
|
|
82914
|
-
***************************************************************/
|
|
82915
|
-
function fmt_intl(date, locale, opts) {
|
|
82916
|
-
try {
|
|
82917
|
-
return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
|
|
82918
|
-
} catch (e) {
|
|
82919
|
-
return date.toDateString();
|
|
82920
|
-
}
|
|
82921
|
-
}
|
|
82922
|
-
/***************************
|
|
82923
|
-
* Epoch <-> clock
|
|
82924
|
-
***************************/
|
|
82925
|
-
/***************************************************************
|
|
82926
|
-
* Epoch in the producer's unit -> milliseconds, and back.
|
|
82927
|
-
* `ms` true means the value already IS milliseconds.
|
|
82928
|
-
***************************************************************/
|
|
82929
|
-
function epoch_to_ms(value, ms) {
|
|
82930
|
-
if (!value) return 0;
|
|
82931
|
-
return ms ? value : value * 1e3;
|
|
82932
|
-
}
|
|
82933
|
-
function ms_to_epoch(value_ms, ms) {
|
|
82934
|
-
if (!value_ms) return 0;
|
|
82935
|
-
return ms ? value_ms : Math.floor(value_ms / 1e3);
|
|
82936
|
-
}
|
|
82937
|
-
/***************************************************************
|
|
82938
|
-
* The LOCAL wall-clock string an `<input type="datetime-local">` takes
|
|
82939
|
-
* ("YYYY-MM-DDTHH:MM:SS", which needs step=1 to keep the seconds), and
|
|
82940
|
-
* the parse back. Empty / unparseable -> 0, which is exactly how a
|
|
82941
|
-
* match condition reads an absent bound.
|
|
82942
|
-
***************************************************************/
|
|
82943
|
-
function epoch_to_local_input(value, ms) {
|
|
82944
|
-
if (!value) return "";
|
|
82945
|
-
let d = new Date(epoch_to_ms(value, ms));
|
|
82946
|
-
let pad = (n) => String(n).padStart(2, "0");
|
|
82947
|
-
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
|
82948
|
-
}
|
|
82949
|
-
function local_input_to_epoch(v, ms) {
|
|
82950
|
-
if (!v) return 0;
|
|
82951
|
-
let parsed = Date.parse(v);
|
|
82952
|
-
if (Number.isNaN(parsed)) return 0;
|
|
82953
|
-
return ms_to_epoch(parsed, ms);
|
|
82954
|
-
}
|
|
82955
|
-
/***************************************************************
|
|
82956
|
-
* A timestamp for a table cell: the local wall clock, space-separated,
|
|
82957
|
-
* keeping the milliseconds when the producer bothered to send them (a
|
|
82958
|
-
* topic that sets sf_t_ms usually appends several records inside the
|
|
82959
|
-
* same second, and a column that hides that shows a column of ties).
|
|
82960
|
-
***************************************************************/
|
|
82961
|
-
function fmt_epoch(value, ms) {
|
|
82962
|
-
if (!value) return "";
|
|
82963
|
-
try {
|
|
82964
|
-
let s = epoch_to_local_input(value, ms).replace("T", " ");
|
|
82965
|
-
if (ms) s += `.${String(value % 1e3).padStart(3, "0")}`;
|
|
82966
|
-
return s;
|
|
82967
|
-
} catch (e) {
|
|
82968
|
-
return String(value);
|
|
82969
|
-
}
|
|
82970
|
-
}
|
|
82971
|
-
/***************************
|
|
82972
|
-
* Calendar atoms
|
|
82973
|
-
***************************/
|
|
82974
|
-
/***************************************************************
|
|
82975
|
-
* The day number of a date, counting local calendar days from
|
|
82976
|
-
* 1970-01-01. Built from the FIELDS (Date.UTC of y/m/d), never from
|
|
82977
|
-
* the timestamp: a DST day is 23 or 25 hours long, so dividing a local
|
|
82978
|
-
* epoch by 86400000 drifts a day twice a year.
|
|
82979
|
-
***************************************************************/
|
|
82980
|
-
function day_number(d) {
|
|
82981
|
-
return Math.floor(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()) / MS_DAY);
|
|
82982
|
-
}
|
|
82983
|
-
function date_from_day_number(n) {
|
|
82984
|
-
let d = /* @__PURE__ */ new Date(n * MS_DAY);
|
|
82985
|
-
return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
|
|
82986
|
-
}
|
|
82987
|
-
/***************************************************************
|
|
82988
|
-
* The Monday of the week a date falls in (ISO: the week starts on
|
|
82989
|
-
* Monday, and Sunday closes it).
|
|
82990
|
-
***************************************************************/
|
|
82991
|
-
function start_of_iso_week(d) {
|
|
82992
|
-
let day = d.getDay();
|
|
82993
|
-
let back = day === 0 ? 6 : day - 1;
|
|
82994
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate() - back);
|
|
82995
|
-
}
|
|
82996
|
-
/***************************************************************
|
|
82997
|
-
* The ISO week a date belongs to: {week, year}. The YEAR is the ISO
|
|
82998
|
-
* week-year, not the calendar year — 2026-12-31 lives in week 1 of
|
|
82999
|
-
* 2027, and a label that said "week 1 2026" would name a week six
|
|
83000
|
-
* months away.
|
|
83001
|
-
***************************************************************/
|
|
83002
|
-
function iso_week(d) {
|
|
83003
|
-
let monday = start_of_iso_week(d);
|
|
83004
|
-
let thursday = new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + 3);
|
|
83005
|
-
let jan1 = new Date(thursday.getFullYear(), 0, 1);
|
|
83006
|
-
return {
|
|
83007
|
-
week: Math.floor((day_number(thursday) - day_number(jan1)) / 7) + 1,
|
|
83008
|
-
year: thursday.getFullYear()
|
|
83009
|
-
};
|
|
83010
|
-
}
|
|
83011
|
-
/***************************************************************
|
|
83012
|
-
* The index of the ISO week a date falls in, counting weeks from the
|
|
83013
|
-
* Monday of the epoch week. It is what aligns a MULTI-week bucket (a
|
|
83014
|
-
* fortnight) to a Monday instead of to whatever day 1970-01-01 was.
|
|
83015
|
-
***************************************************************/
|
|
83016
|
-
function week_index(d) {
|
|
83017
|
-
return Math.floor((day_number(start_of_iso_week(d)) + 3) / 7);
|
|
83018
|
-
}
|
|
83019
|
-
/***************************
|
|
83020
|
-
* Period algebra
|
|
83021
|
-
***************************/
|
|
83022
|
-
/***************************************************************
|
|
83023
|
-
* Normalize whatever a caller hands us into a spec: an id of the
|
|
83024
|
-
* catalog, or a spec of its own. Returns null for anything that is not
|
|
83025
|
-
* a bucket (a "span" / "custom" mode of a navigator has no algebra).
|
|
83026
|
-
***************************************************************/
|
|
83027
|
-
function period_spec(period) {
|
|
83028
|
-
if (!period) return null;
|
|
83029
|
-
let spec = typeof period === "string" ? YUI_PERIODS[period] : period;
|
|
83030
|
-
if (!spec || !spec.unit) return null;
|
|
83031
|
-
if (PERIOD_UNITS.indexOf(spec.unit) < 0) return null;
|
|
83032
|
-
let count = parseInt(spec.count, 10);
|
|
83033
|
-
if (!(count > 0)) count = 1;
|
|
83034
|
-
return {
|
|
83035
|
-
id: spec.id || spec.unit,
|
|
83036
|
-
unit: spec.unit,
|
|
83037
|
-
count
|
|
83038
|
-
};
|
|
83039
|
-
}
|
|
83040
|
-
/***************************************************************
|
|
83041
|
-
* The START of the bucket that holds `anchor_ms`, as a local Date.
|
|
83042
|
-
*
|
|
83043
|
-
* Alignment is what makes a bucket a bucket. Each unit floors against
|
|
83044
|
-
* the natural origin of the unit above it, so the boundaries are the
|
|
83045
|
-
* ones a human already has in their head:
|
|
83046
|
-
*
|
|
83047
|
-
* minute -> the hour (a 15min bucket starts at :00/:15/:30/:45)
|
|
83048
|
-
* hour -> local midnight (a 6h bucket starts at 00/06/12/18)
|
|
83049
|
-
* day -> 1970-01-01 (count=1 is the plain day; a 10-day
|
|
83050
|
-
* bucket has no calendar origin to
|
|
83051
|
-
* align to, so it aligns to the epoch)
|
|
83052
|
-
* week -> the epoch week, Monday-first (ISO)
|
|
83053
|
-
* month -> January (which is why 2/3/4/6/12 give calendar
|
|
83054
|
-
* bimesters, quarters and semesters)
|
|
83055
|
-
* year -> year 0 (a decade starts at 2020, not 2021)
|
|
83056
|
-
***************************************************************/
|
|
83057
|
-
function period_start(period, anchor_ms) {
|
|
83058
|
-
let spec = period_spec(period);
|
|
83059
|
-
if (!spec) return null;
|
|
83060
|
-
let d = new Date(anchor_ms);
|
|
83061
|
-
let n = spec.count;
|
|
83062
|
-
switch (spec.unit) {
|
|
83063
|
-
case "minute": {
|
|
83064
|
-
let m = Math.floor(d.getMinutes() / n) * n;
|
|
83065
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), m);
|
|
83066
|
-
}
|
|
83067
|
-
case "hour": {
|
|
83068
|
-
let h = Math.floor(d.getHours() / n) * n;
|
|
83069
|
-
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h);
|
|
83070
|
-
}
|
|
83071
|
-
case "day": return date_from_day_number(Math.floor(day_number(d) / n) * n);
|
|
83072
|
-
case "week": return date_from_day_number(Math.floor(week_index(d) / n) * n * 7 - 3);
|
|
83073
|
-
case "month": {
|
|
83074
|
-
let mi = d.getFullYear() * 12 + d.getMonth();
|
|
83075
|
-
let s = Math.floor(mi / n) * n;
|
|
83076
|
-
return new Date(Math.floor(s / 12), s % 12, 1);
|
|
83077
|
-
}
|
|
83078
|
-
case "year": {
|
|
83079
|
-
let y = Math.floor(d.getFullYear() / n) * n;
|
|
83080
|
-
return new Date(y, 0, 1);
|
|
83081
|
-
}
|
|
83082
|
-
default: return null;
|
|
83083
|
-
}
|
|
83084
|
-
}
|
|
83085
|
-
/***************************************************************
|
|
83086
|
-
* The start of the bucket `delta` buckets away (delta may be negative).
|
|
83087
|
-
* Calendar arithmetic, never millisecond arithmetic: `new Date(y, m+3, 1)`
|
|
83088
|
-
* overflows the year by itself, and stepping a day across a DST change
|
|
83089
|
-
* keeps landing on midnight.
|
|
83090
|
-
***************************************************************/
|
|
83091
|
-
function period_shift(period, anchor_ms, delta) {
|
|
83092
|
-
let spec = period_spec(period);
|
|
83093
|
-
if (!spec) return anchor_ms;
|
|
83094
|
-
let s = period_start(spec, anchor_ms);
|
|
83095
|
-
let step = spec.count * (delta || 0);
|
|
83096
|
-
switch (spec.unit) {
|
|
83097
|
-
case "minute": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours(), s.getMinutes() + step).getTime();
|
|
83098
|
-
case "hour": return new Date(s.getFullYear(), s.getMonth(), s.getDate(), s.getHours() + step).getTime();
|
|
83099
|
-
case "day": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step).getTime();
|
|
83100
|
-
case "week": return new Date(s.getFullYear(), s.getMonth(), s.getDate() + step * 7).getTime();
|
|
83101
|
-
case "month": return new Date(s.getFullYear(), s.getMonth() + step, 1).getTime();
|
|
83102
|
-
case "year": return new Date(s.getFullYear() + step, 0, 1).getTime();
|
|
83103
|
-
default: return anchor_ms;
|
|
83104
|
-
}
|
|
83105
|
-
}
|
|
83106
|
-
/***************************************************************
|
|
83107
|
-
* The bucket holding `anchor_ms`, as {from, to} in MILLISECONDS.
|
|
83108
|
-
*
|
|
83109
|
-
* `to` is INCLUSIVE — the last millisecond of the bucket, not the first
|
|
83110
|
-
* of the next one. Both ends of a match condition are inclusive, and an
|
|
83111
|
-
* exclusive end handed to one silently swallows the record that landed
|
|
83112
|
-
* exactly on the boundary.
|
|
83113
|
-
***************************************************************/
|
|
83114
|
-
function period_bounds(period, anchor_ms) {
|
|
83115
|
-
let spec = period_spec(period);
|
|
83116
|
-
if (!spec) return {
|
|
83117
|
-
from: 0,
|
|
83118
|
-
to: 0
|
|
83119
|
-
};
|
|
83120
|
-
return {
|
|
83121
|
-
from: period_start(spec, anchor_ms).getTime(),
|
|
83122
|
-
to: period_shift(spec, anchor_ms, 1) - 1
|
|
83123
|
-
};
|
|
83124
|
-
}
|
|
83125
|
-
/***************************************************************
|
|
83126
|
-
* The same bucket, in the unit the CONSUMER speaks (a tranger topic
|
|
83127
|
-
* keeps its timestamps in seconds, unless its system_flag says
|
|
83128
|
-
* milliseconds). This is the function a query builder calls.
|
|
83129
|
-
***************************************************************/
|
|
83130
|
-
function period_bounds_epoch(period, anchor_ms, ms) {
|
|
83131
|
-
let b = period_bounds(period, anchor_ms);
|
|
83132
|
-
if (!b.from) return {
|
|
83133
|
-
from: 0,
|
|
83134
|
-
to: 0
|
|
83135
|
-
};
|
|
83136
|
-
return {
|
|
83137
|
-
from: ms_to_epoch(b.from, ms),
|
|
83138
|
-
to: ms_to_epoch(b.to, ms)
|
|
83139
|
-
};
|
|
83140
|
-
}
|
|
83141
|
-
/***************************************************************
|
|
83142
|
-
* A ROLLING window: `secs` back from now. Not a bucket — it has no
|
|
83143
|
-
* previous and no next, it just ends at `now`.
|
|
83144
|
-
*
|
|
83145
|
-
* The `to` end is left OPEN (0). An iterator with no upper bound keeps
|
|
83146
|
-
* matching the records that land while the card is on screen; pinning
|
|
83147
|
-
* it to "now" would freeze the window at the instant the user clicked.
|
|
83148
|
-
***************************************************************/
|
|
83149
|
-
function rolling_bounds(rolling, ms, now_ms) {
|
|
83150
|
-
let r = typeof rolling === "string" ? YUI_ROLLING[rolling] : rolling;
|
|
83151
|
-
if (!r || !r.secs) return {
|
|
83152
|
-
from: 0,
|
|
83153
|
-
to: 0
|
|
83154
|
-
};
|
|
83155
|
-
return {
|
|
83156
|
-
from: ms_to_epoch((now_ms === void 0 ? Date.now() : now_ms) - r.secs * 1e3, ms),
|
|
83157
|
-
to: 0
|
|
83158
|
-
};
|
|
83159
|
-
}
|
|
83160
|
-
/***************************************************************
|
|
83161
|
-
* Is this the LAST bucket — the one `now` falls in? It is what greys
|
|
83162
|
-
* out the "next" arrow, and what tells the navigator it is already home.
|
|
83163
|
-
***************************************************************/
|
|
83164
|
-
function is_current_period(period, anchor_ms, now_ms) {
|
|
83165
|
-
let spec = period_spec(period);
|
|
83166
|
-
if (!spec) return false;
|
|
83167
|
-
let now = now_ms === void 0 ? Date.now() : now_ms;
|
|
83168
|
-
let a = period_start(spec, anchor_ms);
|
|
83169
|
-
let b = period_start(spec, now);
|
|
83170
|
-
return !!a && !!b && a.getTime() === b.getTime();
|
|
83171
|
-
}
|
|
83172
|
-
/***************************************************************
|
|
83173
|
-
* Recognize the bucket a {from, to} pair came from, so a range that
|
|
83174
|
-
* travelled through a URL, a saved view or a backend answer comes back
|
|
83175
|
-
* as the period the user picked instead of as a hand-typed range.
|
|
83176
|
-
*
|
|
83177
|
-
* `from`/`to` are in the CONSUMER's unit (`ms`), and so is the
|
|
83178
|
-
* comparison — that is the whole trap: a bucket ends on the last
|
|
83179
|
-
* MILLISECOND (…23:59:59.999), and a consumer that keeps seconds stored
|
|
83180
|
-
* it truncated (…23:59:59). Comparing in milliseconds, a week saved by a
|
|
83181
|
-
* seconds-based topic came back as "no bucket at all", every time.
|
|
83182
|
-
*
|
|
83183
|
-
* Only an EXACT match counts: both ends must land on the bucket's own
|
|
83184
|
-
* boundaries, as that consumer would have written them. `candidates` are
|
|
83185
|
-
* ids/specs, tried in order. Returns {period, anchor} (anchor in ms) or
|
|
83186
|
-
* null.
|
|
83187
|
-
***************************************************************/
|
|
83188
|
-
function infer_period(from, to, candidates, ms) {
|
|
83189
|
-
if (!from || !to || to <= from) return null;
|
|
83190
|
-
let from_ms = epoch_to_ms(from, ms);
|
|
83191
|
-
for (let candidate of candidates || Object.keys(YUI_PERIODS)) {
|
|
83192
|
-
let spec = period_spec(candidate);
|
|
83193
|
-
if (!spec) continue;
|
|
83194
|
-
let b = period_bounds_epoch(spec, from_ms, ms);
|
|
83195
|
-
if (b.from === from && b.to === to) return {
|
|
83196
|
-
period: spec,
|
|
83197
|
-
anchor: from_ms
|
|
83198
|
-
};
|
|
83199
|
-
}
|
|
83200
|
-
return null;
|
|
83201
|
-
}
|
|
83202
|
-
/***************************
|
|
83203
|
-
* Period labels
|
|
83204
|
-
***************************/
|
|
83205
|
-
/***************************************************************
|
|
83206
|
-
* The name of a GRANULARITY (what the segmented control shows):
|
|
83207
|
-
* the spec's own id as an i18n key, so an app that declares
|
|
83208
|
-
* {id: "quarter"} gets "Trimestre" the moment it adds the key.
|
|
83209
|
-
***************************************************************/
|
|
83210
|
-
function period_name(period, t) {
|
|
83211
|
-
let spec = period_spec(period);
|
|
83212
|
-
if (!spec) return tr(t, String(period && period.id || period || ""));
|
|
83213
|
-
return tr(t, spec.id);
|
|
83214
|
-
}
|
|
83215
|
-
/***************************************************************
|
|
83216
|
-
* The name of the bucket a navigator is PARKED on: what goes between
|
|
83217
|
-
* the two arrows.
|
|
83218
|
-
*
|
|
83219
|
-
* day -> "Today" / "Yesterday" / "13 jul 2026"
|
|
83220
|
-
* week -> "Week 27" (+ year when it is not this one)
|
|
83221
|
-
* month -> "July" (+ year when it is not this one)
|
|
83222
|
-
* quarter -> "Q3 2026" (unit month, count 3)
|
|
83223
|
-
* semester -> "H2 2026" (unit month, count 6)
|
|
83224
|
-
* year -> "2026"
|
|
83225
|
-
* decade -> "2020 – 2029"
|
|
83226
|
-
* any other -> the bucket's own edges: "1 jul – 31 aug 2026"
|
|
83227
|
-
*
|
|
83228
|
-
* The named ones are named because a range reads worse than a name;
|
|
83229
|
-
* everything an app invents falls back to the range, which is always
|
|
83230
|
-
* true and never wrong.
|
|
83231
|
-
***************************************************************/
|
|
83232
|
-
function period_label(period, anchor_ms, t, locale) {
|
|
83233
|
-
let spec = period_spec(period);
|
|
83234
|
-
if (!spec) return "";
|
|
83235
|
-
let loc = safe_locale(locale);
|
|
83236
|
-
let start = period_start(spec, anchor_ms);
|
|
83237
|
-
let end = new Date(period_bounds(spec, anchor_ms).to);
|
|
83238
|
-
let now = /* @__PURE__ */ new Date();
|
|
83239
|
-
let this_year = start.getFullYear() === now.getFullYear();
|
|
83240
|
-
if (spec.unit === "day" && spec.count === 1) {
|
|
83241
|
-
let diff = day_number(start) - day_number(now);
|
|
83242
|
-
if (diff === 0) return tr(t, "today");
|
|
83243
|
-
if (diff === -1) return tr(t, "yesterday");
|
|
83244
|
-
if (diff === 1) return tr(t, "tomorrow");
|
|
83245
|
-
return fmt_intl(start, loc, this_year ? {
|
|
83246
|
-
day: "numeric",
|
|
83247
|
-
month: "short"
|
|
83248
|
-
} : {
|
|
83249
|
-
day: "numeric",
|
|
83250
|
-
month: "short",
|
|
83251
|
-
year: "numeric"
|
|
83252
|
-
});
|
|
83253
|
-
}
|
|
83254
|
-
if (spec.unit === "hour" && spec.count === 1) {
|
|
83255
|
-
let hh = fmt_intl(start, loc, {
|
|
83256
|
-
hour: "2-digit",
|
|
83257
|
-
minute: "2-digit"
|
|
83258
|
-
});
|
|
83259
|
-
if (day_number(start) === day_number(now)) return hh;
|
|
83260
|
-
return `${hh} · ${fmt_intl(start, loc, {
|
|
83261
|
-
day: "numeric",
|
|
83262
|
-
month: "short"
|
|
83263
|
-
})}`;
|
|
83264
|
-
}
|
|
83265
|
-
if (spec.unit === "week" && spec.count === 1) {
|
|
83266
|
-
let away = week_index(start) - week_index(now);
|
|
83267
|
-
if (away === 0) return tr(t, "this week");
|
|
83268
|
-
if (away === -1) return tr(t, "last week");
|
|
83269
|
-
let w = iso_week(start);
|
|
83270
|
-
return w.year === now.getFullYear() ? tr(t, "week {{n}}", { n: w.week }) : tr(t, "week {{n}} {{y}}", {
|
|
83271
|
-
n: w.week,
|
|
83272
|
-
y: w.year
|
|
83273
|
-
});
|
|
83274
|
-
}
|
|
83275
|
-
if (spec.unit === "month" && spec.count === 1) return fmt_intl(start, loc, this_year ? { month: "long" } : {
|
|
83276
|
-
month: "long",
|
|
83277
|
-
year: "numeric"
|
|
83278
|
-
});
|
|
83279
|
-
if (spec.unit === "month" && (spec.count === 3 || spec.count === 6)) {
|
|
83280
|
-
let n = Math.floor(start.getMonth() / spec.count) + 1;
|
|
83281
|
-
return tr(t, spec.count === 3 ? "quarter {{n}} {{y}}" : "semester {{n}} {{y}}", {
|
|
83282
|
-
n,
|
|
83283
|
-
y: start.getFullYear()
|
|
83284
|
-
});
|
|
83285
|
-
}
|
|
83286
|
-
if (spec.unit === "year") {
|
|
83287
|
-
if (spec.count === 1) return String(start.getFullYear());
|
|
83288
|
-
return `${start.getFullYear()} – ${end.getFullYear()}`;
|
|
83289
|
-
}
|
|
83290
|
-
let opts = spec.unit === "minute" || spec.unit === "hour" ? {
|
|
83291
|
-
day: "numeric",
|
|
83292
|
-
month: "short",
|
|
83293
|
-
hour: "2-digit",
|
|
83294
|
-
minute: "2-digit"
|
|
83295
|
-
} : {
|
|
83296
|
-
day: "numeric",
|
|
83297
|
-
month: "short"
|
|
83298
|
-
};
|
|
83299
|
-
if (start.getFullYear() !== end.getFullYear()) {
|
|
83300
|
-
let y_opts = Object.assign({ year: "numeric" }, opts);
|
|
83301
|
-
return `${fmt_intl(start, loc, y_opts)} – ${fmt_intl(end, loc, y_opts)}`;
|
|
83302
|
-
}
|
|
83303
|
-
let span = `${fmt_intl(start, loc, opts)} – ${fmt_intl(end, loc, opts)}`;
|
|
83304
|
-
return this_year ? span : `${span} ${start.getFullYear()}`;
|
|
83305
|
-
}
|
|
83306
|
-
//#endregion
|
|
83307
83548
|
//#region src/c_yui_period.js
|
|
83308
83549
|
/***********************************************************************
|
|
83309
83550
|
* c_yui_period.js
|
|
@@ -86258,6 +86499,7 @@ exports.enableElements = enableElements;
|
|
|
86258
86499
|
exports.epoch_to_local_input = epoch_to_local_input;
|
|
86259
86500
|
exports.epoch_to_ms = epoch_to_ms;
|
|
86260
86501
|
exports.expose_view_container = expose_view_container;
|
|
86502
|
+
exports.fmt_date_time = fmt_date_time;
|
|
86261
86503
|
exports.fmt_epoch = fmt_epoch;
|
|
86262
86504
|
exports.getStrokeColor = getStrokeColor;
|
|
86263
86505
|
exports.infer_period = infer_period;
|