@yuneta/gobj-ui 7.26.54 → 7.26.56
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 +36 -8
- package/dist/gobj-ui.cjs.js +107 -81
- package/dist/gobj-ui.es.js +68 -42
- package/package.json +4 -4
- package/scripts/validate-locales.mjs +59 -17
- package/src/c_yui_form.js +4 -2
- package/src/fmt_date_time.test.js +31 -2
- package/src/form_time_field.wiring.test.js +28 -0
- package/src/yui_date_text.js +30 -8
- package/src/yui_tabulator_edit.js +40 -24
- package/src/yui_tabulator_edit.test.js +132 -0
- package/src/yui_time.js +2 -7
- package/src/yui_uplot_time.js +2 -6
package/README.md
CHANGED
|
@@ -4199,6 +4199,10 @@ and reads back the bundle each host serves (`--check` only reads back,
|
|
|
4199
4199
|
`--only <name>` does one app, `--no-wait` skips the registry). The private
|
|
4200
4200
|
consumers are listed in `~/.yuneta/gobj-ui-consumers.json` (see
|
|
4201
4201
|
`scripts/gobj-ui-consumers.example.json`); the demo (`test-app/`) is built in.
|
|
4202
|
+
It is built from the working tree, so it goes out only from a clean tree whose
|
|
4203
|
+
HEAD is the commit `origin/main` holds on the remote; otherwise it is `NOT
|
|
4204
|
+
DEPLOYED`, with the reason, and the round exits 1 (since `7.26.55`; up to
|
|
4205
|
+
`7.26.54` any copy of the repo, on any commit, deployed the public demo).
|
|
4202
4206
|
|
|
4203
4207
|
An app whose range cannot be raised safely is refused and left as it was --
|
|
4204
4208
|
every package.json of it, since all are checked before any is written: a
|
|
@@ -4256,7 +4260,10 @@ one of `@yuneta/gobj-ui` on the same HEAD read the library's states -- and
|
|
|
4256
4260
|
said "already" for an app born with both new ranges whose number had gone out
|
|
4257
4261
|
with the runtime's old range (deploying a new bundle under that number), or
|
|
4258
4262
|
raised a version for nothing. A file of another format (one of those rounds)
|
|
4259
|
-
is not read, and is written again; the 64 entries used last are kept.
|
|
4263
|
+
is not read, and is written again; the 64 entries used last are kept. An
|
|
4264
|
+
entry that is not a list of `{specs: [string], versions: [string]}` is said,
|
|
4265
|
+
read again from git and written again (since `7.26.55`; up to `7.26.54` an
|
|
4266
|
+
entry `[null]` refused the app on every round, naming no file). A
|
|
4260
4267
|
package.json born with the range in the ROOT of a
|
|
4261
4268
|
history joined to another one (`--allow-unrelated-histories`) is asked of the
|
|
4262
4269
|
other history, by version, as one born in a commit with parents is. The
|
|
@@ -4606,7 +4613,11 @@ This tree asks for "admin" (a root with children and no `label`), for
|
|
|
4606
4613
|
dependency of this package since `7.26.29`: an app need not declare it). A
|
|
4607
4614
|
LOCALE is not a source: it is parsed, and then imported, so its top-level code
|
|
4608
4615
|
runs -- the app's own code, but code, and in a process of its own (since
|
|
4609
|
-
`7.26.51`), so
|
|
4616
|
+
`7.26.51`), so what a locale does by ACCIDENT does not reach the verdict:
|
|
4617
|
+
ending the process, an exit handler, a timer, a report of its own written to
|
|
4618
|
+
the channel or a `toJSON` on a prototype (refused or never read since
|
|
4619
|
+
`7.26.55`). That process is no sandbox against a locale written to cheat it.
|
|
4620
|
+
Comments are not code. A key is read
|
|
4610
4621
|
where it is WRITTEN -- given to a translator, as an `i18n` or `data-i18n*`
|
|
4611
4622
|
value of an object literal, by `setAttribute()`, or (since `7.26.29`) written
|
|
4612
4623
|
as a member, `attrs.i18n = "save"`, `attrs["data-i18n-title"] = "save"` -- and
|
|
@@ -5574,8 +5585,9 @@ nothing else should.
|
|
|
5574
5585
|
- `epoch_to_local_input` / `local_input_to_epoch` / `fmt_epoch` / `epoch_to_ms`
|
|
5575
5586
|
/ `ms_to_epoch` — every conversion crosses the producer's unit flag
|
|
5576
5587
|
(`ms`: seconds unless a topic's `system_flag` says milliseconds).
|
|
5577
|
-
- `fmt_date_time(date, locale)`
|
|
5578
|
-
|
|
5588
|
+
- `fmt_date_time(date, locale)` and `safe_locale(locale)` are re-exported
|
|
5589
|
+
here, but they live in `yui_date_text.js`: import them from THERE (see
|
|
5590
|
+
*Dates: a time shown as text*).
|
|
5579
5591
|
- `period_bounds` / `period_shift` / `period_start` / `period_label` /
|
|
5580
5592
|
`infer_period` / `is_current_period` — the algebra of **periods**.
|
|
5581
5593
|
|
|
@@ -5633,20 +5645,36 @@ scripts with the UI around it.
|
|
|
5633
5645
|
|
|
5634
5646
|
**Every time a view shows as text is in the APP's language, with a clock of 24
|
|
5635
5647
|
hours** (7.26.52). One function writes it, `fmt_date_time(date, locale)` in
|
|
5636
|
-
`
|
|
5637
|
-
and the views pass it `i18next.language`, never `navigator.language
|
|
5648
|
+
`yui_date_text.js` -- day, short month, year, then hours, minutes and seconds --,
|
|
5649
|
+
and the views pass it `i18next.language`, never `navigator.language`. Import it
|
|
5650
|
+
from `yui_date_text.js`, not from `yui_time.js`: `validate-locales` follows the
|
|
5651
|
+
modules an app imports, and `yui_time.js` makes the app owe every key of the
|
|
5652
|
+
period picker.
|
|
5638
5653
|
|
|
5639
5654
|
```js
|
|
5640
|
-
import {fmt_date_time, safe_locale} from "@yuneta/gobj-ui/src/
|
|
5655
|
+
import {fmt_date_time, safe_locale} from "@yuneta/gobj-ui/src/yui_date_text.js";
|
|
5641
5656
|
import i18next from "i18next";
|
|
5642
5657
|
|
|
5643
5658
|
fmt_date_time(new Date(2026, 9, 14, 15, 5, 9), safe_locale(i18next.language));
|
|
5644
5659
|
// es "14 oct 2026, 15:05:09"
|
|
5645
5660
|
// en "Oct 14, 2026, 15:05:09" (en-US too: 24 hours, no AM/PM)
|
|
5646
5661
|
// midnight "00:00:00", never "24:00:00" (hourCycle "h23", not hour12: false)
|
|
5647
|
-
// not a valid Date -> ""
|
|
5662
|
+
// not a valid Date -> ""
|
|
5648
5663
|
```
|
|
5649
5664
|
|
|
5665
|
+
Three facts the text does not show:
|
|
5666
|
+
|
|
5667
|
+
- **The zone is the browser's**, and the text names no zone and no offset. Two
|
|
5668
|
+
readers in two zones see two different clocks for the same record.
|
|
5669
|
+
- **The hour that repeats in autumn reads the same in its two passes**: in
|
|
5670
|
+
Europe/Madrid, `1792888200` and `1792891800` both read
|
|
5671
|
+
`25 oct 2026, 02:30:00`.
|
|
5672
|
+
- **A locale the environment cannot use writes in the environment's
|
|
5673
|
+
language.** A well-formed one Intl does not know (`xx`, `cimode`, `dev`) does
|
|
5674
|
+
it by Intl's own rule, silently. A malformed one Intl refuses (`en_US`) does
|
|
5675
|
+
it through `date_time_format()` (`yui_date_text.js`), which says it once per
|
|
5676
|
+
locale in a WARNING. The ticks of a chart's time axis fall back the same way.
|
|
5677
|
+
|
|
5650
5678
|
What writes it, and follows the language button (`EV_LANGUAGE_CHANGED`):
|
|
5651
5679
|
|
|
5652
5680
|
| View | Where | Up to 7.26.51 |
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
10
10
|
var __exportAll = (all, no_symbols) => {
|
|
11
11
|
let target = {};
|
|
12
12
|
for (var name in all) __defProp(target, name, {
|
|
@@ -9712,6 +9712,28 @@ function safe_locale(locale) {
|
|
|
9712
9712
|
if (typeof nav === "string" && nav && nav !== "undefined") return nav;
|
|
9713
9713
|
return "en";
|
|
9714
9714
|
}
|
|
9715
|
+
var __refused_locales__ = /* @__PURE__ */ new Set();
|
|
9716
|
+
/***************************************************************
|
|
9717
|
+
* An Intl.DateTimeFormat of `locale` with `options`. A locale
|
|
9718
|
+
* Intl refuses (a malformed tag: "en_US") falls back to the
|
|
9719
|
+
* environment's -- what Intl itself gives for a well-formed
|
|
9720
|
+
* one it does not know ("xx") -- and is said in a WARNING, once
|
|
9721
|
+
* per locale. fmt_date_time() and the ticks of a uPlot time axis
|
|
9722
|
+
* (yui_uplot_time.js) both go through it, so they fall back the
|
|
9723
|
+
* same way.
|
|
9724
|
+
***************************************************************/
|
|
9725
|
+
function date_time_format(locale, options) {
|
|
9726
|
+
let loc = safe_locale(locale);
|
|
9727
|
+
try {
|
|
9728
|
+
return new Intl.DateTimeFormat(loc, options);
|
|
9729
|
+
} catch (e) {
|
|
9730
|
+
if (!__refused_locales__.has(loc)) {
|
|
9731
|
+
__refused_locales__.add(loc);
|
|
9732
|
+
(0, _yuneta_gobj_js.log_warning)(`date_time_format: locale '${loc}' refused by Intl (${e}), using the environment's`);
|
|
9733
|
+
}
|
|
9734
|
+
return new Intl.DateTimeFormat(void 0, options);
|
|
9735
|
+
}
|
|
9736
|
+
}
|
|
9715
9737
|
var DATE_TIME_OPTIONS = {
|
|
9716
9738
|
day: "numeric",
|
|
9717
9739
|
month: "short",
|
|
@@ -9731,7 +9753,7 @@ var DATE_TIME_OPTIONS = {
|
|
|
9731
9753
|
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
9732
9754
|
*
|
|
9733
9755
|
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
9734
|
-
*
|
|
9756
|
+
* writes in the environment's (date_time_format).
|
|
9735
9757
|
*
|
|
9736
9758
|
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
9737
9759
|
* the reading C_YUI_JSON writes beside a time field all come from
|
|
@@ -9739,12 +9761,7 @@ var DATE_TIME_OPTIONS = {
|
|
|
9739
9761
|
***************************************************************/
|
|
9740
9762
|
function fmt_date_time(date, locale) {
|
|
9741
9763
|
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
|
9742
|
-
|
|
9743
|
-
return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
|
|
9744
|
-
} catch (e) {
|
|
9745
|
-
let pad = (n) => String(n).padStart(2, "0");
|
|
9746
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
9747
|
-
}
|
|
9764
|
+
return date_time_format(locale, DATE_TIME_OPTIONS).format(date);
|
|
9748
9765
|
}
|
|
9749
9766
|
/************************************************************
|
|
9750
9767
|
* JSON type discriminator (viewer vocabulary)
|
|
@@ -10326,7 +10343,8 @@ function form_time_cell_editor(real_type) {
|
|
|
10326
10343
|
/****************************************************************************
|
|
10327
10344
|
* yui_tabulator_edit.js
|
|
10328
10345
|
*
|
|
10329
|
-
* An open cell editor survives a FORCED redraw of its table
|
|
10346
|
+
* An open cell editor survives a FORCED redraw of its table,
|
|
10347
|
+
* and the other calls that build its cells again.
|
|
10330
10348
|
*
|
|
10331
10349
|
* `table.redraw(true)` builds every row's cells again, the one
|
|
10332
10350
|
* being edited too, and leaves Tabulator's edit pointing at the
|
|
@@ -10341,7 +10359,12 @@ function form_time_cell_editor(real_type) {
|
|
|
10341
10359
|
* does not blur, and throws at the next edit. Any editor, ours
|
|
10342
10360
|
* (form_time_cell_editor.js) or Tabulator's own.
|
|
10343
10361
|
*
|
|
10344
|
-
*
|
|
10362
|
+
* `setColumns()` (a language change of
|
|
10363
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM runs it) and `setHeight`,
|
|
10364
|
+
* `setMaxHeight` and `setMinHeight` build the cells again the
|
|
10365
|
+
* same way, and Tabulator throws the same.
|
|
10366
|
+
*
|
|
10367
|
+
* So the edit is ended BEFORE each of those calls, while its cell
|
|
10345
10368
|
* is alive, and opened again on the new cell of the same row
|
|
10346
10369
|
* and column after it. What was typed in the box is lost; the
|
|
10347
10370
|
* editor stays open under the reader.
|
|
@@ -10350,8 +10373,10 @@ function form_time_cell_editor(real_type) {
|
|
|
10350
10373
|
* All Rights Reserved.
|
|
10351
10374
|
****************************************************************************/
|
|
10352
10375
|
/************************************************************
|
|
10353
|
-
* Wrap `tabulator
|
|
10354
|
-
*
|
|
10376
|
+
* Wrap the calls of `tabulator` that build the cells again --
|
|
10377
|
+
* a forced `redraw`, `setColumns` and the three height setters
|
|
10378
|
+
* -- so that each ends the open edit first and opens it again
|
|
10379
|
+
* after.
|
|
10355
10380
|
************************************************************/
|
|
10356
10381
|
function yui_tabulator_keep_edit_on_redraw(tabulator) {
|
|
10357
10382
|
let editing = null;
|
|
@@ -10364,23 +10389,32 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
|
|
|
10364
10389
|
tabulator.on("cellEditCancelled", function() {
|
|
10365
10390
|
editing = null;
|
|
10366
10391
|
});
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
(
|
|
10392
|
+
function keep_edit_around(name, rebuilds) {
|
|
10393
|
+
let original = tabulator[name].bind(tabulator);
|
|
10394
|
+
tabulator[name] = function(...args) {
|
|
10395
|
+
let cell = editing;
|
|
10396
|
+
let $cell = cell ? cell.getElement() : null;
|
|
10397
|
+
if (!rebuilds(args) || !$cell || !$cell.classList.contains("tabulator-editing")) return original(...args);
|
|
10398
|
+
let row = cell.getRow();
|
|
10399
|
+
let field = cell.getField();
|
|
10400
|
+
cell.cancelEdit();
|
|
10401
|
+
let ret = original(...args);
|
|
10402
|
+
let again = row.getCell(field);
|
|
10403
|
+
if (!again) {
|
|
10404
|
+
(0, _yuneta_gobj_js.log_warning)(`yui_tabulator_keep_edit_on_redraw: no cell '${field}' after ${name}()`);
|
|
10405
|
+
return ret;
|
|
10406
|
+
}
|
|
10407
|
+
again.edit(true);
|
|
10379
10408
|
return ret;
|
|
10380
|
-
}
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10409
|
+
};
|
|
10410
|
+
}
|
|
10411
|
+
keep_edit_around("redraw", (args) => !!args[0]);
|
|
10412
|
+
for (const name of [
|
|
10413
|
+
"setColumns",
|
|
10414
|
+
"setHeight",
|
|
10415
|
+
"setMaxHeight",
|
|
10416
|
+
"setMinHeight"
|
|
10417
|
+
]) keep_edit_around(name, () => true);
|
|
10384
10418
|
}
|
|
10385
10419
|
//#endregion
|
|
10386
10420
|
//#region src/form_json_field.js
|
|
@@ -13298,10 +13332,10 @@ function set_form_values(gobj, template, $form, record) {
|
|
|
13298
13332
|
switch (input_type) {
|
|
13299
13333
|
case "datetime-local":
|
|
13300
13334
|
$input.value = date_to_datetime_local(value);
|
|
13301
|
-
$input.yui_time_kept = {
|
|
13335
|
+
$input.yui_time_kept = $input.value !== "" ? {
|
|
13302
13336
|
value: stored,
|
|
13303
13337
|
shown: $input.value
|
|
13304
|
-
};
|
|
13338
|
+
} : null;
|
|
13305
13339
|
break;
|
|
13306
13340
|
case "color":
|
|
13307
13341
|
$input.value = convertColor(value);
|
|
@@ -15217,11 +15251,7 @@ function intl(locale, opts) {
|
|
|
15217
15251
|
let key = locale + "|" + JSON.stringify(opts);
|
|
15218
15252
|
let f = __formatters__.get(key);
|
|
15219
15253
|
if (!f) {
|
|
15220
|
-
|
|
15221
|
-
f = new Intl.DateTimeFormat(locale, opts);
|
|
15222
|
-
} catch (e) {
|
|
15223
|
-
f = new Intl.DateTimeFormat("en", opts);
|
|
15224
|
-
}
|
|
15254
|
+
f = date_time_format(locale, opts);
|
|
15225
15255
|
__formatters__.set(key, f);
|
|
15226
15256
|
}
|
|
15227
15257
|
return f;
|
|
@@ -15392,9 +15422,9 @@ function mt_destroy$15(gobj) {
|
|
|
15392
15422
|
gobj.priv.theme_observer.disconnect();
|
|
15393
15423
|
gobj.priv.theme_observer = null;
|
|
15394
15424
|
}
|
|
15395
|
-
let uplot
|
|
15396
|
-
if (uplot
|
|
15397
|
-
uplot
|
|
15425
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15426
|
+
if (uplot) {
|
|
15427
|
+
uplot.destroy();
|
|
15398
15428
|
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "uplot", null);
|
|
15399
15429
|
}
|
|
15400
15430
|
destroy_ui$9(gobj);
|
|
@@ -15424,12 +15454,12 @@ function build_ui$14(gobj) {
|
|
|
15424
15454
|
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales"),
|
|
15425
15455
|
fmtDate: yui_uplot_fmt_date(() => i18next.default.language)
|
|
15426
15456
|
};
|
|
15427
|
-
let uplot$
|
|
15428
|
-
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "uplot", uplot$
|
|
15457
|
+
let uplot$1 = new uplot.default(uPlot_options, (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "data"), $container);
|
|
15458
|
+
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "uplot", uplot$1);
|
|
15429
15459
|
let fixed_height = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "height");
|
|
15430
15460
|
function fit_to_container() {
|
|
15431
15461
|
let w = $container.clientWidth;
|
|
15432
|
-
if (w > 0) uplot$
|
|
15462
|
+
if (w > 0) uplot$1.setSize({
|
|
15433
15463
|
width: w,
|
|
15434
15464
|
height: fixed_height
|
|
15435
15465
|
});
|
|
@@ -15465,19 +15495,19 @@ function destroy_ui$9(gobj) {
|
|
|
15465
15495
|
*
|
|
15466
15496
|
******************************************************/
|
|
15467
15497
|
function ac_load_data$2(gobj, event, kw, src) {
|
|
15468
|
-
let uplot
|
|
15498
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15469
15499
|
if (!kw.length) {
|
|
15470
|
-
uplot
|
|
15500
|
+
uplot.setData([]);
|
|
15471
15501
|
return -1;
|
|
15472
15502
|
}
|
|
15473
15503
|
let tm = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "tm");
|
|
15474
15504
|
let data = [];
|
|
15475
|
-
let max_series = uplot
|
|
15505
|
+
let max_series = uplot.series.length;
|
|
15476
15506
|
for (let idx = 0; idx < max_series; idx++) data[idx] = [];
|
|
15477
15507
|
for (let i = 0; i < kw.length; i++) {
|
|
15478
15508
|
data[0].push(kw[i][tm]);
|
|
15479
|
-
for (let idx = 1; idx < uplot
|
|
15480
|
-
let serie = uplot
|
|
15509
|
+
for (let idx = 1; idx < uplot.series.length; idx++) {
|
|
15510
|
+
let serie = uplot.series[idx];
|
|
15481
15511
|
let value = kw[i][serie.id];
|
|
15482
15512
|
if ((0, _yuneta_gobj_js.is_string)(value)) {
|
|
15483
15513
|
if (value.toLowerCase() === "on") value = 1;
|
|
@@ -15490,20 +15520,20 @@ function ac_load_data$2(gobj, event, kw, src) {
|
|
|
15490
15520
|
data[idx].push(value);
|
|
15491
15521
|
}
|
|
15492
15522
|
}
|
|
15493
|
-
uplot
|
|
15494
|
-
Array.from(uplot
|
|
15523
|
+
uplot.setData(data);
|
|
15524
|
+
Array.from(uplot.root.querySelectorAll(".cursor-pt")).forEach(function(pt, i) {
|
|
15495
15525
|
pt.onclick = function(e) {
|
|
15496
15526
|
let seriesIdx = i + 1;
|
|
15497
|
-
let dataIdx = uplot
|
|
15498
|
-
let xVal = uplot
|
|
15499
|
-
let yVal = uplot
|
|
15500
|
-
let xPos = uplot
|
|
15501
|
-
let yPos = uplot
|
|
15527
|
+
let dataIdx = uplot.cursor.idx;
|
|
15528
|
+
let xVal = uplot.data[0][dataIdx];
|
|
15529
|
+
let yVal = uplot.data[seriesIdx][dataIdx];
|
|
15530
|
+
let xPos = uplot.valToPos(xVal, "x");
|
|
15531
|
+
let yPos = uplot.valToPos(yVal, "y");
|
|
15502
15532
|
let heart = document.createElement("div");
|
|
15503
15533
|
heart.classList.add("heart");
|
|
15504
15534
|
heart.style.left = xPos + "px";
|
|
15505
15535
|
heart.style.top = yPos + "px";
|
|
15506
|
-
uplot
|
|
15536
|
+
uplot.root.querySelector(".over").appendChild(heart);
|
|
15507
15537
|
};
|
|
15508
15538
|
});
|
|
15509
15539
|
return 0;
|
|
@@ -15512,10 +15542,10 @@ function ac_load_data$2(gobj, event, kw, src) {
|
|
|
15512
15542
|
*
|
|
15513
15543
|
******************************************************/
|
|
15514
15544
|
function ac_add_serie(gobj, event, kw, src) {
|
|
15515
|
-
let uplot
|
|
15545
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15516
15546
|
let idx = 0;
|
|
15517
|
-
for (; idx < uplot
|
|
15518
|
-
let serie = uplot
|
|
15547
|
+
for (; idx < uplot.series.length; idx++) {
|
|
15548
|
+
let serie = uplot.series[idx];
|
|
15519
15549
|
if (serie.id && serie.id === kw.id) {
|
|
15520
15550
|
(0, _yuneta_gobj_js.log_error)("Serie '" + kw.id + "' already exists");
|
|
15521
15551
|
return -1;
|
|
@@ -15526,7 +15556,7 @@ function ac_add_serie(gobj, event, kw, src) {
|
|
|
15526
15556
|
let color = colors[Math.max(0, idx - 1) % colors.length];
|
|
15527
15557
|
if (kw.stroke === void 0) kw.stroke = color.stroke;
|
|
15528
15558
|
if (kw.fill === void 0) kw.fill = color.fill;
|
|
15529
|
-
uplot
|
|
15559
|
+
uplot.addSeries(kw);
|
|
15530
15560
|
return 0;
|
|
15531
15561
|
}
|
|
15532
15562
|
/******************************************************
|
|
@@ -15534,10 +15564,10 @@ function ac_add_serie(gobj, event, kw, src) {
|
|
|
15534
15564
|
* one already, the canvas is what has to be painted again.
|
|
15535
15565
|
******************************************************/
|
|
15536
15566
|
function ac_theme$4(gobj, event, kw, src) {
|
|
15537
|
-
let uplot
|
|
15538
|
-
if (!uplot
|
|
15567
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15568
|
+
if (!uplot) return 0;
|
|
15539
15569
|
try {
|
|
15540
|
-
uplot
|
|
15570
|
+
uplot.redraw();
|
|
15541
15571
|
} catch (e) {
|
|
15542
15572
|
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot redraw the chart: ${e}`);
|
|
15543
15573
|
}
|
|
@@ -15549,11 +15579,11 @@ function ac_theme$4(gobj, event, kw, src) {
|
|
|
15549
15579
|
* so they are written again.
|
|
15550
15580
|
******************************************************/
|
|
15551
15581
|
function ac_language_changed$9(gobj, event, kw, src) {
|
|
15552
|
-
let uplot
|
|
15553
|
-
if (!uplot
|
|
15582
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15583
|
+
if (!uplot) return 0;
|
|
15554
15584
|
try {
|
|
15555
|
-
uplot
|
|
15556
|
-
uplot
|
|
15585
|
+
uplot.redraw(true, true);
|
|
15586
|
+
uplot.setLegend(null, false);
|
|
15557
15587
|
} catch (e) {
|
|
15558
15588
|
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot redraw the chart: ${e}`);
|
|
15559
15589
|
}
|
|
@@ -15563,14 +15593,14 @@ function ac_language_changed$9(gobj, event, kw, src) {
|
|
|
15563
15593
|
*
|
|
15564
15594
|
******************************************************/
|
|
15565
15595
|
function ac_del_serie(gobj, event, kw, src) {
|
|
15566
|
-
let uplot
|
|
15567
|
-
for (let idx = 1; idx < uplot
|
|
15568
|
-
let serie = uplot
|
|
15596
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15597
|
+
for (let idx = 1; idx < uplot.series.length; idx++) {
|
|
15598
|
+
let serie = uplot.series[idx];
|
|
15569
15599
|
if (serie.id && serie.id === kw.id) {
|
|
15570
|
-
uplot
|
|
15571
|
-
let data = uplot
|
|
15600
|
+
uplot.delSeries(idx);
|
|
15601
|
+
let data = uplot.data.splice(idx, 1);
|
|
15572
15602
|
if (data.length === 1) data = [[]];
|
|
15573
|
-
uplot
|
|
15603
|
+
uplot.setData(data);
|
|
15574
15604
|
return 0;
|
|
15575
15605
|
}
|
|
15576
15606
|
}
|
|
@@ -15580,9 +15610,9 @@ function ac_del_serie(gobj, event, kw, src) {
|
|
|
15580
15610
|
*
|
|
15581
15611
|
******************************************************/
|
|
15582
15612
|
function ac_clear$1(gobj, event, kw, src) {
|
|
15583
|
-
let uplot
|
|
15584
|
-
uplot
|
|
15585
|
-
for (let idx = uplot
|
|
15613
|
+
let uplot = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "uplot");
|
|
15614
|
+
uplot.setData([[]]);
|
|
15615
|
+
for (let idx = uplot.series.length - 1; idx > 0; idx--) uplot.delSeries(idx);
|
|
15586
15616
|
return 0;
|
|
15587
15617
|
}
|
|
15588
15618
|
/***************************
|
|
@@ -55017,10 +55047,10 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
55017
55047
|
* @author AntVis
|
|
55018
55048
|
* @docs https://g.antv.antgroup.com/
|
|
55019
55049
|
*/
|
|
55020
|
-
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
55050
|
+
(/* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
|
|
55021
55051
|
(function(global, factory) {
|
|
55022
55052
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.html2canvas = factory());
|
|
55023
|
-
})(
|
|
55053
|
+
})(this$1, (function() {
|
|
55024
55054
|
"use strict";
|
|
55025
55055
|
var extendStatics = function(d, b) {
|
|
55026
55056
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
@@ -83234,11 +83264,7 @@ function tr(t, key, params) {
|
|
|
83234
83264
|
* the library has no business owning.
|
|
83235
83265
|
***************************************************************/
|
|
83236
83266
|
function fmt_intl(date, locale, opts) {
|
|
83237
|
-
|
|
83238
|
-
return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
|
|
83239
|
-
} catch (e) {
|
|
83240
|
-
return date.toDateString();
|
|
83241
|
-
}
|
|
83267
|
+
return date_time_format(locale, opts).format(date);
|
|
83242
83268
|
}
|
|
83243
83269
|
/***************************
|
|
83244
83270
|
* Epoch <-> clock
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -13,7 +13,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
13
13
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
14
|
var __getProtoOf = Object.getPrototypeOf;
|
|
15
15
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
16
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
17
17
|
var __exportAll = (all, no_symbols) => {
|
|
18
18
|
let target = {};
|
|
19
19
|
for (var name in all) __defProp(target, name, {
|
|
@@ -9707,6 +9707,28 @@ function safe_locale(locale) {
|
|
|
9707
9707
|
if (typeof nav === "string" && nav && nav !== "undefined") return nav;
|
|
9708
9708
|
return "en";
|
|
9709
9709
|
}
|
|
9710
|
+
var __refused_locales__ = /* @__PURE__ */ new Set();
|
|
9711
|
+
/***************************************************************
|
|
9712
|
+
* An Intl.DateTimeFormat of `locale` with `options`. A locale
|
|
9713
|
+
* Intl refuses (a malformed tag: "en_US") falls back to the
|
|
9714
|
+
* environment's -- what Intl itself gives for a well-formed
|
|
9715
|
+
* one it does not know ("xx") -- and is said in a WARNING, once
|
|
9716
|
+
* per locale. fmt_date_time() and the ticks of a uPlot time axis
|
|
9717
|
+
* (yui_uplot_time.js) both go through it, so they fall back the
|
|
9718
|
+
* same way.
|
|
9719
|
+
***************************************************************/
|
|
9720
|
+
function date_time_format(locale, options) {
|
|
9721
|
+
let loc = safe_locale(locale);
|
|
9722
|
+
try {
|
|
9723
|
+
return new Intl.DateTimeFormat(loc, options);
|
|
9724
|
+
} catch (e) {
|
|
9725
|
+
if (!__refused_locales__.has(loc)) {
|
|
9726
|
+
__refused_locales__.add(loc);
|
|
9727
|
+
log_warning(`date_time_format: locale '${loc}' refused by Intl (${e}), using the environment's`);
|
|
9728
|
+
}
|
|
9729
|
+
return new Intl.DateTimeFormat(void 0, options);
|
|
9730
|
+
}
|
|
9731
|
+
}
|
|
9710
9732
|
var DATE_TIME_OPTIONS = {
|
|
9711
9733
|
day: "numeric",
|
|
9712
9734
|
month: "short",
|
|
@@ -9726,7 +9748,7 @@ var DATE_TIME_OPTIONS = {
|
|
|
9726
9748
|
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
9727
9749
|
*
|
|
9728
9750
|
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
9729
|
-
*
|
|
9751
|
+
* writes in the environment's (date_time_format).
|
|
9730
9752
|
*
|
|
9731
9753
|
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
9732
9754
|
* the reading C_YUI_JSON writes beside a time field all come from
|
|
@@ -9734,12 +9756,7 @@ var DATE_TIME_OPTIONS = {
|
|
|
9734
9756
|
***************************************************************/
|
|
9735
9757
|
function fmt_date_time(date, locale) {
|
|
9736
9758
|
if (!(date instanceof Date) || isNaN(date.getTime())) return "";
|
|
9737
|
-
|
|
9738
|
-
return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
|
|
9739
|
-
} catch (e) {
|
|
9740
|
-
let pad = (n) => String(n).padStart(2, "0");
|
|
9741
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
9742
|
-
}
|
|
9759
|
+
return date_time_format(locale, DATE_TIME_OPTIONS).format(date);
|
|
9743
9760
|
}
|
|
9744
9761
|
/************************************************************
|
|
9745
9762
|
* JSON type discriminator (viewer vocabulary)
|
|
@@ -10321,7 +10338,8 @@ function form_time_cell_editor(real_type) {
|
|
|
10321
10338
|
/****************************************************************************
|
|
10322
10339
|
* yui_tabulator_edit.js
|
|
10323
10340
|
*
|
|
10324
|
-
* An open cell editor survives a FORCED redraw of its table
|
|
10341
|
+
* An open cell editor survives a FORCED redraw of its table,
|
|
10342
|
+
* and the other calls that build its cells again.
|
|
10325
10343
|
*
|
|
10326
10344
|
* `table.redraw(true)` builds every row's cells again, the one
|
|
10327
10345
|
* being edited too, and leaves Tabulator's edit pointing at the
|
|
@@ -10336,7 +10354,12 @@ function form_time_cell_editor(real_type) {
|
|
|
10336
10354
|
* does not blur, and throws at the next edit. Any editor, ours
|
|
10337
10355
|
* (form_time_cell_editor.js) or Tabulator's own.
|
|
10338
10356
|
*
|
|
10339
|
-
*
|
|
10357
|
+
* `setColumns()` (a language change of
|
|
10358
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM runs it) and `setHeight`,
|
|
10359
|
+
* `setMaxHeight` and `setMinHeight` build the cells again the
|
|
10360
|
+
* same way, and Tabulator throws the same.
|
|
10361
|
+
*
|
|
10362
|
+
* So the edit is ended BEFORE each of those calls, while its cell
|
|
10340
10363
|
* is alive, and opened again on the new cell of the same row
|
|
10341
10364
|
* and column after it. What was typed in the box is lost; the
|
|
10342
10365
|
* editor stays open under the reader.
|
|
@@ -10345,8 +10368,10 @@ function form_time_cell_editor(real_type) {
|
|
|
10345
10368
|
* All Rights Reserved.
|
|
10346
10369
|
****************************************************************************/
|
|
10347
10370
|
/************************************************************
|
|
10348
|
-
* Wrap `tabulator
|
|
10349
|
-
*
|
|
10371
|
+
* Wrap the calls of `tabulator` that build the cells again --
|
|
10372
|
+
* a forced `redraw`, `setColumns` and the three height setters
|
|
10373
|
+
* -- so that each ends the open edit first and opens it again
|
|
10374
|
+
* after.
|
|
10350
10375
|
************************************************************/
|
|
10351
10376
|
function yui_tabulator_keep_edit_on_redraw(tabulator) {
|
|
10352
10377
|
let editing = null;
|
|
@@ -10359,23 +10384,32 @@ function yui_tabulator_keep_edit_on_redraw(tabulator) {
|
|
|
10359
10384
|
tabulator.on("cellEditCancelled", function() {
|
|
10360
10385
|
editing = null;
|
|
10361
10386
|
});
|
|
10362
|
-
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10387
|
+
function keep_edit_around(name, rebuilds) {
|
|
10388
|
+
let original = tabulator[name].bind(tabulator);
|
|
10389
|
+
tabulator[name] = function(...args) {
|
|
10390
|
+
let cell = editing;
|
|
10391
|
+
let $cell = cell ? cell.getElement() : null;
|
|
10392
|
+
if (!rebuilds(args) || !$cell || !$cell.classList.contains("tabulator-editing")) return original(...args);
|
|
10393
|
+
let row = cell.getRow();
|
|
10394
|
+
let field = cell.getField();
|
|
10395
|
+
cell.cancelEdit();
|
|
10396
|
+
let ret = original(...args);
|
|
10397
|
+
let again = row.getCell(field);
|
|
10398
|
+
if (!again) {
|
|
10399
|
+
log_warning(`yui_tabulator_keep_edit_on_redraw: no cell '${field}' after ${name}()`);
|
|
10400
|
+
return ret;
|
|
10401
|
+
}
|
|
10402
|
+
again.edit(true);
|
|
10374
10403
|
return ret;
|
|
10375
|
-
}
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10404
|
+
};
|
|
10405
|
+
}
|
|
10406
|
+
keep_edit_around("redraw", (args) => !!args[0]);
|
|
10407
|
+
for (const name of [
|
|
10408
|
+
"setColumns",
|
|
10409
|
+
"setHeight",
|
|
10410
|
+
"setMaxHeight",
|
|
10411
|
+
"setMinHeight"
|
|
10412
|
+
]) keep_edit_around(name, () => true);
|
|
10379
10413
|
}
|
|
10380
10414
|
//#endregion
|
|
10381
10415
|
//#region src/form_json_field.js
|
|
@@ -13293,10 +13327,10 @@ function set_form_values(gobj, template, $form, record) {
|
|
|
13293
13327
|
switch (input_type) {
|
|
13294
13328
|
case "datetime-local":
|
|
13295
13329
|
$input.value = date_to_datetime_local(value);
|
|
13296
|
-
$input.yui_time_kept = {
|
|
13330
|
+
$input.yui_time_kept = $input.value !== "" ? {
|
|
13297
13331
|
value: stored,
|
|
13298
13332
|
shown: $input.value
|
|
13299
|
-
};
|
|
13333
|
+
} : null;
|
|
13300
13334
|
break;
|
|
13301
13335
|
case "color":
|
|
13302
13336
|
$input.value = convertColor(value);
|
|
@@ -15212,11 +15246,7 @@ function intl(locale, opts) {
|
|
|
15212
15246
|
let key = locale + "|" + JSON.stringify(opts);
|
|
15213
15247
|
let f = __formatters__.get(key);
|
|
15214
15248
|
if (!f) {
|
|
15215
|
-
|
|
15216
|
-
f = new Intl.DateTimeFormat(locale, opts);
|
|
15217
|
-
} catch (e) {
|
|
15218
|
-
f = new Intl.DateTimeFormat("en", opts);
|
|
15219
|
-
}
|
|
15249
|
+
f = date_time_format(locale, opts);
|
|
15220
15250
|
__formatters__.set(key, f);
|
|
15221
15251
|
}
|
|
15222
15252
|
return f;
|
|
@@ -55012,10 +55042,10 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
55012
55042
|
* @author AntVis
|
|
55013
55043
|
* @docs https://g.antv.antgroup.com/
|
|
55014
55044
|
*/
|
|
55015
|
-
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
55045
|
+
(/* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
|
|
55016
55046
|
(function(global, factory) {
|
|
55017
55047
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.html2canvas = factory());
|
|
55018
|
-
})(
|
|
55048
|
+
})(this$1, (function() {
|
|
55019
55049
|
"use strict";
|
|
55020
55050
|
var extendStatics = function(d, b) {
|
|
55021
55051
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
@@ -83229,11 +83259,7 @@ function tr(t, key, params) {
|
|
|
83229
83259
|
* the library has no business owning.
|
|
83230
83260
|
***************************************************************/
|
|
83231
83261
|
function fmt_intl(date, locale, opts) {
|
|
83232
|
-
|
|
83233
|
-
return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
|
|
83234
|
-
} catch (e) {
|
|
83235
|
-
return date.toDateString();
|
|
83236
|
-
}
|
|
83262
|
+
return date_time_format(locale, opts).format(date);
|
|
83237
83263
|
}
|
|
83238
83264
|
/***************************
|
|
83239
83265
|
* Epoch <-> clock
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuneta/gobj-ui",
|
|
3
|
-
"version": "7.26.
|
|
3
|
+
"version": "7.26.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/gobj-ui.cjs.js",
|
|
6
6
|
"module": "dist/gobj-ui.es.js",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"@rollup/plugin-terser": "^1.0.0",
|
|
42
42
|
"@vitest/coverage-v8": "^4.1.10",
|
|
43
43
|
"@yuneta/gobj-js": "^7.26.28",
|
|
44
|
-
"vite": "^8.3.
|
|
44
|
+
"vite": "^8.3.4",
|
|
45
45
|
"vitest": "^4.1.10"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@antv/g6": "^5.1.0",
|
|
49
49
|
"@yuneta/gobj-js": "^7.26.3",
|
|
50
50
|
"bulma": "^1.0.4",
|
|
51
|
-
"i18next": "^26.
|
|
52
|
-
"maplibre-gl": "^6.
|
|
51
|
+
"i18next": "^26.4.5",
|
|
52
|
+
"maplibre-gl": "^6.14.0",
|
|
53
53
|
"tabulator-tables": "^6.5.3",
|
|
54
54
|
"tom-select": "^2.6.2",
|
|
55
55
|
"uplot": "^1.6.32",
|
|
@@ -341,6 +341,7 @@
|
|
|
341
341
|
***********************************************************************/
|
|
342
342
|
import {readdirSync, readFileSync, existsSync, statSync, realpathSync} from "fs";
|
|
343
343
|
import {spawnSync} from "child_process";
|
|
344
|
+
import {randomBytes} from "crypto";
|
|
344
345
|
import {resolve, relative} from "path";
|
|
345
346
|
import {pathToFileURL, fileURLToPath} from "url";
|
|
346
347
|
import {I18N_KEY_FUNCTIONS} from "../src/i18n_key_functions.js";
|
|
@@ -581,6 +582,13 @@ function load_locales(locales_dir)
|
|
|
581
582
|
* in the locales' process, is a violation; that process ending
|
|
582
583
|
* before its report, or not reporting in LOCALES_TIMEOUT_MS, aborts
|
|
583
584
|
* the run: no language could be checked.
|
|
585
|
+
*
|
|
586
|
+
* The report must carry a nonce the process reads on its stdin
|
|
587
|
+
* before it imports any locale, so a report a locale writes to the
|
|
588
|
+
* channel itself is refused (up to gobj-ui 7.26.54 it was the
|
|
589
|
+
* verdict). This stops accidents and the shapes named here, not
|
|
590
|
+
* deliberate malice: a locale is the app's own code, and the
|
|
591
|
+
* process is no sandbox.
|
|
584
592
|
***************************************************************/
|
|
585
593
|
const LOCALES_TIMEOUT_MS = 60000;
|
|
586
594
|
|
|
@@ -590,9 +598,11 @@ function import_locales(locales_dir, codes)
|
|
|
590
598
|
dir: locales_dir.href,
|
|
591
599
|
codes: codes.map((code) => [code, locale_export_names(code)])
|
|
592
600
|
});
|
|
601
|
+
let nonce = randomBytes(16).toString("hex");
|
|
593
602
|
let r = spawnSync(process.execPath,
|
|
594
603
|
[...process.execArgv, "-e", `(${report_locales.toString()})(${request});`], {
|
|
595
|
-
|
|
604
|
+
input: nonce,
|
|
605
|
+
stdio: ["pipe", "inherit", "inherit", "pipe"],
|
|
596
606
|
timeout: LOCALES_TIMEOUT_MS,
|
|
597
607
|
killSignal: "SIGKILL",
|
|
598
608
|
maxBuffer: 1 << 30
|
|
@@ -615,7 +625,8 @@ function import_locales(locales_dir, codes)
|
|
|
615
625
|
report = null;
|
|
616
626
|
}
|
|
617
627
|
}
|
|
618
|
-
if(r.status !== 0 || !report ||
|
|
628
|
+
if(r.status !== 0 || !report || report.nonce !== nonce ||
|
|
629
|
+
typeof report.locales !== "object" || !Array.isArray(report.problems)) {
|
|
619
630
|
let how = r.signal? `killed by ${r.signal}` : `exit code ${r.status}`;
|
|
620
631
|
abort(`${AT} ended (${how}) before it reported what they export` +
|
|
621
632
|
`${text? ", or reported what is not its report" : ""}: ${WHY} (a top-level await that ` +
|
|
@@ -635,9 +646,12 @@ function import_locales(locales_dir, codes)
|
|
|
635
646
|
/***************************************************************
|
|
636
647
|
* The code of the locales' process (import_locales()), run there
|
|
637
648
|
* from its text: it can use nothing of this module but its
|
|
638
|
-
* argument. What it calls after the
|
|
639
|
-
* them, so a locale that replaces
|
|
640
|
-
* JSON.stringify does not reach the report
|
|
649
|
+
* argument and the nonce on its stdin. What it calls after the
|
|
650
|
+
* locales ran is taken BEFORE them, so a locale that replaces
|
|
651
|
+
* process.reallyExit or JSON.stringify does not reach the report,
|
|
652
|
+
* and the report is written by hand from strings (JSON.stringify of
|
|
653
|
+
* a primitive string reads no toJSON): a toJSON a locale puts on
|
|
654
|
+
* Object.prototype or Array.prototype is never called. It reports after a
|
|
641
655
|
* timer of 0 and an immediate: a promise a locale rejects in such
|
|
642
656
|
* a timer, with nothing to handle it, is told first. Its own end is
|
|
643
657
|
* process.reallyExit(0): no exit handler of a locale runs, and a
|
|
@@ -645,47 +659,75 @@ function import_locales(locales_dir, codes)
|
|
|
645
659
|
***************************************************************/
|
|
646
660
|
async function report_locales(request)
|
|
647
661
|
{
|
|
648
|
-
const {writeSync} = await import("node:fs");
|
|
662
|
+
const {writeSync, readFileSync} = await import("node:fs");
|
|
663
|
+
const nonce = readFileSync(0, "utf8");
|
|
649
664
|
const really_exit = process.reallyExit.bind(process);
|
|
650
665
|
const stringify = JSON.stringify;
|
|
651
666
|
const keys_of = Object.keys;
|
|
652
667
|
const set_timeout = setTimeout;
|
|
653
668
|
const set_immediate = setImmediate;
|
|
654
669
|
const buffer_from = Buffer.from.bind(Buffer);
|
|
670
|
+
const define = Object.defineProperty;
|
|
671
|
+
const has_own = Object.hasOwn;
|
|
655
672
|
const problems = [];
|
|
673
|
+
const add_problem = (text) => {
|
|
674
|
+
define(problems, problems.length, {value: String(text), enumerable: true});
|
|
675
|
+
};
|
|
676
|
+
const list_text = (list) => {
|
|
677
|
+
let text = "[";
|
|
678
|
+
for(let i = 0; i < list.length; i++) {
|
|
679
|
+
text += (i? "," : "") + stringify(String(list[i]));
|
|
680
|
+
}
|
|
681
|
+
return text + "]";
|
|
682
|
+
};
|
|
656
683
|
process.on("unhandledRejection", (reason) => {
|
|
657
|
-
|
|
684
|
+
add_problem(`a promise was rejected and nothing handled it: ${(reason && reason.stack) || reason}`);
|
|
658
685
|
});
|
|
659
686
|
process.on("uncaughtException", (e) => {
|
|
660
|
-
|
|
687
|
+
add_problem(`an exception was thrown and nothing caught it: ${(e && e.stack) || e}`);
|
|
661
688
|
});
|
|
662
689
|
const locales = {};
|
|
663
|
-
|
|
690
|
+
const set_locale = (code, value) => {
|
|
691
|
+
define(locales, code, {value, enumerable: true});
|
|
692
|
+
};
|
|
693
|
+
for(let c = 0; c < request.codes.length; c++) {
|
|
694
|
+
const code = request.codes[c][0];
|
|
695
|
+
const names = request.codes[c][1];
|
|
664
696
|
try {
|
|
665
697
|
const mod = await import(new URL(`${code}.js`, request.dir).href);
|
|
666
698
|
let locale = null;
|
|
667
|
-
for(
|
|
668
|
-
if(mod[
|
|
669
|
-
locale = mod[
|
|
699
|
+
for(let n = 0; n < names.length; n++) {
|
|
700
|
+
if(mod[names[n]]) {
|
|
701
|
+
locale = mod[names[n]];
|
|
670
702
|
break;
|
|
671
703
|
}
|
|
672
704
|
}
|
|
673
705
|
locale = locale || mod.default;
|
|
674
706
|
if(!locale || !locale.translation || typeof locale.translation !== "object") {
|
|
675
|
-
|
|
707
|
+
set_locale(code, {none: true});
|
|
676
708
|
} else {
|
|
677
|
-
|
|
709
|
+
set_locale(code, {
|
|
678
710
|
keys: keys_of(locale.translation),
|
|
679
711
|
name: (typeof locale.name === "string" && locale.name)? locale.name : null
|
|
680
|
-
};
|
|
712
|
+
});
|
|
681
713
|
}
|
|
682
714
|
} catch(e) {
|
|
683
|
-
|
|
715
|
+
set_locale(code, {error: String((e && e.message) || e)});
|
|
684
716
|
}
|
|
685
717
|
}
|
|
686
718
|
set_timeout(() => {
|
|
687
719
|
set_immediate(() => {
|
|
688
|
-
|
|
720
|
+
let text = `{"nonce":${stringify(nonce)},"problems":${list_text(problems)},"locales":{`;
|
|
721
|
+
for(let i = 0; i < request.codes.length; i++) {
|
|
722
|
+
const code = request.codes[i][0];
|
|
723
|
+
const one = locales[code];
|
|
724
|
+
text += (i? "," : "") + stringify(code) + ":" + (
|
|
725
|
+
has_own(one, "none")? `{"none":true}` :
|
|
726
|
+
has_own(one, "error")? `{"error":${stringify(one.error)}}` :
|
|
727
|
+
`{"keys":${list_text(one.keys)},"name":${one.name === null? "null" : stringify(one.name)}}`
|
|
728
|
+
);
|
|
729
|
+
}
|
|
730
|
+
const buf = buffer_from(text + "}}\n", "utf8");
|
|
689
731
|
let done = 0;
|
|
690
732
|
while(done < buf.length) {
|
|
691
733
|
done += writeSync(3, buf, done, buf.length - done);
|
package/src/c_yui_form.js
CHANGED
|
@@ -3526,9 +3526,11 @@ function set_form_values(gobj, template, $form, record)
|
|
|
3526
3526
|
/* value is a Date (see treedb_value_2_form_value).
|
|
3527
3527
|
* The text kept is the one READ BACK: the browser
|
|
3528
3528
|
* drops seconds of :00, so the text written never
|
|
3529
|
-
* matches it (get_form_values).
|
|
3529
|
+
* matches it (get_form_values). An empty box keeps
|
|
3530
|
+
* nothing: it is no time, whatever was stored. */
|
|
3530
3531
|
$input.value = date_to_datetime_local(value);
|
|
3531
|
-
$input.yui_time_kept =
|
|
3532
|
+
$input.yui_time_kept = ($input.value !== "")?
|
|
3533
|
+
{value: stored, shown: $input.value} : null;
|
|
3532
3534
|
break;
|
|
3533
3535
|
case "color":
|
|
3534
3536
|
$input.value = convertColor(value);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* All Rights Reserved.
|
|
13
13
|
***********************************************************************/
|
|
14
14
|
import {describe, test, expect} from "vitest";
|
|
15
|
+
import {set_log_callback} from "@yuneta/gobj-js";
|
|
15
16
|
import {fmt_date_time, safe_locale} from "./yui_time.js";
|
|
16
17
|
import {time_value_to_text} from "./form_time_value.js";
|
|
17
18
|
import {format_epoch} from "./json_view_helpers.js";
|
|
@@ -72,8 +73,36 @@ describe("fmt_date_time", () => {
|
|
|
72
73
|
expect(fmt_date_time(D, "")).toBe(fallback);
|
|
73
74
|
});
|
|
74
75
|
|
|
75
|
-
test("a locale Intl refuses
|
|
76
|
-
|
|
76
|
+
test("a locale Intl refuses writes in the environment's, as one it does not know, and says so once", () => {
|
|
77
|
+
const warnings = [];
|
|
78
|
+
set_log_callback((level, msg) => {
|
|
79
|
+
if(String(level) === "warning" && /date_time_format/.test(String(msg))) {
|
|
80
|
+
warnings.push(String(msg));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
const env = fmt_date_time(D, "xx"); /* well-formed, unknown: Intl's own fallback */
|
|
85
|
+
expect(env).toBe(new Intl.DateTimeFormat(undefined, {
|
|
86
|
+
day: "numeric", month: "short", year: "numeric",
|
|
87
|
+
hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23"
|
|
88
|
+
}).format(D));
|
|
89
|
+
expect(warnings).toEqual([]);
|
|
90
|
+
expect(fmt_date_time(D, "xx_YY")).toBe(env);
|
|
91
|
+
expect(fmt_date_time(D, "xx_YY")).toBe(env);
|
|
92
|
+
expect(fmt_date_time(D, "zz_ZZ")).toBe(env);
|
|
93
|
+
expect(warnings.length).toBe(2);
|
|
94
|
+
expect(warnings[0]).toMatch(/'xx_YY'/);
|
|
95
|
+
expect(warnings[1]).toMatch(/'zz_ZZ'/);
|
|
96
|
+
|
|
97
|
+
/* The axis of a chart falls back the same way, and says it once. */
|
|
98
|
+
const month = yui_uplot_fmt_date(() => "yy_QQ")("{MMM}");
|
|
99
|
+
expect(month(D)).toBe(new Intl.DateTimeFormat(undefined, {month: "short"}).format(D));
|
|
100
|
+
expect(month(D)).toBe(new Intl.DateTimeFormat(undefined, {month: "short"}).format(D));
|
|
101
|
+
expect(warnings.length).toBe(3);
|
|
102
|
+
expect(warnings[2]).toMatch(/'yy_QQ'/);
|
|
103
|
+
} finally {
|
|
104
|
+
set_log_callback(null);
|
|
105
|
+
}
|
|
77
106
|
});
|
|
78
107
|
});
|
|
79
108
|
|
|
@@ -314,3 +314,31 @@ describe("a time in the repeated hour of autumn, saved with nothing touched", ()
|
|
|
314
314
|
});
|
|
315
315
|
});
|
|
316
316
|
});
|
|
317
|
+
|
|
318
|
+
describe("a stored value the box cannot show", () => {
|
|
319
|
+
test("is not saved back from the empty box: an empty box is no time", () => {
|
|
320
|
+
const app = gobj_create_pure_child("tapp6", "C_TEST_TIME_APP", {}, yuno);
|
|
321
|
+
gobj_start(app);
|
|
322
|
+
const form = gobj_create_pure_child("tform6", "C_YUI_FORM", {
|
|
323
|
+
template: {
|
|
324
|
+
as_epoch: {type: "integer", flag: ["writable", "persistent", "time"]},
|
|
325
|
+
as_text: {type: "string", flag: ["writable", "persistent", "time"]},
|
|
326
|
+
},
|
|
327
|
+
record: {as_epoch: "rubbish", as_text: "rubbish"},
|
|
328
|
+
editable: true,
|
|
329
|
+
}, app);
|
|
330
|
+
gobj_start(form);
|
|
331
|
+
|
|
332
|
+
expect(box(form, "as_epoch").value).toBe("");
|
|
333
|
+
expect(box(form, "as_text").value).toBe("");
|
|
334
|
+
gobj_send_event(form, "EV_SAVE_RECORD", {}, form);
|
|
335
|
+
expect(saved[0].as_epoch).toBe(null);
|
|
336
|
+
expect(saved[0].as_text).toBe(null);
|
|
337
|
+
|
|
338
|
+
/* A date typed and cleared again: the box is empty too. */
|
|
339
|
+
box(form, "as_epoch").value = WALL;
|
|
340
|
+
box(form, "as_epoch").value = "";
|
|
341
|
+
gobj_send_event(form, "EV_SAVE_RECORD", {}, form);
|
|
342
|
+
expect(saved[1].as_epoch).toBe(null);
|
|
343
|
+
});
|
|
344
|
+
});
|
package/src/yui_date_text.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* Copyright (c) 2026, ArtGins.
|
|
13
13
|
* All Rights Reserved.
|
|
14
14
|
***********************************************************************/
|
|
15
|
+
import {log_warning} from "@yuneta/gobj-js";
|
|
15
16
|
|
|
16
17
|
/***************************************************************
|
|
17
18
|
* The locale to format with.
|
|
@@ -34,6 +35,32 @@ function safe_locale(locale)
|
|
|
34
35
|
return "en";
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/* The locales Intl refused, said once each. */
|
|
39
|
+
const __refused_locales__ = new Set();
|
|
40
|
+
|
|
41
|
+
/***************************************************************
|
|
42
|
+
* An Intl.DateTimeFormat of `locale` with `options`. A locale
|
|
43
|
+
* Intl refuses (a malformed tag: "en_US") falls back to the
|
|
44
|
+
* environment's -- what Intl itself gives for a well-formed
|
|
45
|
+
* one it does not know ("xx") -- and is said in a WARNING, once
|
|
46
|
+
* per locale. fmt_date_time() and the ticks of a uPlot time axis
|
|
47
|
+
* (yui_uplot_time.js) both go through it, so they fall back the
|
|
48
|
+
* same way.
|
|
49
|
+
***************************************************************/
|
|
50
|
+
function date_time_format(locale, options)
|
|
51
|
+
{
|
|
52
|
+
let loc = safe_locale(locale);
|
|
53
|
+
try {
|
|
54
|
+
return new Intl.DateTimeFormat(loc, options);
|
|
55
|
+
} catch(e) {
|
|
56
|
+
if(!__refused_locales__.has(loc)) {
|
|
57
|
+
__refused_locales__.add(loc);
|
|
58
|
+
log_warning(`date_time_format: locale '${loc}' refused by Intl (${e}), using the environment's`);
|
|
59
|
+
}
|
|
60
|
+
return new Intl.DateTimeFormat(undefined, options);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
37
64
|
/* The clock is always 24 hours: `hourCycle`, never `hour12: false`,
|
|
38
65
|
* which some engines read as "h24" and show midnight as 24:00:00. */
|
|
39
66
|
const DATE_TIME_OPTIONS = {
|
|
@@ -52,7 +79,7 @@ const DATE_TIME_OPTIONS = {
|
|
|
52
79
|
* fmt_date_time(d, "en") -> "Oct 14, 2026, 15:05:09"
|
|
53
80
|
*
|
|
54
81
|
* "" for anything that is not a valid Date. A locale Intl refuses
|
|
55
|
-
*
|
|
82
|
+
* writes in the environment's (date_time_format).
|
|
56
83
|
*
|
|
57
84
|
* The time cells of C_YUI_FORM and C_YUI_TREEDB_TOPIC_WITH_FORM and
|
|
58
85
|
* the reading C_YUI_JSON writes beside a time field all come from
|
|
@@ -63,13 +90,7 @@ function fmt_date_time(date, locale)
|
|
|
63
90
|
if(!(date instanceof Date) || isNaN(date.getTime())) {
|
|
64
91
|
return "";
|
|
65
92
|
}
|
|
66
|
-
|
|
67
|
-
return new Intl.DateTimeFormat(safe_locale(locale), DATE_TIME_OPTIONS).format(date);
|
|
68
|
-
} catch(e) {
|
|
69
|
-
let pad = (n) => String(n).padStart(2, "0");
|
|
70
|
-
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
|
|
71
|
-
`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
72
|
-
}
|
|
93
|
+
return date_time_format(locale, DATE_TIME_OPTIONS).format(date);
|
|
73
94
|
}
|
|
74
95
|
|
|
75
96
|
|
|
@@ -78,5 +99,6 @@ function fmt_date_time(date, locale)
|
|
|
78
99
|
***************************************************************/
|
|
79
100
|
export {
|
|
80
101
|
safe_locale,
|
|
102
|
+
date_time_format,
|
|
81
103
|
fmt_date_time,
|
|
82
104
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/****************************************************************************
|
|
2
2
|
* yui_tabulator_edit.js
|
|
3
3
|
*
|
|
4
|
-
* An open cell editor survives a FORCED redraw of its table
|
|
4
|
+
* An open cell editor survives a FORCED redraw of its table,
|
|
5
|
+
* and the other calls that build its cells again.
|
|
5
6
|
*
|
|
6
7
|
* `table.redraw(true)` builds every row's cells again, the one
|
|
7
8
|
* being edited too, and leaves Tabulator's edit pointing at the
|
|
@@ -16,7 +17,12 @@
|
|
|
16
17
|
* does not blur, and throws at the next edit. Any editor, ours
|
|
17
18
|
* (form_time_cell_editor.js) or Tabulator's own.
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
+
* `setColumns()` (a language change of
|
|
21
|
+
* C_YUI_TREEDB_TOPIC_WITH_FORM runs it) and `setHeight`,
|
|
22
|
+
* `setMaxHeight` and `setMinHeight` build the cells again the
|
|
23
|
+
* same way, and Tabulator throws the same.
|
|
24
|
+
*
|
|
25
|
+
* So the edit is ended BEFORE each of those calls, while its cell
|
|
20
26
|
* is alive, and opened again on the new cell of the same row
|
|
21
27
|
* and column after it. What was typed in the box is lost; the
|
|
22
28
|
* editor stays open under the reader.
|
|
@@ -27,8 +33,10 @@
|
|
|
27
33
|
import {log_warning} from "@yuneta/gobj-js";
|
|
28
34
|
|
|
29
35
|
/************************************************************
|
|
30
|
-
* Wrap `tabulator
|
|
31
|
-
*
|
|
36
|
+
* Wrap the calls of `tabulator` that build the cells again --
|
|
37
|
+
* a forced `redraw`, `setColumns` and the three height setters
|
|
38
|
+
* -- so that each ends the open edit first and opens it again
|
|
39
|
+
* after.
|
|
32
40
|
************************************************************/
|
|
33
41
|
function yui_tabulator_keep_edit_on_redraw(tabulator)
|
|
34
42
|
{
|
|
@@ -43,27 +51,35 @@ function yui_tabulator_keep_edit_on_redraw(tabulator)
|
|
|
43
51
|
editing = null;
|
|
44
52
|
});
|
|
45
53
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
function keep_edit_around(name, rebuilds)
|
|
55
|
+
{
|
|
56
|
+
let original = tabulator[name].bind(tabulator);
|
|
57
|
+
tabulator[name] = function(...args) {
|
|
58
|
+
let cell = editing;
|
|
59
|
+
/* A success() with the value unchanged fires no cellEdited:
|
|
60
|
+
* the cell's class says whether it is still being edited. */
|
|
61
|
+
let $cell = cell? cell.getElement() : null;
|
|
62
|
+
if(!rebuilds(args) || !$cell || !$cell.classList.contains("tabulator-editing")) {
|
|
63
|
+
return original(...args);
|
|
64
|
+
}
|
|
65
|
+
let row = cell.getRow();
|
|
66
|
+
let field = cell.getField();
|
|
67
|
+
cell.cancelEdit();
|
|
68
|
+
let ret = original(...args);
|
|
69
|
+
let again = row.getCell(field);
|
|
70
|
+
if(!again) {
|
|
71
|
+
log_warning(`yui_tabulator_keep_edit_on_redraw: no cell '${field}' after ${name}()`);
|
|
72
|
+
return ret;
|
|
73
|
+
}
|
|
74
|
+
again.edit(true);
|
|
62
75
|
return ret;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
keep_edit_around("redraw", (args) => !!args[0]);
|
|
80
|
+
for(const name of ["setColumns", "setHeight", "setMaxHeight", "setMinHeight"]) {
|
|
81
|
+
keep_edit_around(name, () => true);
|
|
82
|
+
}
|
|
67
83
|
}
|
|
68
84
|
|
|
69
85
|
export {yui_tabulator_keep_edit_on_redraw};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* yui_tabulator_edit.test.js
|
|
3
|
+
*
|
|
4
|
+
* yui_tabulator_keep_edit_on_redraw(): every Tabulator call that
|
|
5
|
+
* builds the cells again -- a forced redraw, setColumns() and the
|
|
6
|
+
* three height setters -- ends the open edit BEFORE it, while its
|
|
7
|
+
* cell is alive, and opens it again on the new cell after it.
|
|
8
|
+
* Nothing else is touched. The table is a double that records the
|
|
9
|
+
* order of the calls; that the real Tabulator throws without this
|
|
10
|
+
* is proved in a browser by scripts/qa-cell-editor.mjs.
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2026, ArtGins.
|
|
13
|
+
* All Rights Reserved.
|
|
14
|
+
***********************************************************************/
|
|
15
|
+
import {describe, test, expect, beforeEach} from "vitest";
|
|
16
|
+
import {yui_tabulator_keep_edit_on_redraw} from "./yui_tabulator_edit.js";
|
|
17
|
+
|
|
18
|
+
let calls = [];
|
|
19
|
+
|
|
20
|
+
function make_cell(row, field, editing)
|
|
21
|
+
{
|
|
22
|
+
const cell = {
|
|
23
|
+
field,
|
|
24
|
+
classes: new Set(editing? ["tabulator-editing"] : []),
|
|
25
|
+
getElement() {
|
|
26
|
+
return {classList: {contains: (c) => cell.classes.has(c)}};
|
|
27
|
+
},
|
|
28
|
+
getRow() {
|
|
29
|
+
return row;
|
|
30
|
+
},
|
|
31
|
+
getField() {
|
|
32
|
+
return field;
|
|
33
|
+
},
|
|
34
|
+
cancelEdit() {
|
|
35
|
+
calls.push(`cancel ${field}`);
|
|
36
|
+
cell.classes.delete("tabulator-editing");
|
|
37
|
+
},
|
|
38
|
+
edit(force) {
|
|
39
|
+
calls.push(`edit ${field} ${force}`);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return cell;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function make_table()
|
|
46
|
+
{
|
|
47
|
+
const handlers = {};
|
|
48
|
+
const row = {
|
|
49
|
+
getCell(field) {
|
|
50
|
+
calls.push(`getCell ${field}`);
|
|
51
|
+
return field === "gone"? false : make_cell(row, field, false);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const table = {
|
|
55
|
+
row,
|
|
56
|
+
on(name, fn) {
|
|
57
|
+
handlers[name] = fn;
|
|
58
|
+
},
|
|
59
|
+
emit(name, cell) {
|
|
60
|
+
handlers[name](cell);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
for(const name of ["redraw", "setColumns", "setHeight", "setMaxHeight", "setMinHeight"]) {
|
|
64
|
+
table[name] = function(...args) {
|
|
65
|
+
calls.push(`${name}(${args.join(",")})`);
|
|
66
|
+
return `${name} done`;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
yui_tabulator_keep_edit_on_redraw(table);
|
|
70
|
+
return table;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
calls = [];
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("an open edit around a call that builds the cells again", () => {
|
|
78
|
+
for(const [name, args] of [
|
|
79
|
+
["redraw", [true]],
|
|
80
|
+
["setColumns", [["defs"]]],
|
|
81
|
+
["setHeight", [300]],
|
|
82
|
+
["setMaxHeight", [400]],
|
|
83
|
+
["setMinHeight", [100]],
|
|
84
|
+
]) {
|
|
85
|
+
test(`${name}: ended before, opened again after, the answer passed on`, () => {
|
|
86
|
+
const table = make_table();
|
|
87
|
+
table.emit("cellEditing", make_cell(table.row, "when", true));
|
|
88
|
+
const ret = table[name](...args);
|
|
89
|
+
expect(ret).toBe(`${name} done`);
|
|
90
|
+
expect(calls).toEqual([
|
|
91
|
+
"cancel when",
|
|
92
|
+
`${name}(${args.join(",")})`,
|
|
93
|
+
"getCell when",
|
|
94
|
+
"edit when true",
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("what it leaves alone", () => {
|
|
101
|
+
test("a redraw that is not forced", () => {
|
|
102
|
+
const table = make_table();
|
|
103
|
+
table.emit("cellEditing", make_cell(table.row, "when", true));
|
|
104
|
+
table.redraw();
|
|
105
|
+
table.redraw(false);
|
|
106
|
+
expect(calls).toEqual(["redraw()", "redraw(false)"]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("no edit open: never opened, ended, or ended without cellEdited", () => {
|
|
110
|
+
const table = make_table();
|
|
111
|
+
table.setColumns(["a"]);
|
|
112
|
+
const cell = make_cell(table.row, "when", true);
|
|
113
|
+
table.emit("cellEditing", cell);
|
|
114
|
+
table.emit("cellEdited", cell);
|
|
115
|
+
table.setHeight(10);
|
|
116
|
+
table.emit("cellEditing", cell);
|
|
117
|
+
table.emit("cellEditCancelled", cell);
|
|
118
|
+
table.redraw(true);
|
|
119
|
+
/* A success() with the value unchanged fires no cellEdited. */
|
|
120
|
+
table.emit("cellEditing", cell);
|
|
121
|
+
cell.classes.delete("tabulator-editing");
|
|
122
|
+
table.setMinHeight(5);
|
|
123
|
+
expect(calls).toEqual(["setColumns(a)", "setHeight(10)", "redraw(true)", "setMinHeight(5)"]);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("a column the new columns do not have: the edit stays closed", () => {
|
|
127
|
+
const table = make_table();
|
|
128
|
+
table.emit("cellEditing", make_cell(table.row, "gone", true));
|
|
129
|
+
expect(table.setColumns(["other"])).toBe("setColumns done");
|
|
130
|
+
expect(calls).toEqual(["cancel gone", "setColumns(other)", "getCell gone"]);
|
|
131
|
+
});
|
|
132
|
+
});
|
package/src/yui_time.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
/* The text of a moment lives in a module of its own, which carries no
|
|
48
48
|
* i18n key: a view that formats a time must not make the validator ask
|
|
49
49
|
* an app for the keys of the period picker, which live here. */
|
|
50
|
-
import {safe_locale, fmt_date_time} from "./yui_date_text.js";
|
|
50
|
+
import {safe_locale, date_time_format, fmt_date_time} from "./yui_date_text.js";
|
|
51
51
|
|
|
52
52
|
/***************************************************************
|
|
53
53
|
* Constants
|
|
@@ -140,12 +140,7 @@ function tr(t, key, params)
|
|
|
140
140
|
***************************************************************/
|
|
141
141
|
function fmt_intl(date, locale, opts)
|
|
142
142
|
{
|
|
143
|
-
|
|
144
|
-
return new Intl.DateTimeFormat(safe_locale(locale), opts).format(date);
|
|
145
|
-
} catch(e) {
|
|
146
|
-
/* A locale Intl refuses is not worth a broken screen. */
|
|
147
|
-
return date.toDateString();
|
|
148
|
-
}
|
|
143
|
+
return date_time_format(locale, opts).format(date);
|
|
149
144
|
}
|
|
150
145
|
|
|
151
146
|
|
package/src/yui_uplot_time.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* Copyright (c) 2026, ArtGins.
|
|
28
28
|
* All Rights Reserved.
|
|
29
29
|
***********************************************************************/
|
|
30
|
-
import {fmt_date_time, safe_locale} from "./yui_date_text.js";
|
|
30
|
+
import {fmt_date_time, safe_locale, date_time_format} from "./yui_date_text.js";
|
|
31
31
|
|
|
32
32
|
/* The legend's stamp, as uPlot 1.6 writes it (_timeSeriesStamp). */
|
|
33
33
|
const LEGEND_STAMP = "{YYYY}-{MM}-{DD} {h}:{mm}{aa}";
|
|
@@ -43,11 +43,7 @@ function intl(locale, opts)
|
|
|
43
43
|
let key = locale + "|" + JSON.stringify(opts);
|
|
44
44
|
let f = __formatters__.get(key);
|
|
45
45
|
if(!f) {
|
|
46
|
-
|
|
47
|
-
f = new Intl.DateTimeFormat(locale, opts);
|
|
48
|
-
} catch(e) {
|
|
49
|
-
f = new Intl.DateTimeFormat("en", opts);
|
|
50
|
-
}
|
|
46
|
+
f = date_time_format(locale, opts);
|
|
51
47
|
__formatters__.set(key, f);
|
|
52
48
|
}
|
|
53
49
|
return f;
|