@yuneta/gobj-ui 7.26.51 → 7.26.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -2
- package/dist/gobj-ui.cjs.js +330 -71
- package/dist/gobj-ui.es.js +321 -63
- package/index.js +1 -0
- package/package.json +1 -1
- package/src/c_yui_form.js +48 -5
- package/src/c_yui_json.js +36 -3
- package/src/c_yui_treedb_topic_with_form.js +13 -28
- package/src/c_yui_uplot.js +51 -2
- package/src/fmt_date_time.test.js +138 -0
- package/src/form_table_rows.wiring.test.js +5 -4
- package/src/form_time_value.js +9 -6
- package/src/form_time_value.test.js +1 -1
- package/src/json_view_helpers.js +8 -3
- package/src/time_text.wiring.test.js +489 -0
- package/src/yui_date_text.js +82 -0
- package/src/yui_time.js +6 -22
- package/src/yui_uplot_time.js +142 -0
package/README.md
CHANGED
|
@@ -898,6 +898,23 @@ with both dict- and array-drill (via `kw_collapse()`): `c_tranger.c` for a
|
|
|
898
898
|
A document that arrives with no `__collapsed__` sentinels is simply rendered
|
|
899
899
|
client-side (no lazy drill).
|
|
900
900
|
|
|
901
|
+
**The reading of a time field.** Beside a number under a time key (`t`, `tm`,
|
|
902
|
+
`__t__`, `from_t`, `fr_t`, … — `TIME_FIELDS` in `json_view_helpers.js`, seconds
|
|
903
|
+
or milliseconds) the tree writes the moment in the app's language with a clock
|
|
904
|
+
of 24 hours (`JSON_TIME`):
|
|
905
|
+
|
|
906
|
+
```text
|
|
907
|
+
"t": 1785312000 29 jul 2026, 10:00:00 (es, Europe/Madrid)
|
|
908
|
+
"t": 1785312000 Jul 29, 2026, 10:00:00 (en)
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
The viewer subscribes ITSELF to the shell's `EV_LANGUAGE_CHANGED` and draws the
|
|
912
|
+
tree again (7.26.52). Up to 7.26.51 the reading was `toLocaleString()` -- the
|
|
913
|
+
browser's language, and 12 hours in English -- and the language action never
|
|
914
|
+
ran: no host forwarded the event. A language change draws only the tree: the
|
|
915
|
+
text view carries its keys, and the graph is not loaded again (it would lose the
|
|
916
|
+
reader's camera).
|
|
917
|
+
|
|
901
918
|
Logical DOM classes: `JSON_VIEWER`, `JSON_TOOLBAR`, `JSON_SEARCH`, `JSON_TREE`,
|
|
902
919
|
`JSON_ROW`, `JSON_KEY`, `JSON_VALUE`, `JSON_SUMMARY`, `JSON_COLLAPSED`,
|
|
903
920
|
`JSON_TIME`. The gclass imports its own `c_yui_json.css`.
|
|
@@ -3693,6 +3710,25 @@ new uPlot({width: 600, height: 300, series: [{}, {label: "temperature"}],
|
|
|
3693
3710
|
axes: yui_uplot_axes([{}])}, data, $el);
|
|
3694
3711
|
```
|
|
3695
3712
|
|
|
3713
|
+
**The moments of a time axis are the app's language, 24 hours** (7.26.52).
|
|
3714
|
+
uPlot writes them from templates of its own, in English and 12 hours: `3pm`,
|
|
3715
|
+
`3:05pm`, `10/14` (month first) on the ticks, `2026-10-14 3:05pm` in the
|
|
3716
|
+
legend. `C_YUI_UPLOT` gives it `fmtDate: yui_uplot_fmt_date(() =>
|
|
3717
|
+
i18next.language)` (`yui_uplot_time.js`): the ticks read `15:00`, `15:05`, es
|
|
3718
|
+
`14/10` / en `10/14`, and the legend reads as every other time a view shows
|
|
3719
|
+
(`14 oct 2026, 15:05:09`). It subscribes to the shell's `EV_LANGUAGE_CHANGED`
|
|
3720
|
+
and redraws the axes and the legend. A uPlot built by the app takes the same
|
|
3721
|
+
option:
|
|
3722
|
+
|
|
3723
|
+
```js
|
|
3724
|
+
import {yui_uplot_fmt_date} from "@yuneta/gobj-ui/src/yui_uplot_time.js";
|
|
3725
|
+
|
|
3726
|
+
new uPlot({..., fmtDate: yui_uplot_fmt_date(() => i18next.language)}, data, $el);
|
|
3727
|
+
// on EV_LANGUAGE_CHANGED: chart.redraw(true, true); chart.setLegend(null, false);
|
|
3728
|
+
```
|
|
3729
|
+
|
|
3730
|
+
An axis whose host gives its own `values` writes them as the host says.
|
|
3731
|
+
|
|
3696
3732
|
### `C_YUI_FORM` — what closing it asks about
|
|
3697
3733
|
|
|
3698
3734
|
`changes` says the form is not what is stored: the reader changed it, or the
|
|
@@ -3747,8 +3783,12 @@ second, read and written as the form's own time field is (`form_time_value.js`:
|
|
|
3747
3783
|
an epoch in seconds, or an ISO text for a string column). Up to 7.26.45 it was
|
|
3748
3784
|
Tabulator's `datetime` editor with a luxon `format`, and nothing gives gobj-ui
|
|
3749
3785
|
luxon: it opened empty and threw when committed. Luxon is not taken in for one
|
|
3750
|
-
editor. The cell shows the
|
|
3751
|
-
|
|
3786
|
+
editor. The cell shows the local clock as text, in the app's language and 24
|
|
3787
|
+
hours -- es `14 mar 2026, 09:26:53`, en `Mar 14, 2026, 09:26:53`, the same
|
|
3788
|
+
text as the time cells of `C_YUI_TREEDB_TOPIC_WITH_FORM` -- and writes it again
|
|
3789
|
+
when the language changes (7.26.52; 7.26.47 to 7.26.51 showed
|
|
3790
|
+
`2026-03-14 09:26:53`, and up to 7.26.46 the raw epoch). See *Dates → A time
|
|
3791
|
+
shown as text*.
|
|
3752
3792
|
|
|
3753
3793
|
A date with a part cleared is not a value. The box answers `""` for it, as for an
|
|
3754
3794
|
empty box, and only `validity.badInput` tells them apart: Enter leaves the editor
|
|
@@ -5534,6 +5574,8 @@ nothing else should.
|
|
|
5534
5574
|
- `epoch_to_local_input` / `local_input_to_epoch` / `fmt_epoch` / `epoch_to_ms`
|
|
5535
5575
|
/ `ms_to_epoch` — every conversion crosses the producer's unit flag
|
|
5536
5576
|
(`ms`: seconds unless a topic's `system_flag` says milliseconds).
|
|
5577
|
+
- `fmt_date_time(date, locale)` — a moment as a view shows it as text, in the
|
|
5578
|
+
app's language, 24 hours (see *Dates: a time shown as text*).
|
|
5537
5579
|
- `period_bounds` / `period_shift` / `period_start` / `period_label` /
|
|
5538
5580
|
`infer_period` / `is_current_period` — the algebra of **periods**.
|
|
5539
5581
|
|
|
@@ -5587,6 +5629,50 @@ formatting (month names, weekday initials, the parked-bucket label) follows
|
|
|
5587
5629
|
i18next's ACTIVE language, not `navigator.language` — the calendar never mixes
|
|
5588
5630
|
scripts with the UI around it.
|
|
5589
5631
|
|
|
5632
|
+
### Dates: a time shown as text
|
|
5633
|
+
|
|
5634
|
+
**Every time a view shows as text is in the APP's language, with a clock of 24
|
|
5635
|
+
hours** (7.26.52). One function writes it, `fmt_date_time(date, locale)` in
|
|
5636
|
+
`yui_time.js` -- day, short month, year, then hours, minutes and seconds --,
|
|
5637
|
+
and the views pass it `i18next.language`, never `navigator.language`:
|
|
5638
|
+
|
|
5639
|
+
```js
|
|
5640
|
+
import {fmt_date_time, safe_locale} from "@yuneta/gobj-ui/src/yui_time.js";
|
|
5641
|
+
import i18next from "i18next";
|
|
5642
|
+
|
|
5643
|
+
fmt_date_time(new Date(2026, 9, 14, 15, 5, 9), safe_locale(i18next.language));
|
|
5644
|
+
// es "14 oct 2026, 15:05:09"
|
|
5645
|
+
// en "Oct 14, 2026, 15:05:09" (en-US too: 24 hours, no AM/PM)
|
|
5646
|
+
// midnight "00:00:00", never "24:00:00" (hourCycle "h23", not hour12: false)
|
|
5647
|
+
// not a valid Date -> ""; a locale Intl refuses -> "2026-10-14 15:05:09"
|
|
5648
|
+
```
|
|
5649
|
+
|
|
5650
|
+
What writes it, and follows the language button (`EV_LANGUAGE_CHANGED`):
|
|
5651
|
+
|
|
5652
|
+
| View | Where | Up to 7.26.51 |
|
|
5653
|
+
|---|---|---|
|
|
5654
|
+
| `C_YUI_TREEDB_TOPIC_WITH_FORM` | the cells of a `time` / `now` column | browser's language, 12 h: `14 oct 2026, 03:05:09 p. m.`; did not change with the app |
|
|
5655
|
+
| `C_YUI_FORM` | the cells of a `time` / `now` column of a table | `2026-10-14 15:05:09` |
|
|
5656
|
+
| `C_YUI_JSON` | the reading beside a time field (`JSON_TIME`) | `toLocaleString()`; never changed |
|
|
5657
|
+
| `C_YUI_UPLOT` | the ticks of a time axis and the legend | uPlot's English, 12 h |
|
|
5658
|
+
|
|
5659
|
+
`time_value_to_text(value, real_type, locale)` (`form_time_value.js`) is the
|
|
5660
|
+
reader of a time COLUMN on top of it (an epoch in seconds, or an ISO text for a
|
|
5661
|
+
`string` column; `""` for no time, a value that is not a time shown as it is),
|
|
5662
|
+
and `format_epoch(value, locale)` (`json_view_helpers.js`) the reader of a
|
|
5663
|
+
number that may be seconds or milliseconds.
|
|
5664
|
+
|
|
5665
|
+
The EDITORS are not text: the form's time field and the cell editor are
|
|
5666
|
+
`datetime-local` boxes, drawn by the browser in the browser's language. In the
|
|
5667
|
+
form, a cell whose editor is open when the language changes is left to it, and
|
|
5668
|
+
written in the new language when it closes. Other times that are deliberately
|
|
5669
|
+
not written this way: the bounds `C_YUI_PERIOD` resolves
|
|
5670
|
+
(`2026-10-14 00:00:00 → 2026-10-14 23:59:59.999`, `fmt_epoch`: the exact range
|
|
5671
|
+
a query will carry, with its milliseconds, under a label that is already in the
|
|
5672
|
+
app's language), and the developer window's traffic (`hh:mm:ss.SSS` of arrival
|
|
5673
|
+
and an ISO `Z` beside a timestamp field, to be matched against the backend's
|
|
5674
|
+
logs).
|
|
5675
|
+
|
|
5590
5676
|
### Inputs: a clear (✕) is the norm on free-text fields
|
|
5591
5677
|
|
|
5592
5678
|
Every editable free-text field carries a clear button — a big help on mobile,
|