@yuneta/gobj-ui 7.26.45 → 7.26.46
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 +87 -14
- package/dist/gobj-ui.cjs.js +230 -24
- package/dist/gobj-ui.es.js +231 -25
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +210 -55
- package/src/c_yui_form.js +75 -24
- package/src/c_yui_shell.js +59 -12
- package/src/c_yui_window.js +14 -0
- package/src/form_table_rows.wiring.test.js +164 -1
- package/src/form_time_cell_editor.js +143 -0
- package/src/form_time_cell_editor.test.js +116 -0
- package/src/i18n_key_functions.test.js +8 -4
- package/src/shell_focus_trap.js +32 -1
- package/src/shell_focus_trap.test.js +95 -0
- package/src/shell_modals.js +2 -2
- package/src/shell_stop_overlays.wiring.test.js +143 -0
- package/src/tabulator_edit_internals.test.js +50 -0
- package/src/window_rect_rounding.wiring.test.js +23 -0
|
@@ -61,8 +61,11 @@
|
|
|
61
61
|
* name, an alias of one (`const translate = t`, a `.bind()`,
|
|
62
62
|
* a destructuring, `const {t: tt} = i18next` or a parameter
|
|
63
63
|
* `{t: tt}`, a re-export), called `t?.(k)`, `t.call(x, k)` or
|
|
64
|
-
* `t.apply(x, [k])` (`t["call"](x, k)` too,
|
|
65
|
-
* `["bind"]
|
|
64
|
+
* `t.apply(x, [k])` (`t["call"](x, k)` too, a computed
|
|
65
|
+
* `["bind"]`, a name a const gives, `t[M]`, or a template;
|
|
66
|
+
* and a spread of an array the source writes out,
|
|
67
|
+
* `t(...["k"])`, `t.apply(x, KEYS)` with KEYS a const
|
|
68
|
+
* array); an array there is i18next's list of
|
|
66
69
|
* fallback keys, each one a key (`t([k, "fallback"])`). A
|
|
67
70
|
* `.bind()` that binds a key (`const tk = t.bind(null, k)`)
|
|
68
71
|
* hands t() that key, read where the bind is written, and
|
|
@@ -238,9 +241,12 @@
|
|
|
238
241
|
* alias of (a parameter `translate`, a `let` alias,
|
|
239
242
|
* `i18next.getFixedT()`), or called by what is no name of it --
|
|
240
243
|
* `(0, t)(k)`, `[t][0](k)`, `Reflect.apply(t, x, [k])`,
|
|
241
|
-
* `Function.prototype.call.call(t, x, k)
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
+
* `Function.prototype.call.call(t, x, k)`, a computed name the
|
|
245
|
+
* reader does not follow to one string --; a key in a spread of
|
|
246
|
+
* what is no array the source writes out (`t(...args)`); a
|
|
247
|
+
* parameter a closure returns (`const inner = () => key;
|
|
248
|
+
* t(inner())`: the search for the functions that forward a key
|
|
249
|
+
* does not see it); a translator
|
|
244
250
|
* handed to a function (`{t: t}`, `yui_tabulator_lang(t)`: it
|
|
245
251
|
* calls it with keys of its own), or to any method but those
|
|
246
252
|
* above (`keys.reduce(t)`, `keys.sort(t)`, an alias of a method,
|
|
@@ -249,10 +255,10 @@
|
|
|
249
255
|
* label`: the reader reads the literals of a `let`, not what it
|
|
250
256
|
* translates), or returned by a function (`{i18n:
|
|
251
257
|
* label_of(x)}`); a key function reached through a parameter, a
|
|
252
|
-
* `let` given more than one value, a computed member
|
|
253
|
-
* (`API[name](...)`); a data-i18n* attribute written
|
|
254
|
-
* alias of `dataset`, by Object.assign() into it, or
|
|
255
|
-
* `let`; an export of a `let`; a published list mutated through a
|
|
258
|
+
* `let` given more than one value, a computed member named by
|
|
259
|
+
* no const (`API[name](...)`); a data-i18n* attribute written
|
|
260
|
+
* through an alias of `dataset`, by Object.assign() into it, or
|
|
261
|
+
* named by a `let`; an export of a `let`; a published list mutated through a
|
|
256
262
|
* function it is handed to, or by
|
|
257
263
|
* `Array.prototype.push.call(X_I18N_KEYS, k)`; a module of a
|
|
258
264
|
* package (gobj-js, i18next); what is written into a const table
|
|
@@ -988,20 +994,20 @@ function iteration_call(call, scope)
|
|
|
988
994
|
if(c.type !== "MemberExpression") {
|
|
989
995
|
return null;
|
|
990
996
|
}
|
|
991
|
-
let name =
|
|
997
|
+
let name = member_name(c, scope);
|
|
992
998
|
if(ITERATION_METHODS.has(name)) {
|
|
993
999
|
let cb = call.arguments[0];
|
|
994
1000
|
return (cb && cb.type !== "SpreadElement")? {method: name, receiver: c.object, callback: cb, form: ""} : null;
|
|
995
1001
|
}
|
|
996
1002
|
if(name === "call" || name === "apply") {
|
|
997
1003
|
let inner = unchain(c.object);
|
|
998
|
-
let method = (inner.type === "MemberExpression")?
|
|
1004
|
+
let method = (inner.type === "MemberExpression")? member_name(inner, scope) : null;
|
|
999
1005
|
if(!ITERATION_METHODS.has(method)) {
|
|
1000
1006
|
return null;
|
|
1001
1007
|
}
|
|
1002
|
-
let receiver = call.arguments
|
|
1003
|
-
let
|
|
1004
|
-
let cb = (name === "call")? rest : (
|
|
1008
|
+
let [receiver, rest] = written_args(call.arguments, scope);
|
|
1009
|
+
let listed = (name === "apply" && rest && rest.type !== "SpreadElement")? written_elements(rest, scope) : null;
|
|
1010
|
+
let cb = (name === "call")? rest : (listed? listed[0] : null);
|
|
1005
1011
|
if(!receiver || receiver.type === "SpreadElement" || !cb || cb.type === "SpreadElement") {
|
|
1006
1012
|
return null;
|
|
1007
1013
|
}
|
|
@@ -1872,7 +1878,7 @@ function callee_at(node, scope, depth, far)
|
|
|
1872
1878
|
}
|
|
1873
1879
|
|
|
1874
1880
|
case "MemberExpression": {
|
|
1875
|
-
let step =
|
|
1881
|
+
let step = {prop: member_name(node, scope), computed: !!node.computed};
|
|
1876
1882
|
if(step.prop === null) {
|
|
1877
1883
|
return null;
|
|
1878
1884
|
}
|
|
@@ -1914,17 +1920,19 @@ function callee_at(node, scope, depth, far)
|
|
|
1914
1920
|
/* f.bind(x) is f; f.bind(x, a, ...) is f with its first arguments
|
|
1915
1921
|
* BOUND, so what a call of it is handed comes after them */
|
|
1916
1922
|
let c = node.callee;
|
|
1917
|
-
if(c.type !== "MemberExpression" ||
|
|
1923
|
+
if(c.type !== "MemberExpression" || member_name(c, scope) !== "bind") {
|
|
1918
1924
|
return null;
|
|
1919
1925
|
}
|
|
1920
1926
|
let inner = callee_at(c.object, scope, depth + 1, far);
|
|
1921
|
-
let
|
|
1922
|
-
|
|
1927
|
+
let given = written_args(node.arguments, scope);
|
|
1928
|
+
let hidden = is_spread(given[0]); // `f.bind(...X)`: what it binds is not known
|
|
1929
|
+
let taken = given.slice(1);
|
|
1930
|
+
if(!inner || (taken.length === 0 && !hidden)) {
|
|
1923
1931
|
return inner;
|
|
1924
1932
|
}
|
|
1925
1933
|
return Object.assign({}, inner, {
|
|
1926
1934
|
bound: (inner.bound || 0) + taken.length,
|
|
1927
|
-
bound_spread: !!inner.bound_spread || taken.some(
|
|
1935
|
+
bound_spread: !!inner.bound_spread || hidden || taken.some(is_spread)
|
|
1928
1936
|
});
|
|
1929
1937
|
}
|
|
1930
1938
|
|
|
@@ -2005,21 +2013,23 @@ function call_target(call, scope)
|
|
|
2005
2013
|
}
|
|
2006
2014
|
let r = null;
|
|
2007
2015
|
let callee = call.callee;
|
|
2008
|
-
let method = (callee.type === "MemberExpression")?
|
|
2016
|
+
let method = (callee.type === "MemberExpression")? member_name(callee, scope) : null;
|
|
2009
2017
|
if(method === "call" || method === "apply") {
|
|
2010
2018
|
let inner = callee_of(callee.object, scope);
|
|
2011
2019
|
if(inner) {
|
|
2012
|
-
let
|
|
2020
|
+
let given = written_args(call.arguments, scope);
|
|
2021
|
+
let hidden = is_spread(given[0]); // `f.call(...X)`: where its arguments start is not known
|
|
2022
|
+
let args = hidden? [given[0]] : given.slice(1);
|
|
2013
2023
|
if(method === "apply") {
|
|
2014
|
-
let list =
|
|
2015
|
-
args = !list? [] : (list
|
|
2024
|
+
let list = given[1];
|
|
2025
|
+
args = (hidden || is_spread(list))? null : !list? [] : written_elements(list, scope);
|
|
2016
2026
|
}
|
|
2017
2027
|
r = {target: inner, args};
|
|
2018
2028
|
}
|
|
2019
2029
|
}
|
|
2020
2030
|
if(!r) {
|
|
2021
2031
|
let target = callee_of(callee, scope);
|
|
2022
|
-
r = target? {target, args: call.arguments} : null;
|
|
2032
|
+
r = target? {target, args: written_args(call.arguments, scope)} : null;
|
|
2023
2033
|
}
|
|
2024
2034
|
if(r && r.target.bound) {
|
|
2025
2035
|
/* Up to 7.26.41 the bound arguments were not counted: what a call of
|
|
@@ -2049,14 +2059,19 @@ function call_target(call, scope)
|
|
|
2049
2059
|
function bind_kind(call, scope, table = I18N_KEY_FUNCTIONS)
|
|
2050
2060
|
{
|
|
2051
2061
|
let c = call.callee;
|
|
2052
|
-
if(c.type !== "MemberExpression" ||
|
|
2062
|
+
if(c.type !== "MemberExpression" || member_name(c, scope) !== "bind") {
|
|
2063
|
+
return null;
|
|
2064
|
+
}
|
|
2065
|
+
let given = written_args(call.arguments, scope);
|
|
2066
|
+
let hidden = is_spread(given[0]);
|
|
2067
|
+
if(given.length < 2 && !hidden) {
|
|
2053
2068
|
return null;
|
|
2054
2069
|
}
|
|
2055
2070
|
let inner = callee_of(c.object, scope);
|
|
2056
2071
|
if(!inner) {
|
|
2057
2072
|
return null;
|
|
2058
2073
|
}
|
|
2059
|
-
let args = inner.bound_spread? null : [...new Array(inner.bound || 0).fill(null), ...
|
|
2074
|
+
let args = (inner.bound_spread || hidden)? null : [...new Array(inner.bound || 0).fill(null), ...given.slice(1)];
|
|
2060
2075
|
if(inner.kind === "t") {
|
|
2061
2076
|
return {kind: "t", target: inner, args};
|
|
2062
2077
|
}
|
|
@@ -2100,7 +2115,8 @@ function call_kind(call, scope, table = I18N_KEY_FUNCTIONS)
|
|
|
2100
2115
|
let fns = module? key_fn_index(table).by_module.get(module) : null;
|
|
2101
2116
|
let entry = (fns && call.callee.type === "Identifier" && !binding_of(call.callee.name, scope))?
|
|
2102
2117
|
(fns.get(call.callee.name) || null) : null;
|
|
2103
|
-
return entry? {kind: "key", entry, target: {kind: "unbound", name: entry.name},
|
|
2118
|
+
return entry? {kind: "key", entry, target: {kind: "unbound", name: entry.name},
|
|
2119
|
+
args: written_args(call.arguments, scope)} : null;
|
|
2104
2120
|
}
|
|
2105
2121
|
let {target, args} = r;
|
|
2106
2122
|
if(target.kind === "t") {
|
|
@@ -2246,7 +2262,7 @@ function translator_callback(call, scope)
|
|
|
2246
2262
|
{how: "elements", method: it.method, form: it.form, receiver: it.receiver, arg: it.callback} : null;
|
|
2247
2263
|
}
|
|
2248
2264
|
let c = (call.callee.type === "ChainExpression")? call.callee.expression : call.callee;
|
|
2249
|
-
let method = (c.type === "MemberExpression")?
|
|
2265
|
+
let method = (c.type === "MemberExpression")? member_name(c, scope) : null;
|
|
2250
2266
|
if(SETTLE_METHODS.has(method)) {
|
|
2251
2267
|
let arg = call.arguments.find(is_translator);
|
|
2252
2268
|
return arg? {how: "settled", method, arg} : null;
|
|
@@ -2367,16 +2383,22 @@ function gave_up(ast = null)
|
|
|
2367
2383
|
* A read counts its steps from the place the value is read: a const,
|
|
2368
2384
|
* a property, an element, the returns of a function called, each
|
|
2369
2385
|
* read ONCE and kept, keep the steps they took beside their values
|
|
2370
|
-
* (`
|
|
2371
|
-
* The verdict on a read is the same whatever was
|
|
2372
|
-
* to gobj-ui 7.26.44 a const kept the values of
|
|
2373
|
-
* at the depth that read had reached, so `t(J16);
|
|
2374
|
-
* `t(K10); t(J16)` passed. A read that goes past
|
|
2375
|
-
* up as a whole (TooDeep unwinds it to its
|
|
2376
|
-
* value read on the way is kept: each is
|
|
2377
|
-
* to its end.
|
|
2386
|
+
* (`steps`), so a later read of them takes those steps again from
|
|
2387
|
+
* where it stands. The verdict on a read is the same whatever was
|
|
2388
|
+
* read before it: up to gobj-ui 7.26.44 a const kept the values of
|
|
2389
|
+
* its FIRST read, cut at the depth that read had reached, so `t(J16);
|
|
2390
|
+
* t(K10)` failed and `t(K10); t(J16)` passed. A read that goes past
|
|
2391
|
+
* MAX_DEPTH is given up as a whole (TooDeep unwinds it to its
|
|
2392
|
+
* outermost frame), and no value read on the way is kept: each is
|
|
2393
|
+
* kept only when it was read to its end.
|
|
2394
|
+
*
|
|
2395
|
+
* The place it went past is the same whatever was read before, too:
|
|
2396
|
+
* the first node reached at step MAX_DEPTH + 1 -- a kept read hands
|
|
2397
|
+
* on, for each of its steps, the first node it reached there (up to
|
|
2398
|
+
* gobj-ui 7.26.45 the place was the kept read itself, so `past K10`
|
|
2399
|
+
* or `past K2` depended on what had been read first).
|
|
2378
2400
|
***************************************************************/
|
|
2379
|
-
const FRAMES = []; // the reads in progress, outermost first: {max
|
|
2401
|
+
const FRAMES = []; // the reads in progress, outermost first: {max, at}
|
|
2380
2402
|
|
|
2381
2403
|
class TooDeep
|
|
2382
2404
|
{
|
|
@@ -2387,10 +2409,17 @@ class TooDeep
|
|
|
2387
2409
|
}
|
|
2388
2410
|
}
|
|
2389
2411
|
|
|
2390
|
-
|
|
2412
|
+
/* A step of the read in progress at `depth`: the first one there is
|
|
2413
|
+
* kept in `at[depth]`. Of its scope only the module is kept, which is
|
|
2414
|
+
* all gave_up() reads -- and a walker's own chain goes on changing */
|
|
2415
|
+
function note_step(depth, node, scope)
|
|
2391
2416
|
{
|
|
2392
|
-
|
|
2393
|
-
|
|
2417
|
+
let frame = FRAMES[FRAMES.length - 1];
|
|
2418
|
+
if(frame && depth > frame.max) {
|
|
2419
|
+
for(let d = frame.max + 1; d <= depth; d++) {
|
|
2420
|
+
frame.at[d] = {node, scope: (scope || []).slice(0, 1)};
|
|
2421
|
+
}
|
|
2422
|
+
frame.max = depth;
|
|
2394
2423
|
}
|
|
2395
2424
|
}
|
|
2396
2425
|
|
|
@@ -2398,7 +2427,7 @@ function note_depth(depth)
|
|
|
2398
2427
|
* outside one, it is given up here and the caller stops: true */
|
|
2399
2428
|
function too_deep(depth, node, scope)
|
|
2400
2429
|
{
|
|
2401
|
-
|
|
2430
|
+
note_step(depth, node, scope);
|
|
2402
2431
|
if(depth <= MAX_DEPTH) {
|
|
2403
2432
|
return false;
|
|
2404
2433
|
}
|
|
@@ -2414,7 +2443,7 @@ function too_deep(depth, node, scope)
|
|
|
2414
2443
|
function outermost_read(node, scope, fn, fallback)
|
|
2415
2444
|
{
|
|
2416
2445
|
return from_read(node, scope, () => {
|
|
2417
|
-
FRAMES.push({max: 0});
|
|
2446
|
+
FRAMES.push({max: 0, at: []});
|
|
2418
2447
|
try {
|
|
2419
2448
|
return fn();
|
|
2420
2449
|
} catch(e) {
|
|
@@ -2430,19 +2459,22 @@ function outermost_read(node, scope, fn, fallback)
|
|
|
2430
2459
|
}
|
|
2431
2460
|
|
|
2432
2461
|
/* What `compute()` answers for `key` of `cache`, read once and kept
|
|
2433
|
-
* with its
|
|
2462
|
+
* with its steps, read at `depth` by `node` (in `scope`) */
|
|
2434
2463
|
function kept_values(cache, key, depth, node, scope, compute, fallback)
|
|
2435
2464
|
{
|
|
2436
|
-
let known = cache.get(key);
|
|
2437
|
-
if(known) {
|
|
2438
|
-
too_deep(depth + known.height, node, scope);
|
|
2439
|
-
return known.values;
|
|
2440
|
-
}
|
|
2441
2465
|
if(FRAMES.length === 0) {
|
|
2442
2466
|
return outermost_read(node, scope, () => kept_values(cache, key, depth, node, scope, compute, fallback),
|
|
2443
2467
|
fallback);
|
|
2444
2468
|
}
|
|
2445
|
-
let
|
|
2469
|
+
let known = cache.get(key);
|
|
2470
|
+
if(known) {
|
|
2471
|
+
let top = FRAMES[FRAMES.length - 1];
|
|
2472
|
+
for(let i = Math.max(0, top.max - depth); i < known.steps.length; i++) {
|
|
2473
|
+
too_deep(depth + 1 + i, known.steps[i].node, known.steps[i].scope);
|
|
2474
|
+
}
|
|
2475
|
+
return known.values;
|
|
2476
|
+
}
|
|
2477
|
+
let frame = {max: depth, at: []};
|
|
2446
2478
|
FRAMES.push(frame);
|
|
2447
2479
|
let values;
|
|
2448
2480
|
try {
|
|
@@ -2450,8 +2482,11 @@ function kept_values(cache, key, depth, node, scope, compute, fallback)
|
|
|
2450
2482
|
} finally {
|
|
2451
2483
|
FRAMES.pop();
|
|
2452
2484
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2485
|
+
let steps = frame.at.slice(depth + 1, frame.max + 1);
|
|
2486
|
+
for(let i = 0; i < steps.length; i++) {
|
|
2487
|
+
note_step(depth + 1 + i, steps[i].node, steps[i].scope);
|
|
2488
|
+
}
|
|
2489
|
+
cache.set(key, {values, steps});
|
|
2455
2490
|
return values;
|
|
2456
2491
|
}
|
|
2457
2492
|
|
|
@@ -2657,7 +2692,7 @@ function expand_node(node, ctx, depth)
|
|
|
2657
2692
|
* again while its value is being read leads back to itself: the reader
|
|
2658
2693
|
* gives up on it (give_up()).
|
|
2659
2694
|
***************************************************************/
|
|
2660
|
-
const CONST_VALUES = new WeakMap(); // the init of a const -> {values,
|
|
2695
|
+
const CONST_VALUES = new WeakMap(); // the init of a const -> {values, steps}, `via` left out
|
|
2661
2696
|
const CONST_READING = new Set(); // the inits being read
|
|
2662
2697
|
|
|
2663
2698
|
function const_values(b, node, scope, via, depth)
|
|
@@ -2784,7 +2819,7 @@ function local_call_values(call, ctx, via, depth = 0)
|
|
|
2784
2819
|
* the count again, so thirty nested calls were read through.
|
|
2785
2820
|
* `call` makes it, in `scope`, at `depth`.
|
|
2786
2821
|
***************************************************************/
|
|
2787
|
-
const FN_RETURNS = new WeakMap(); // a function -> {values: {items, complete, keys},
|
|
2822
|
+
const FN_RETURNS = new WeakMap(); // a function -> {values: {items, complete, keys}, steps}
|
|
2788
2823
|
const FN_READING = new Set();
|
|
2789
2824
|
|
|
2790
2825
|
function fn_returns(target, call, scope, depth)
|
|
@@ -2867,10 +2902,105 @@ function member_step(node)
|
|
|
2867
2902
|
name = node.property.name;
|
|
2868
2903
|
} else if(node.computed && node.property.type === "Literal") {
|
|
2869
2904
|
name = String(node.property.value);
|
|
2905
|
+
} else if(node.computed && static_string(node.property) !== null) {
|
|
2906
|
+
name = static_string(node.property); // x[`a`]
|
|
2870
2907
|
}
|
|
2871
2908
|
return {prop: name, computed: !!node.computed};
|
|
2872
2909
|
}
|
|
2873
2910
|
|
|
2911
|
+
/***************************************************************
|
|
2912
|
+
* The name of the METHOD a member names: member_step()'s, or the one
|
|
2913
|
+
* string a computed name is when the reader follows it to one -- `t[M]`
|
|
2914
|
+
* with `const M = "call"` (an import of one, a chain of them). Up to
|
|
2915
|
+
* gobj-ui 7.26.45 such a `.call` / `.apply` / `.bind` / `.map`, and
|
|
2916
|
+
* `i18next[T]`, were not read. Only for names of methods: a property
|
|
2917
|
+
* read by a computed name reads every property it may be.
|
|
2918
|
+
***************************************************************/
|
|
2919
|
+
function member_name(node, scope)
|
|
2920
|
+
{
|
|
2921
|
+
let name = member_step(node).prop;
|
|
2922
|
+
if(name !== null || !node.computed || !scope
|
|
2923
|
+
|| (node.property.type !== "Identifier" && node.property.type !== "MemberExpression")) {
|
|
2924
|
+
return name;
|
|
2925
|
+
}
|
|
2926
|
+
let {keys, complete} = static_keys(node.property, scope);
|
|
2927
|
+
return (complete && keys.length === 1)? keys[0] : null;
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
/***************************************************************
|
|
2931
|
+
* The arguments of a call as the callee receives them, a SPREAD of an
|
|
2932
|
+
* array the source writes out read as its elements: `t(...["k"])`,
|
|
2933
|
+
* `t(...KEYS)` with `const KEYS = ["k"]`. A spread of anything else
|
|
2934
|
+
* stays where it is: no position from it on is known. Up to gobj-ui
|
|
2935
|
+
* 7.26.45 every spread did.
|
|
2936
|
+
***************************************************************/
|
|
2937
|
+
function written_args(list, scope)
|
|
2938
|
+
{
|
|
2939
|
+
let out = [];
|
|
2940
|
+
for(let i = 0; i < list.length; i++) {
|
|
2941
|
+
let a = list[i];
|
|
2942
|
+
if(a && a.type === "SpreadElement") {
|
|
2943
|
+
let elements = written_elements(a.argument, scope);
|
|
2944
|
+
if(elements === null) {
|
|
2945
|
+
return [...out, ...list.slice(i)];
|
|
2946
|
+
}
|
|
2947
|
+
out.push(...elements);
|
|
2948
|
+
} else {
|
|
2949
|
+
out.push(a);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
return out;
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
/***************************************************************
|
|
2956
|
+
* The elements of an array the source writes out, or null: an array
|
|
2957
|
+
* literal (its spreads read by written_args(), a hole is an argument
|
|
2958
|
+
* not given), or a const bound to one with no spread and no hole --
|
|
2959
|
+
* its elements read THROUGH it, as `X[0]`, `X[1]`... (element_ref()),
|
|
2960
|
+
* so each is read where the const is declared.
|
|
2961
|
+
***************************************************************/
|
|
2962
|
+
function written_elements(n, scope)
|
|
2963
|
+
{
|
|
2964
|
+
if(!n) {
|
|
2965
|
+
return null;
|
|
2966
|
+
}
|
|
2967
|
+
if(n.type === "ArrayExpression") {
|
|
2968
|
+
return written_args(n.elements, scope);
|
|
2969
|
+
}
|
|
2970
|
+
if(n.type !== "Identifier") {
|
|
2971
|
+
return null;
|
|
2972
|
+
}
|
|
2973
|
+
let b = binding_of(n.name, scope);
|
|
2974
|
+
if(!b || b.kind !== "const" || b.steps.length > 0 || !b.init || b.init.type !== "ArrayExpression"
|
|
2975
|
+
|| b.init.elements.some((e) => e === null || e.type === "SpreadElement")) {
|
|
2976
|
+
return null;
|
|
2977
|
+
}
|
|
2978
|
+
return b.init.elements.map((e, i) => element_ref(n, i));
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
function is_spread(n)
|
|
2982
|
+
{
|
|
2983
|
+
return !!n && n.type === "SpreadElement";
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
/* `X[i]` for the name X, a node of no source (at the place of X), made
|
|
2987
|
+
* once: what is said about it is said once */
|
|
2988
|
+
const ELEMENT_REFS = new WeakMap(); // an Identifier -> [its X[i]]
|
|
2989
|
+
|
|
2990
|
+
function element_ref(n, i)
|
|
2991
|
+
{
|
|
2992
|
+
if(!ELEMENT_REFS.has(n)) {
|
|
2993
|
+
ELEMENT_REFS.set(n, []);
|
|
2994
|
+
}
|
|
2995
|
+
let refs = ELEMENT_REFS.get(n);
|
|
2996
|
+
if(!refs[i]) {
|
|
2997
|
+
refs[i] = {type: "MemberExpression", object: n, computed: true, optional: false,
|
|
2998
|
+
property: {type: "Literal", value: i, raw: String(i), start: n.start, end: n.end},
|
|
2999
|
+
start: n.start, end: n.end};
|
|
3000
|
+
}
|
|
3001
|
+
return refs[i];
|
|
3002
|
+
}
|
|
3003
|
+
|
|
2874
3004
|
/***************************************************************
|
|
2875
3005
|
* The var_root of what is read one step further from something read
|
|
2876
3006
|
* from a `let` / `var` (null when it was not)
|
|
@@ -2964,7 +3094,7 @@ function assigned_properties(o, step, depth)
|
|
|
2964
3094
|
* (const_values()): a spread of the same object twice, `{...O, ...O}`,
|
|
2965
3095
|
* gives its values once.
|
|
2966
3096
|
***************************************************************/
|
|
2967
|
-
const PROPERTY_VALUES = new WeakMap(); // an object literal -> Map(property -> {values,
|
|
3097
|
+
const PROPERTY_VALUES = new WeakMap(); // an object literal -> Map(property -> {values, steps}, `via` left out)
|
|
2968
3098
|
|
|
2969
3099
|
function property_values(o, name, depth)
|
|
2970
3100
|
{
|
|
@@ -3063,7 +3193,7 @@ function elements_of(node, ctx, depth)
|
|
|
3063
3193
|
* the properties of an object are (property_values()): `[...A, ...A]`
|
|
3064
3194
|
* gives A's once.
|
|
3065
3195
|
***************************************************************/
|
|
3066
|
-
const ELEMENT_VALUES = new WeakMap(); // an array literal or a .map() -> {values,
|
|
3196
|
+
const ELEMENT_VALUES = new WeakMap(); // an array literal or a .map() -> {values, steps}, `via` left out
|
|
3067
3197
|
|
|
3068
3198
|
function element_values(v, depth)
|
|
3069
3199
|
{
|
|
@@ -5192,6 +5322,9 @@ function may_take_a_callback(n)
|
|
|
5192
5322
|
return false;
|
|
5193
5323
|
}
|
|
5194
5324
|
let m = member_step(c).prop;
|
|
5325
|
+
if(m === null && c.computed) {
|
|
5326
|
+
return true; // a name translator_callback() may follow to one of them
|
|
5327
|
+
}
|
|
5195
5328
|
return ITERATION_METHODS.has(m) || SETTLE_METHODS.has(m) || ARRAY_BUILDERS.has(m) || m === "call" || m === "apply";
|
|
5196
5329
|
}
|
|
5197
5330
|
|
|
@@ -6284,4 +6417,26 @@ if(is_main) {
|
|
|
6284
6417
|
throw e;
|
|
6285
6418
|
}
|
|
6286
6419
|
}
|
|
6420
|
+
exit_when_written();
|
|
6421
|
+
}
|
|
6422
|
+
|
|
6423
|
+
/***************************************************************
|
|
6424
|
+
* End the run with its exitCode once what it wrote has left: a
|
|
6425
|
+
* locale is IMPORTED, and a timer its code leaves running holds the
|
|
6426
|
+
* process for ever, verdict or not (up to gobj-ui 7.26.45, also a run
|
|
6427
|
+
* that failed). process.exit() runs from the callbacks of a last
|
|
6428
|
+
* write to each stream, which come after every write before them, so
|
|
6429
|
+
* a long list on its way to a pipe still reaches it whole.
|
|
6430
|
+
***************************************************************/
|
|
6431
|
+
function exit_when_written()
|
|
6432
|
+
{
|
|
6433
|
+
let pending = 2;
|
|
6434
|
+
let written = () => {
|
|
6435
|
+
pending--;
|
|
6436
|
+
if(pending === 0) {
|
|
6437
|
+
process.exit();
|
|
6438
|
+
}
|
|
6439
|
+
};
|
|
6440
|
+
process.stdout.write("", written);
|
|
6441
|
+
process.stderr.write("", written);
|
|
6287
6442
|
}
|
package/src/c_yui_form.js
CHANGED
|
@@ -96,6 +96,7 @@ import "tabulator-tables/dist/css/tabulator_bulma.css";
|
|
|
96
96
|
import "./tabulator.css";
|
|
97
97
|
import {is_time_field} from "./json_view_helpers.js";
|
|
98
98
|
import {date_to_datetime_local, datetime_local_to_epoch} from "./form_time_value.js";
|
|
99
|
+
import {form_time_cell_editor} from "./form_time_cell_editor.js";
|
|
99
100
|
import {parse_json_field, json_editor_value} from "./form_json_field.js";
|
|
100
101
|
import {
|
|
101
102
|
json_editor_menu_items,
|
|
@@ -133,7 +134,7 @@ SDATA(data_type_t.DTP_STRING, "topic_name", 0, "", "Treedb topic na
|
|
|
133
134
|
SDATA(data_type_t.DTP_BOOLEAN, "editable", 0, false, "Default is editable, set false to readonly"),
|
|
134
135
|
SDATA(data_type_t.DTP_BOOLEAN, "readonly", 0, false, "Show EVERY field read-only, whatever its schema says: a record being LOOKED at, not edited. Independent of `editable`, which drives the TABLE rendering; this one drives the FORM"),
|
|
135
136
|
SDATA(data_type_t.DTP_BOOLEAN, "selectable", 0, true, "A click selects a row, when tabulator_settings selects rows (selectableRows)"),
|
|
136
|
-
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows"),
|
|
137
|
+
SDATA(data_type_t.DTP_BOOLEAN, "with_checkbox", 0, false, "Show a first column with checkbox to select rows (not drawn when the form is not `selectable`)"),
|
|
137
138
|
SDATA(data_type_t.DTP_BOOLEAN, "with_rownum", 0, false, "Print first column with row number"),
|
|
138
139
|
SDATA(data_type_t.DTP_BOOLEAN, "with_delete_row_btn", 0, false, "Print last column with delete row button"),
|
|
139
140
|
/*
|
|
@@ -620,15 +621,40 @@ function destroy_widget(gobj, what, widget)
|
|
|
620
621
|
* walks the rows already wiped: a reload, a Clear or a destroy
|
|
621
622
|
* with an editor open in any row but the first threw, and left
|
|
622
623
|
* the table half wiped.
|
|
624
|
+
*
|
|
625
|
+
* Tabulator has no public way to ask which cell is edited: this
|
|
626
|
+
* reads its edit module (`modules.edit`, `currentCell`,
|
|
627
|
+
* `cancelEdit()`), names pinned against the installed Tabulator
|
|
628
|
+
* by tabulator_edit_internals.test.js. A Tabulator without them
|
|
629
|
+
* is said: the guard would do nothing, and the crash come back.
|
|
623
630
|
************************************************************/
|
|
624
|
-
function close_table_editor(tabulator)
|
|
631
|
+
function close_table_editor(gobj, tabulator)
|
|
625
632
|
{
|
|
626
633
|
let edit = tabulator.modules? tabulator.modules.edit : null;
|
|
627
|
-
if(edit
|
|
634
|
+
if(!edit || !("currentCell" in edit) || typeof edit.cancelEdit !== "function") {
|
|
635
|
+
log_warning(`${gobj_short_name(gobj)}: this Tabulator has no modules.edit.currentCell/cancelEdit(): ` +
|
|
636
|
+
`an open cell editor is not closed before its table is wiped`);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
if(edit.currentCell) {
|
|
628
640
|
edit.cancelEdit();
|
|
629
641
|
}
|
|
630
642
|
}
|
|
631
643
|
|
|
644
|
+
/************************************************************
|
|
645
|
+
* The element of the table (`.tabulator` kept on it) that holds
|
|
646
|
+
* $el, the innermost one.
|
|
647
|
+
************************************************************/
|
|
648
|
+
function table_element_of($el)
|
|
649
|
+
{
|
|
650
|
+
for(let $n = $el; $n; $n = $n.parentNode) {
|
|
651
|
+
if($n.tabulator) {
|
|
652
|
+
return $n;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
|
|
632
658
|
/************************************************************
|
|
633
659
|
* A table element that is gone: its identity is no table now,
|
|
634
660
|
* and what was waiting to be loaded in it never will be.
|
|
@@ -655,7 +681,7 @@ function destroy_row_tables(gobj, $row)
|
|
|
655
681
|
$row.yui_nested = null;
|
|
656
682
|
for(let $nested of nested) {
|
|
657
683
|
if($nested.tabulator) {
|
|
658
|
-
close_table_editor($nested.tabulator);
|
|
684
|
+
close_table_editor(gobj, $nested.tabulator);
|
|
659
685
|
destroy_rows_tables(gobj, $nested.tabulator);
|
|
660
686
|
destroy_widget(gobj, "nested table", $nested.tabulator);
|
|
661
687
|
$nested.tabulator = null;
|
|
@@ -694,7 +720,7 @@ function destroy_widgets(gobj, $container)
|
|
|
694
720
|
$el.jsoneditor = null;
|
|
695
721
|
}
|
|
696
722
|
if($el.tabulator) {
|
|
697
|
-
close_table_editor($el.tabulator);
|
|
723
|
+
close_table_editor(gobj, $el.tabulator);
|
|
698
724
|
destroy_rows_tables(gobj, $el.tabulator);
|
|
699
725
|
destroy_widget(gobj, "table", $el.tabulator);
|
|
700
726
|
$el.tabulator = null;
|
|
@@ -2264,6 +2290,17 @@ function create_coordinates(gobj, attrs)
|
|
|
2264
2290
|
* the form's `selectable` -- first. Up to 7.26.44 the form toggled
|
|
2265
2291
|
* the row again in `rowClick`, which undid every click. The default
|
|
2266
2292
|
* `"highlight"` is left as it is, hover and all.
|
|
2293
|
+
*
|
|
2294
|
+
* The checkbox column (`with_checkbox`) asks `selectable` too, and is
|
|
2295
|
+
* not drawn when the form is not selectable: Tabulator's row box ticks
|
|
2296
|
+
* before its toggle is refused (a ticked box over a row not selected),
|
|
2297
|
+
* and its header box selects every row asking nothing. Up to 7.26.45
|
|
2298
|
+
* the boxes were drawn and lied; with the default `selectableRows`
|
|
2299
|
+
* they selected whatever `selectable` said.
|
|
2300
|
+
*
|
|
2301
|
+
* A click in a nested table stays there: it bubbled to the row that
|
|
2302
|
+
* holds the table, whose own click listener (SelectRow's) toggled
|
|
2303
|
+
* that row too.
|
|
2267
2304
|
******************************************************************/
|
|
2268
2305
|
function create_tabulator(gobj, $extend, name, template, rows)
|
|
2269
2306
|
{
|
|
@@ -2275,8 +2312,9 @@ function create_tabulator(gobj, $extend, name, template, rows)
|
|
|
2275
2312
|
}
|
|
2276
2313
|
|
|
2277
2314
|
/* Tabulator toggles the row on its own click: `selectable` only vetoes */
|
|
2315
|
+
let with_checkbox = gobj_read_bool_attr(gobj, "with_checkbox");
|
|
2278
2316
|
let selectable_rows = tabulator_settings.selectableRows;
|
|
2279
|
-
if(selectable_rows === true || typeof selectable_rows === "number") {
|
|
2317
|
+
if(selectable_rows === true || typeof selectable_rows === "number" || with_checkbox) {
|
|
2280
2318
|
tabulator_settings.selectableRowsCheck = function() {
|
|
2281
2319
|
return gobj_read_bool_attr(gobj, "selectable");
|
|
2282
2320
|
};
|
|
@@ -2317,6 +2355,15 @@ function create_tabulator(gobj, $extend, name, template, rows)
|
|
|
2317
2355
|
}
|
|
2318
2356
|
];
|
|
2319
2357
|
let $extend = createElement2(extend);
|
|
2358
|
+
/* Widget plumbing, not an action: the event is the nested table's */
|
|
2359
|
+
$extend.addEventListener("click", function(ev) {
|
|
2360
|
+
ev.stopPropagation();
|
|
2361
|
+
});
|
|
2362
|
+
$extend.addEventListener("mousedown", function(ev) {
|
|
2363
|
+
if(ev.shiftKey) {
|
|
2364
|
+
ev.stopPropagation();
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2320
2367
|
let rows = data[sub_element.name];
|
|
2321
2368
|
$extend.tabulator = create_tabulator(
|
|
2322
2369
|
gobj, $extend, sub_element.name, sub_element.template, rows
|
|
@@ -2348,7 +2395,7 @@ function create_tabulator(gobj, $extend, name, template, rows)
|
|
|
2348
2395
|
);
|
|
2349
2396
|
}
|
|
2350
2397
|
|
|
2351
|
-
if(gobj_read_bool_attr(gobj, "
|
|
2398
|
+
if(with_checkbox && gobj_read_bool_attr(gobj, "selectable")) {
|
|
2352
2399
|
tabulator_settings.rowHeader = {
|
|
2353
2400
|
formatter: "rowSelection",
|
|
2354
2401
|
titleFormatter: "rowSelection",
|
|
@@ -2380,6 +2427,22 @@ function create_tabulator(gobj, $extend, name, template, rows)
|
|
|
2380
2427
|
}
|
|
2381
2428
|
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
2382
2429
|
});
|
|
2430
|
+
/* What the reader TYPES in a cell editor is `edited` at once, as in a
|
|
2431
|
+
* field of the form (its `input`): `dataChanged` comes only when the
|
|
2432
|
+
* editor commits, and a host that reloads or closes the form by code
|
|
2433
|
+
* asks `edited` first. Up to 7.26.45 a half-typed cell was not
|
|
2434
|
+
* edited, and such a reload dropped it without a question. Only the
|
|
2435
|
+
* editor of a cell of THIS table: not a header filter, not the
|
|
2436
|
+
* selection box, not a nested table's editor (that table says it). */
|
|
2437
|
+
$extend.addEventListener("input", function(ev) {
|
|
2438
|
+
let $target = ev.target;
|
|
2439
|
+
if(!$target || typeof $target.closest !== "function" ||
|
|
2440
|
+
!$target.closest(".tabulator-cell.tabulator-editing") ||
|
|
2441
|
+
table_element_of($target) !== $extend) {
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
gobj_send_event(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
2445
|
+
});
|
|
2383
2446
|
$extend.yui_pending_rows = null;
|
|
2384
2447
|
tabulator.on("tableBuilt", function() {
|
|
2385
2448
|
let rows = $extend.yui_pending_rows;
|
|
@@ -2644,25 +2707,13 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2644
2707
|
|
|
2645
2708
|
case "now":
|
|
2646
2709
|
case "time":
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2710
|
+
/* Tabulator's `datetime` with a `format` needs luxon: see
|
|
2711
|
+
* form_time_cell_editor.js. Named after its column
|
|
2712
|
+
* (yui_tabulator_name_editor, below). */
|
|
2713
|
+
column.editor = form_time_cell_editor(field_desc.real_type);
|
|
2650
2714
|
column.editorParams = {
|
|
2651
|
-
format: "dd/MM/yyyy hh:mm", // the format of the date value stored in the cell
|
|
2652
2715
|
verticalNavigation: "table", //navigate cursor around table without changing the value
|
|
2653
|
-
elementAttributes: {
|
|
2654
|
-
/* Tabulator writes this attribute once, when the
|
|
2655
|
-
* editor opens, so it is translated then -- which
|
|
2656
|
-
* is also when it is read. */
|
|
2657
|
-
title: t("slide bar to choose option")
|
|
2658
|
-
}
|
|
2659
2716
|
};
|
|
2660
|
-
switch(field_desc.real_type) {
|
|
2661
|
-
case "string":
|
|
2662
|
-
break;
|
|
2663
|
-
case "integer":
|
|
2664
|
-
break;
|
|
2665
|
-
}
|
|
2666
2717
|
break;
|
|
2667
2718
|
|
|
2668
2719
|
case "color":
|
|
@@ -3156,7 +3207,7 @@ function clear_data(gobj, $form)
|
|
|
3156
3207
|
$form.querySelectorAll('.yui-tabulator-table').forEach($table => {
|
|
3157
3208
|
$table.yui_pending_rows = null;
|
|
3158
3209
|
if($table.tabulator.initialized) {
|
|
3159
|
-
close_table_editor($table.tabulator);
|
|
3210
|
+
close_table_editor(gobj, $table.tabulator);
|
|
3160
3211
|
destroy_rows_tables(gobj, $table.tabulator);
|
|
3161
3212
|
$table.tabulator.clearData();
|
|
3162
3213
|
}
|