@yuneta/gobj-ui 7.26.42 → 7.26.44
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 +227 -36
- package/dist/gobj-ui.cjs.js +770 -192
- package/dist/gobj-ui.es.js +770 -192
- package/package.json +2 -2
- package/scripts/validate-locales.mjs +355 -63
- package/src/c_yui_form.js +268 -155
- package/src/c_yui_node.js +51 -7
- package/src/c_yui_schema_editor.js +49 -3
- package/src/c_yui_shell.css +4 -1
- package/src/c_yui_shell.js +28 -2
- package/src/c_yui_window.js +373 -62
- package/src/c_yui_window_manager.js +74 -2
- package/src/escape_taken.js +58 -0
- package/src/form_close_asks_for_edits.wiring.test.js +6 -3
- package/src/form_json_editor_names.js +3 -1
- package/src/form_json_editor_names.wiring.test.js +8 -4
- package/src/form_json_expand.wiring.test.js +6 -3
- package/src/form_json_field.wiring.test.js +8 -4
- package/src/form_label_i18n.wiring.test.js +10 -5
- package/src/form_table_edits_ask.wiring.test.js +18 -8
- package/src/form_table_rearm.wiring.test.js +13 -5
- package/src/form_table_rows.wiring.test.js +533 -0
- package/src/form_table_validator.wiring.test.js +8 -4
- package/src/form_template_field.wiring.test.js +6 -3
- package/src/g6_long_press_clock.test.js +8 -3
- package/src/i18n_key_functions.js +63 -25
- package/src/i18n_key_functions.test.js +230 -8
- package/src/modal_guard_back.wiring.test.js +53 -0
- package/src/named_controls.wiring.test.js +53 -13
- package/src/node_nav_events.wiring.test.js +93 -1
- package/src/schema_editor_diagram_click.wiring.test.js +277 -0
- package/src/shell_dialog_names.wiring.test.js +149 -0
- package/src/shell_escape_taken.wiring.test.js +142 -0
- package/src/shell_focus_trap.js +30 -2
- package/src/shell_focus_trap.test.js +90 -6
- package/src/shell_modals.js +90 -19
- package/src/table_editor_name.wiring.test.js +10 -5
- package/src/treedb_column_title.wiring.test.js +8 -4
- package/src/treedb_graph_writes.wiring.test.js +6 -3
- package/src/treedb_json_drill.wiring.test.js +6 -3
- package/src/uplot_add_serie.test.js +6 -3
- package/src/uplot_ink.test.js +8 -4
- package/src/window_dialog.wiring.test.js +486 -0
- package/src/window_dock_band.wiring.test.js +189 -0
- package/src/window_rect_rounding.wiring.test.js +121 -0
- package/src/yui_tabulator_i18n.js +31 -1
- package/src/yui_tabulator_i18n.test.js +46 -0
package/README.md
CHANGED
|
@@ -137,6 +137,72 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
|
|
|
137
137
|
> (minimise / bring back, named by the window's title, through the FSM:
|
|
138
138
|
> `EV_TOGGLE_WINDOW`) and its ✕ (`close`). It was a `role="button"` holding
|
|
139
139
|
> the ✕ button -- one control inside another.
|
|
140
|
+
>
|
|
141
|
+
> **A floating dock keeps its band free (7.26.43).** A window that fills the
|
|
142
|
+
> screen -- the sheet a window becomes on a phone, a maximized one on a laptop --
|
|
143
|
+
> went under the floating dock: at a bottom corner the dock covered its foot, at
|
|
144
|
+
> a top corner its ✕ and its minimize. It happens on a phone to every app whose
|
|
145
|
+
> dock is `responsive` with no `inline_selector` (it floats there too). The dock
|
|
146
|
+
> now says the band it keeps, on the root element (`--yui-dock-inset-top` /
|
|
147
|
+
> `--yui-dock-inset-bottom`, set while a floating dock shows a chip), and a
|
|
148
|
+
> full-screen window takes `top: var(--yui-dock-inset-top, 0px)` and a height
|
|
149
|
+
> that leaves both bands out. A maximized window is therefore that much shorter
|
|
150
|
+
> with a floating dock; an inline dock keeps no band (it is in the layout).
|
|
151
|
+
>
|
|
152
|
+
> **A window is a dialog (7.26.43).** `focus`, `modal` and `keyboard` were
|
|
153
|
+
> declared and did nothing up to 7.26.42: a window took no focus, closed with no
|
|
154
|
+
> key, kept nothing in and had no role. Now:
|
|
155
|
+
>
|
|
156
|
+
> - it is `role="dialog"`, named by its title (`aria-labelledby` on the two
|
|
157
|
+
> halves, `title_prefix` and `title`, so the name changes language; under a
|
|
158
|
+
> `header` of the caller's the title is still there, `is-sr-only`);
|
|
159
|
+
> - when it **starts** (`gobj_start`, so a host that fills the body after
|
|
160
|
+
> creating it can name what it put there) in answer to the reader -- a press
|
|
161
|
+
> or a key, the browser's user activation -- it takes the focus: `focus` is an
|
|
162
|
+
> element of the window, a selector looked up in it, or a number (the n-th
|
|
163
|
+
> control of the body); by default the window itself (`tabindex="-1"`). A
|
|
164
|
+
> window the app opens on its own (the Developer window restored at start up
|
|
165
|
+
> from the last session) leaves the focus in the page, or a keyboard reader's
|
|
166
|
+
> first Tab lands in a window they did not open; a modal one takes it always.
|
|
167
|
+
> When it goes, the focus goes back where it was -- if it was in the window;
|
|
168
|
+
> - **Escape closes it** (`keyboard`, `true` by default) when the focus is in
|
|
169
|
+
> it, the way its ✕ does: `EV_CLOSE_WINDOW`, so `EV_WINDOW_TO_CLOSE` still
|
|
170
|
+
> vetoes or asks. Not an Escape that what it was typed in took first: a
|
|
171
|
+
> handler that called `preventDefault()` (a Tom Select list, the json
|
|
172
|
+
> editor's search box), an input method composing, an inline editor that
|
|
173
|
+
> closed with the key (Tabulator cancels a cell edit by removing the box --
|
|
174
|
+
> the window then takes the focus back), a `textarea` or a
|
|
175
|
+
> `contenteditable` (what is being written is not lost to one key). Turn it
|
|
176
|
+
> off with `keyboard: false`; the key then goes on to the shell;
|
|
177
|
+
> - a **`modal`** one blocks the rest of the app: it hangs over a backdrop in
|
|
178
|
+
> the shell's dialog layer (`yui_shell_modal_layer()`; above the drawer, the
|
|
179
|
+
> dock and every other window, below the toasts, and a question it asks opens
|
|
180
|
+
> above it), `aria-modal="true"`, a press on the backdrop does nothing, and
|
|
181
|
+
> Tab stays inside (the trap of the shell's dialogs). It never goes to the
|
|
182
|
+
> dock: a `manager` given to a modal window is ignored, with a warning.
|
|
183
|
+
>
|
|
184
|
+
> ```js
|
|
185
|
+
> const win = gobj_create_service("keys", "C_YUI_WINDOW", {
|
|
186
|
+
> title_prefix: topic, // data, never translated
|
|
187
|
+
> title: "keys", // the key
|
|
188
|
+
> body: $box,
|
|
189
|
+
> focus: ".KEYS_FILTER", // the filter box takes the focus
|
|
190
|
+
> modal: true, // answer it before anything else
|
|
191
|
+
> }, gobj);
|
|
192
|
+
> gobj_start(win); // opened by the reader: the focus moves here
|
|
193
|
+
> ```
|
|
194
|
+
>
|
|
195
|
+
> **The shell's Escape follows the same rule (7.26.43).** It closed the
|
|
196
|
+
> overlay on top of its chain for any Escape: one typed in a table cell being
|
|
197
|
+
> edited inside a dialog cancelled the edit and closed the dialog with it. The
|
|
198
|
+
> rule is one function, `escape_is_taken()` (`src/escape_taken.js`).
|
|
199
|
+
>
|
|
200
|
+
> **The focus trap counts only what is drawn (7.26.43).** The adaptive dialog's
|
|
201
|
+
> back arrow is the first control of every dialog and is `display:none` on a
|
|
202
|
+
> laptop: the trap gave it the focus on opening (so the focus stayed outside
|
|
203
|
+
> the dialog), and every Tab after that "wrapped" to it, did nothing and was
|
|
204
|
+
> prevented -- the keyboard never got into a dialog. It now skips a control
|
|
205
|
+
> that is not drawn.
|
|
140
206
|
|
|
141
207
|
## Two maintained lines
|
|
142
208
|
|
|
@@ -3339,7 +3405,11 @@ is not even in the tree. So:
|
|
|
3339
3405
|
nothing); two controls of one name with one count say it once. The next
|
|
3340
3406
|
turn starts a message of its own: the shell posts itself
|
|
3341
3407
|
`EV_CLOSE_BADGE_NEWS` on the first change of a turn, which closes it on the
|
|
3342
|
-
next one -- a deferral through the machine, not a time.
|
|
3408
|
+
next one -- a deferral through the machine, not a time. A turn is
|
|
3409
|
+
therefore up to that delivery (`gobj_post_event()` runs it from a
|
|
3410
|
+
`setTimeout(0)`), not one task of the browser: a message of the socket
|
|
3411
|
+
already queued may be handled first, and what it changes joins the same
|
|
3412
|
+
message -- news that arrive together are said together.
|
|
3343
3413
|
|
|
3344
3414
|
```js
|
|
3345
3415
|
/* One action: both are said -- "Alerts, 3" and "Modals, 3" */
|
|
@@ -3418,7 +3488,15 @@ meant for the question, reached the modal, which asked again, and on a phone
|
|
|
3418
3488
|
a warning) -- is the veto, and a Back that asked gets its entry back when it
|
|
3419
3489
|
settles. A `true` that comes after the guard closed the modal itself closes
|
|
3420
3490
|
nothing twice. Up to `7.26.41` any promise was a veto, so an `async` guard --
|
|
3421
|
-
which always answers a promise -- left a modal that nobody could close
|
|
3491
|
+
which always answers a promise -- left a modal that nobody could close.
|
|
3492
|
+
|
|
3493
|
+
**An `async` guard closes with `return true`, never with `return;`.** Without
|
|
3494
|
+
`async` a bare `return;` closes; with it, the guard settles with `undefined`,
|
|
3495
|
+
which is the veto -- and when the guard opened nothing through the shell, no
|
|
3496
|
+
question is on the screen and the modal simply does not close. That case is
|
|
3497
|
+
said in the log (`7.26.43`+): *"before_close settled with undefined and asked
|
|
3498
|
+
nothing"*. An `undefined` from a guard that asked is its "no", and says
|
|
3499
|
+
nothing.
|
|
3422
3500
|
|
|
3423
3501
|
```js
|
|
3424
3502
|
/* An async guard: true closes, false keeps it up */
|
|
@@ -3524,15 +3602,6 @@ true. A record that lacks a defaulted field opens changed and closes without
|
|
|
3524
3602
|
a question; until 7.26.39 it asked on every close, about nothing the reader
|
|
3525
3603
|
would lose.
|
|
3526
3604
|
|
|
3527
|
-
What the reader does to a TABLE of the form -- edits a cell, adds a row,
|
|
3528
|
-
deletes one, in a nested table too -- is `edited` like anything typed, whatever
|
|
3529
|
-
the record the form opened with. Each table hears it from the moment it is
|
|
3530
|
-
built (a nested one is built by its row, whenever the row is drawn); the rows
|
|
3531
|
-
the form loads itself say nothing. In 7.26.39 and 7.26.40 a form that opened
|
|
3532
|
-
changed did not hear its tables at all, so closing it lost a table edit without
|
|
3533
|
-
a question. And the titles of those tables change language with the shell's
|
|
3534
|
-
`EV_LANGUAGE_CHANGED` (7.26.41+), like the rest of the form.
|
|
3535
|
-
|
|
3536
3605
|
```js
|
|
3537
3606
|
const kw = {abort_close: false};
|
|
3538
3607
|
gobj_send_event(form, "EV_WINDOW_TO_CLOSE", kw, gobj);
|
|
@@ -3541,6 +3610,52 @@ if(kw.abort_close) {
|
|
|
3541
3610
|
}
|
|
3542
3611
|
```
|
|
3543
3612
|
|
|
3613
|
+
What the reader does to a TABLE of the form -- edits a cell, adds a row,
|
|
3614
|
+
deletes one, in a nested table too -- is `edited` like anything typed, whatever
|
|
3615
|
+
the record the form opened with. Each table hears it from the moment it is
|
|
3616
|
+
built (a nested one is built by its row, the first time the row is drawn); the
|
|
3617
|
+
rows the form loads itself say nothing. In 7.26.39 and 7.26.40 a form that
|
|
3618
|
+
opened changed did not hear its tables at all, so closing it lost a table edit
|
|
3619
|
+
without a question. And the titles of those tables change language with the
|
|
3620
|
+
shell's `EV_LANGUAGE_CHANGED` (7.26.41+), like the rest of the form.
|
|
3621
|
+
|
|
3622
|
+
A table hears the reader through Tabulator's `dataChanged`, which Tabulator
|
|
3623
|
+
does not say for `setData()` / `replaceData()`, nor when its `history` module
|
|
3624
|
+
undoes or redoes a cell edit or a row move (`Ctrl+Z`; a row added or deleted
|
|
3625
|
+
is said). The form uses none of them (it loads with `addData()`, and `history`
|
|
3626
|
+
is off); a host that does -- through `$table.tabulator`, or by turning
|
|
3627
|
+
`history` on in `tabulator_settings` -- marks the form edited itself with
|
|
3628
|
+
`EV_RECORD_CHANGED`.
|
|
3629
|
+
|
|
3630
|
+
**Undo gives the tables back the rows the form was loaded with** (7.26.43+).
|
|
3631
|
+
Tabulator keeps the objects it is given and writes a cell edit into them, so
|
|
3632
|
+
the form hands each table its own copy of the record's rows. Up to 7.26.42 it
|
|
3633
|
+
handed the record's own: an edit wrote into the record (and into the host's
|
|
3634
|
+
object, when the host kept the one it sent), Undo loaded that record again --
|
|
3635
|
+
the edit -- and cleared `edited`, so the close did not ask and a later save
|
|
3636
|
+
sent what the reader believed undone. What a save publishes is a copy too, so
|
|
3637
|
+
an edit after the save does not reach what the host was given.
|
|
3638
|
+
|
|
3639
|
+
A row's nested tables live as long as the row: a reload, an Undo, a Clear, a
|
|
3640
|
+
row the reader deletes and the form's destroy destroy them, and a row drawn
|
|
3641
|
+
again (a forced `redraw(true)`, a column rebuilt) keeps them with their rows.
|
|
3642
|
+
Up to 7.26.42 nothing destroyed them -- five reloads of two rows left ten
|
|
3643
|
+
orphan tables in Tabulator's registry, for the life of the page -- and a row
|
|
3644
|
+
drawn again built new ones, empty. A table loads its rows in ONE call
|
|
3645
|
+
(`addData()`) and is redrawn once; it added them one by one and redrew the
|
|
3646
|
+
table after each, so 300 rows took 20 s to load (0.14 s now), and 300 with a
|
|
3647
|
+
nested table each 39 s (3 s now).
|
|
3648
|
+
|
|
3649
|
+
A host marks the form edited again with `EV_RECORD_CHANGED`, when what the
|
|
3650
|
+
reader changed is unsaved once more: a save the form published but the host
|
|
3651
|
+
could not send (the transport was down). The form keeps its values, lights
|
|
3652
|
+
its save, and the next close asks.
|
|
3653
|
+
|
|
3654
|
+
```js
|
|
3655
|
+
// the save never left: what the reader typed is still theirs to lose
|
|
3656
|
+
gobj_send_event(form, "EV_RECORD_CHANGED", {}, gobj);
|
|
3657
|
+
```
|
|
3658
|
+
|
|
3544
3659
|
### `C_YUI_FORM` — which field is editable, and the one `writable` does not govern
|
|
3545
3660
|
|
|
3546
3661
|
A form opened to LOOK at a record has no editable field: that is a property of
|
|
@@ -3842,6 +3957,19 @@ and reads back the bundle each host serves (`--check` only reads back,
|
|
|
3842
3957
|
consumers are listed in `~/.yuneta/gobj-ui-consumers.json` (see
|
|
3843
3958
|
`scripts/gobj-ui-consumers.example.json`); the demo (`test-app/`) is built in.
|
|
3844
3959
|
|
|
3960
|
+
An app whose range cannot be raised safely is refused and left as it was --
|
|
3961
|
+
every package.json of it, since all are checked before any is written: a
|
|
3962
|
+
range that is not a `^` of the version's major, a range AHEAD of the version
|
|
3963
|
+
(the source tree the version is read from is behind: raising it would lower
|
|
3964
|
+
it), a version that is not x.y.z. A registry that serves a NEWER version than
|
|
3965
|
+
the tree stops the round at once and says so. A range found already raised
|
|
3966
|
+
raises the app's version all the same when nobody raised it with the range (a
|
|
3967
|
+
range raised by hand), and leaves it when it did (the round run twice, a
|
|
3968
|
+
package.json two apps share): the package.json's git history says which, and
|
|
3969
|
+
one whose history cannot be read is refused (since `7.26.43`; up to `7.26.42`
|
|
3970
|
+
a refused app kept the files raised before the refusal, `--no-wait` could
|
|
3971
|
+
lower a range, and "already" deployed a new bundle under the old number).
|
|
3972
|
+
|
|
3845
3973
|
### Colour: a brand token as INK takes `-on-scheme`, as a FILL it does not
|
|
3846
3974
|
|
|
3847
3975
|
A Bulma brand colour (`--bulma-link`, `--bulma-danger`, …) is built to carry
|
|
@@ -3961,7 +4089,14 @@ DOM is a race with the next one:
|
|
|
3961
4089
|
that opens a dropdown, which the editor names not at all, is `more
|
|
3962
4090
|
options`. **A documented limit:** what the editor draws with no hook --
|
|
3963
4091
|
its search box, its repair messages, the tip at the foot of the context
|
|
3964
|
-
menu, its sort and transform modals -- stays in its English
|
|
4092
|
+
menu, its sort and transform modals -- stays in its English. Why:
|
|
4093
|
+
vanilla-jsoneditor (3.13.0) has no i18n option. Those words are literals
|
|
4094
|
+
inside its Svelte components (the tip is a fixed string handed to the
|
|
4095
|
+
context menu), `createJSONEditor()` takes no translation, and its only
|
|
4096
|
+
hooks are `onRenderMenu`, `onRenderContextMenu`, `onRenderValue` and
|
|
4097
|
+
`onClassName`. What is left is a fork, or rewriting the editor's DOM by
|
|
4098
|
+
its English words after each render -- which this module refuses: an
|
|
4099
|
+
item is known by its class or its place, never by its words;
|
|
3965
4100
|
- maplibre's canvas and default markers, whose `aria-label` maplibre writes
|
|
3966
4101
|
once from its locale: `yui_maplibre_relocalize()` rewrites them.
|
|
3967
4102
|
- **An `<option>`**, which is text like any other: it carries `data-i18n`,
|
|
@@ -4047,6 +4182,16 @@ locale, so they are drawn again and no column is rebuilt -- `updateDefinition()`
|
|
|
4047
4182
|
re-renders every row, and a row formatter that builds something in its row (a
|
|
4048
4183
|
nested table) builds it again, empty.
|
|
4049
4184
|
|
|
4185
|
+
A column GROUP is bound by field as well, and Tabulator gives a group none, so
|
|
4186
|
+
its title stays in the language the table was built in. Give the group a
|
|
4187
|
+
`field` -- no row reads a group's -- and hand its title like any other; a group
|
|
4188
|
+
without one is said in the log when titles are handed (`7.26.43`+):
|
|
4189
|
+
|
|
4190
|
+
```js
|
|
4191
|
+
columns: [{title: t("sizes"), field: "sizes", columns: [...]}]
|
|
4192
|
+
yui_tabulator_relocalize(table, t, {sizes: t("sizes"), width: t("width")});
|
|
4193
|
+
```
|
|
4194
|
+
|
|
4050
4195
|
**A missing key is invisible:** i18next answers an unknown key **with the key
|
|
4051
4196
|
itself**, so it renders (lower-case English) and simply never changes language.
|
|
4052
4197
|
A **duplicate** key in a locale file is silent too — an object literal keeps the
|
|
@@ -4109,13 +4254,20 @@ by it, because the item has no `name` (a node, no `label`):
|
|
|
4109
4254
|
|
|
4110
4255
|
- a menu item (of `menu.<id>.items` or of a `submenu.items`) with neither a
|
|
4111
4256
|
`name` nor an `aria_label`: `C_YUI_NAV` names it `name || aria_label || id`
|
|
4112
|
-
in every layout
|
|
4257
|
+
in every layout, and the navs of its submenu and the landing of a section
|
|
4258
|
+
index it opens (`submenu.index`) are labelled the same way;
|
|
4113
4259
|
- a menu item with no `name` in a breadcrumb that shows its labels (the text
|
|
4114
|
-
of the crumb is `name || id`)
|
|
4115
|
-
|
|
4260
|
+
of the crumb is `name || id`);
|
|
4261
|
+
- a MENU (`menu.<id>`) drawn as a `"submenu"` in a zone that hosts it: that
|
|
4262
|
+
layout heads the nav with its label, and the shell gives a menu none, so the
|
|
4263
|
+
heading is the menu's id (since `7.26.43`; `7.26.42` asked for neither);
|
|
4116
4264
|
- a toolbar item, the menu of a toolbar dropdown, or an entry of one, with
|
|
4117
4265
|
neither an `aria_label` nor a `name`: the shell names them
|
|
4118
|
-
`aria_label || name || id` (an avatar's menu is the library's "user
|
|
4266
|
+
`aria_label || name || id` (an avatar's menu is the library's "user
|
|
4267
|
+
menu"). The menu a RIGHT-click opens (`context_action`, wired on an action
|
|
4268
|
+
item and on a connection) is named the same way, and read the same way,
|
|
4269
|
+
since `7.26.43`: up to `7.26.42` the shell named it by the raw id whatever
|
|
4270
|
+
the item declared, and the validator did not read it;
|
|
4119
4271
|
- a row the SITE MAP draws, labelled as its control is named: the rows of the
|
|
4120
4272
|
dropdown action of a menu entry with no submenu (`name || aria_label ||
|
|
4121
4273
|
id`), and every row under a toolbar item that is not the brand, at every
|
|
@@ -4160,7 +4312,14 @@ runs -- the app's own code, but code. Comments are not code. A key is read
|
|
|
4160
4312
|
where it is WRITTEN -- given to a translator, as an `i18n` or `data-i18n*`
|
|
4161
4313
|
value of an object literal, by `setAttribute()`, or (since `7.26.29`) written
|
|
4162
4314
|
as a member, `attrs.i18n = "save"`, `attrs["data-i18n-title"] = "save"` -- and
|
|
4163
|
-
FOLLOWED where the source writes it out.
|
|
4315
|
+
FOLLOWED where the source writes it out. A `code` property is a key only in
|
|
4316
|
+
the modules of this library whose codes are keys -- the findings and conflicts
|
|
4317
|
+
of the schema checks, which the schema editor hands to `t(finding.code)`
|
|
4318
|
+
(`CODE_KEY_MODULES`) -- and in an app that names it in its `attr_keys`. Up to
|
|
4319
|
+
`7.26.42` every `code` of every file was read as one, `{code: "en"}` asked
|
|
4320
|
+
for "en", and so was every `add("error", x)`, `classList.add("error",
|
|
4321
|
+
"has-text-danger")` included (the schema checks' own `add()` is a key
|
|
4322
|
+
function of the table).
|
|
4164
4323
|
|
|
4165
4324
|
A **translator** is one notion, the same everywhere the reader asks "is this a
|
|
4166
4325
|
call of t()?" (since `7.26.32`; up to `7.26.31` it was a call NAMED `t` or
|
|
@@ -4175,7 +4334,8 @@ each one is a key: `t([specific, "generic"])` asks for "generic". A `.bind()`
|
|
|
4175
4334
|
that binds a KEY makes a translator whose calls hand i18next its options or its
|
|
4176
4335
|
default value: `const tk = t.bind(null, "save"); tk({count: 2})` (since
|
|
4177
4336
|
`7.26.42`; up to `7.26.41` what `tk()` was handed was asked for as a key). The
|
|
4178
|
-
key it binds is
|
|
4337
|
+
key it binds is read where the bind is written: `t.bind(null, "save")` asks
|
|
4338
|
+
for "save" (since `7.26.43`; up to `7.26.42` it was not read). The places,
|
|
4179
4339
|
since `7.26.32`, also include `el.dataset.i18nTitle = k` (`dataset.i18nX` IS
|
|
4180
4340
|
the attribute `data-i18n-x`), and an attribute or property NAMED by a const:
|
|
4181
4341
|
`el.setAttribute(ATTR, k)`, `{[ATTR]: k}`, `x[ATTR] = k`, with `const ATTR =
|
|
@@ -4185,8 +4345,9 @@ translator handed as a CALLBACK -- in these forms, and no other:
|
|
|
4185
4345
|
- the methods `map`, `flatMap`, `forEach`, `filter`, `find`, `findIndex`,
|
|
4186
4346
|
`findLast`, `findLastIndex`, `some`, `every` (`findIndex` and
|
|
4187
4347
|
`findLastIndex` since `7.26.42`), called on the array -- `keys.map(t)`,
|
|
4188
|
-
`keys?.map(t)`, `keys["map"](t)` -- or (since
|
|
4189
|
-
`.apply()` of the method,
|
|
4348
|
+
`keys?.map(t)`, and (since `7.26.42`) `keys["map"](t)` -- or (since
|
|
4349
|
+
`7.26.42` too) by `.call()` / `.apply()` of the method,
|
|
4350
|
+
`Array.prototype.map.call(keys, t)`,
|
|
4190
4351
|
`[].forEach.apply(keys, [t])`; and `Array.from(keys, t)`,
|
|
4191
4352
|
`Array.fromAsync(keys, t)`: each ELEMENT is a key, read like any other -- a
|
|
4192
4353
|
const array, a published list, an import of one are followed;
|
|
@@ -4263,7 +4424,7 @@ element of one -- is followed (below). A source file that cannot be parsed
|
|
|
4263
4424
|
fails the build, because its keys would go unchecked.
|
|
4264
4425
|
|
|
4265
4426
|
**An UNMARKED `let` that is only ever given literals IS followed** (since
|
|
4266
|
-
`7.26.35`), where `t()`, an `i18n`
|
|
4427
|
+
`7.26.35`), where `t()`, an `i18n` value or a `data-i18n*` attribute
|
|
4267
4428
|
reads a key: when every value it is given in its scope -- its initializer, every
|
|
4268
4429
|
`=`, `||=`, `??=`, `&&=`, the value of a `var` of it declared again -- is
|
|
4269
4430
|
WRITTEN as a string literal, a const bound to one (of the module, or imported),
|
|
@@ -4355,7 +4516,26 @@ that receives a key, and where it is:
|
|
|
4355
4516
|
|
|
4356
4517
|
A position is an argument (`"1"`), a property of the object given there
|
|
4357
4518
|
(`"2.title"`, also through `Object.assign()` or a spread of a const object),
|
|
4358
|
-
or a property of each object of an array (`"1.actions[].label"`).
|
|
4519
|
+
or a property of each object of an array (`"1.actions[].label"`). A position
|
|
4520
|
+
that is only the FALLBACK of others the function reads first says so in the
|
|
4521
|
+
entry's `fallbacks` (since `7.26.43`):
|
|
4522
|
+
|
|
4523
|
+
```js
|
|
4524
|
+
{module: "nav_cards_helpers.js", name: "card_descriptor", exported: true,
|
|
4525
|
+
keys: ["0.name", "0.tooltip", "0.aria_label", "0.id"],
|
|
4526
|
+
fallbacks: {"0.id": ["0.name", "0.aria_label"]}},
|
|
4527
|
+
```
|
|
4528
|
+
|
|
4529
|
+
`card_descriptor()` names a card `it.name || it.aria_label || it.id`, so an
|
|
4530
|
+
object that surely gives a `name` or an `aria_label` (a non-empty string in
|
|
4531
|
+
every value it can take) never reaches its `id`: `card_descriptor({id:
|
|
4532
|
+
"card_internal_id", name: "save"})` asks for "save" and not for
|
|
4533
|
+
"card_internal_id", and `{id: row.id, name: "ok"}` passes the rule per call.
|
|
4534
|
+
One that may give neither (`{id: "x", name: row.name}`, a parameter) reaches
|
|
4535
|
+
it. The test of the table proves every `fallbacks` against the code: each
|
|
4536
|
+
hand-off of the position is the right side of a `||` whose left reads the
|
|
4537
|
+
positions named (or a key position of a key function whose `fallbacks` say as
|
|
4538
|
+
much). Up to `7.26.42` the id of a card was a key in every case. What is
|
|
4359
4539
|
given at those positions is read like any other key (literals, consts,
|
|
4360
4540
|
branches): in the app's own code, on a call that reaches that function of
|
|
4361
4541
|
gobj-ui (an app function of the same name is not mistaken for it), and in
|
|
@@ -4366,7 +4546,12 @@ member): an import under any name, a re-export from a file of the app
|
|
|
4366
4546
|
(`export {yui_shell_show_info as say} from "@yuneta/gobj-ui/src/shell_modals.js"`),
|
|
4367
4547
|
a const alias (`const show = yui_shell_show_info`), a map in a const
|
|
4368
4548
|
(`const API = {info: yui_shell_show_info}; API.info(...)`, imported too),
|
|
4369
|
-
`.call(x, ...)` and `.apply(x, [...])`.
|
|
4549
|
+
`.call(x, ...)` and `.apply(x, [...])`; and a `.bind()` of it is read as the
|
|
4550
|
+
call it prepares, at the positions it binds (since `7.26.43`):
|
|
4551
|
+
`yui_shell_show_info.bind(null, shell, "k")` asks for "k", and a parameter
|
|
4552
|
+
bound there fails the rule per call as it does when it is handed directly. Up
|
|
4553
|
+
to `7.26.42` what a bind binds was not read, and the forwarder search missed a
|
|
4554
|
+
function that hands its parameter on that way. A position may also hold
|
|
4370
4555
|
DOM, which is no key (since `7.26.29`): an array (a `createElement2` spec), a
|
|
4371
4556
|
call of `createElement2()`, `createOneHtml()` or `html_markup()` imported
|
|
4372
4557
|
from gobj-js, of `text_node()` from gobj-ui, of `document.createElement()`
|
|
@@ -4381,9 +4566,9 @@ variable: `$box` says nothing. The exported ones an app calls:
|
|
|
4381
4566
|
/ `yui_asset_element` (`key`), `hook_cell_spec` (the title key),
|
|
4382
4567
|
`period_name` (a granularity id), `card_descriptor` / `cards_grid_descriptor`
|
|
4383
4568
|
(a nav item's `name`, `tooltip`, `aria_label`, and its `id`: the key of an
|
|
4384
|
-
item with
|
|
4385
|
-
name of a graph's main canvas) and
|
|
4386
|
-
titles it).
|
|
4569
|
+
item with neither a `name` nor an `aria_label`), `keep_canvas_tab_order` /
|
|
4570
|
+
`set_canvas_tab_order` (the name of a graph's main canvas) and
|
|
4571
|
+
`open_gclass_view` (the gclass name, which titles it).
|
|
4387
4572
|
|
|
4388
4573
|
**Every function that forwards a key is in the table, and a test finds them**
|
|
4389
4574
|
(since `7.26.29`: up to `7.26.28` the table lacked 39 of them, and 6 entries
|
|
@@ -4736,8 +4921,8 @@ src/c_app.js:734 (call at line 732): yui_install_ask_once() [1.message] is given
|
|
|
4736
4921
|
```
|
|
4737
4922
|
|
|
4738
4923
|
Such a text fails EVERYWHERE a key is read, marked or not: given to `t()`
|
|
4739
|
-
(`t(t("k") + "!")`), to an `i18n` / `
|
|
4740
|
-
(`{i18n: t("k").trim()}`, `el.dataset.i18nTitle = t("k")`), or to a
|
|
4924
|
+
(`t(t("k") + "!")`), to an `i18n` / `data-i18n*` value -- a `code` where it is
|
|
4925
|
+
a key -- (`{i18n: t("k").trim()}`, `el.dataset.i18nTitle = t("k")`), or to a
|
|
4741
4926
|
`data-i18n*` attribute (`el.setAttribute("data-i18n-title", t("k"))`), and
|
|
4742
4927
|
through a `const` that holds one. The place keeps the translation as its key,
|
|
4743
4928
|
so it never changes language. Up to `7.26.41` only a MARKED one failed there:
|
|
@@ -4835,10 +5020,6 @@ reading the page in another language:
|
|
|
4835
5020
|
`let` alias, `opts.translate(k)`, `i18next.getFixedT()` --, or one called
|
|
4836
5021
|
through what is no name of it: `(0, t)(k)`, `[t][0](k)`,
|
|
4837
5022
|
`Reflect.apply(t, x, [k])`, `Function.prototype.call.call(t, x, k)`;
|
|
4838
|
-
- a key BOUND with the translator, `t.bind(null, k)` (`.bind()` is read as an
|
|
4839
|
-
alias of the translator, and the key it binds is not read; what a call of
|
|
4840
|
-
it is handed is i18next's options or default value, and since `7.26.42` it
|
|
4841
|
-
is not read as a key either);
|
|
4842
5023
|
- a translator handed to a FUNCTION (`{t: t}`, `yui_tabulator_lang(t)`,
|
|
4843
5024
|
`run(t)`) or to any method but those listed above (`keys.reduce(t)`,
|
|
4844
5025
|
`keys.sort(t)`, an alias of a method, `Reflect.apply()`): only those
|
|
@@ -4895,13 +5076,23 @@ reading the page in another language:
|
|
|
4895
5076
|
list has -- or whose every key of that shape a narrower marked template
|
|
4896
5077
|
builds;
|
|
4897
5078
|
- a TRANSLATED text where a key is read, marked or not: given to `t()`, to an
|
|
4898
|
-
`i18n` / `
|
|
4899
|
-
`7.26.42`; up to `7.26.41` only a marked one
|
|
4900
|
-
of a key function (the rule per call, above);
|
|
5079
|
+
`i18n` / `data-i18n*` value (a `code` where it is a key) or to a
|
|
5080
|
+
`data-i18n*` attribute (since `7.26.42`; up to `7.26.41` only a marked one
|
|
5081
|
+
failed), or to a key position of a key function (the rule per call, above);
|
|
4901
5082
|
- a key position of a key function, in the app's own code, given what the
|
|
4902
5083
|
reader cannot follow and unmarked (the rule per call, above); and so a
|
|
4903
5084
|
translator handed as a callback to one of the methods above over an array
|
|
4904
|
-
the reader cannot follow, or to `.then()` / `.catch()`, unmarked
|
|
5085
|
+
the reader cannot follow, or to `.then()` / `.catch()`, unmarked;
|
|
5086
|
+
- a value the reader GIVES UP on, with the file and the line (since
|
|
5087
|
+
`7.26.43`): a chain of consts, aliases or calls more than 24 steps deep, a
|
|
5088
|
+
const that leads back to itself, an expression that can take more than
|
|
5089
|
+
10000 values. A key behind it would go unasked. Up to `7.26.42` the reader
|
|
5090
|
+
stopped there in silence -- a chain of 24 aliases of a const, or of 12
|
|
5091
|
+
consts that branch, asked for nothing at its far end, and the build passed
|
|
5092
|
+
-- and a chain of consts that doubles at every link (`const O1 = c()? O0 :
|
|
5093
|
+
{...O0, ...O0}`) grew three times at every link until it died with a
|
|
5094
|
+
`RangeError` that named no file. A const is now read once, wherever it is
|
|
5095
|
+
read, and a spread of the same object or array twice gives its values once.
|
|
4905
5096
|
|
|
4906
5097
|
Up to `7.26.27` the locale cases were "skipped" with an OK: one language less
|
|
4907
5098
|
validated, and nobody told. A file of the locales directory with a locale's
|