@yuneta/gobj-ui 7.26.41 → 7.26.43
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 +510 -78
- package/dist/gobj-ui.cjs.js +1120 -326
- package/dist/gobj-ui.es.js +1120 -326
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +971 -177
- package/src/c_g6_nodes_tree.js +3 -2
- package/src/c_yui_form.js +261 -154
- package/src/c_yui_fsm_graph.js +3 -2
- package/src/c_yui_gobj_tree_js.js +3 -2
- package/src/c_yui_json_graph.js +3 -2
- package/src/c_yui_nav.js +43 -28
- package/src/c_yui_node.js +51 -7
- package/src/c_yui_schema_editor.css +16 -0
- package/src/c_yui_schema_editor.js +110 -20
- package/src/c_yui_shell.css +4 -1
- package/src/c_yui_shell.js +227 -61
- package/src/c_yui_treedb_schema.js +3 -2
- package/src/c_yui_window.js +373 -62
- package/src/c_yui_window_manager.js +80 -8
- 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 +489 -0
- package/src/form_table_validator.wiring.test.js +8 -4
- package/src/form_template_field.wiring.test.js +6 -3
- package/src/g6_canvas_tab_order.css +29 -0
- package/src/g6_canvas_tab_order.js +41 -9
- package/src/g6_canvas_tab_order.wiring.test.js +107 -1
- package/src/g6_long_press_clock.test.js +8 -3
- package/src/i18n_key_functions.js +81 -27
- package/src/i18n_key_functions.test.js +402 -4
- package/src/modal_guard_back.wiring.test.js +188 -0
- package/src/named_controls.wiring.test.js +323 -19
- package/src/nav_cards_helpers.js +9 -4
- package/src/nav_item_badge.wiring.test.js +163 -15
- package/src/node_nav_events.wiring.test.js +93 -1
- package/src/route_map_model.js +59 -10
- package/src/route_map_model.test.js +90 -0
- package/src/schema_editor_diagram_click.wiring.test.js +277 -0
- package/src/schema_editor_openers.wiring.test.js +283 -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 +113 -22
- package/src/shell_route_map.js +15 -3
- package/src/shell_section_index.js +3 -1
- 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_layer.wiring.test.js +114 -0
- package/src/window_rect_rounding.wiring.test.js +121 -0
- package/src/yui_gclass_view.js +16 -1
- package/src/yui_tabulator_i18n.js +31 -1
- package/src/yui_tabulator_i18n.test.js +46 -0
package/README.md
CHANGED
|
@@ -114,6 +114,20 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
|
|
|
114
114
|
> entry closed the invisible one. Its Back entry goes with the shell that held
|
|
115
115
|
> it: after a re-login Back no longer closes it, its ✕ does.
|
|
116
116
|
>
|
|
117
|
+
> **A gclass viewer goes where the window it was opened from goes.** Opened
|
|
118
|
+
> from a window that hangs where the shell puts every window -- its window
|
|
119
|
+
> layer, the body while there is none -- it takes that place as its opener
|
|
120
|
+
> does, and follows the shell with it. Up to 7.26.41 it was given that element
|
|
121
|
+
> by name, as a `$parent`, which is a choice of its host: opened from the
|
|
122
|
+
> developer window between a logout and the next login, it stayed in the body
|
|
123
|
+
> after the login, above the new shell's dialogs. Opened from a window its host
|
|
124
|
+
> placed elsewhere, it hangs beside that window, there for good, as before.
|
|
125
|
+
>
|
|
126
|
+
> **With two shells alive** (no app has two), destroying the LAST one gives its
|
|
127
|
+
> windows to the one that remains: `yui_shell_of()` falls back to the last
|
|
128
|
+
> shell still alive. Up to 7.26.41 the fallback went empty, and they went to
|
|
129
|
+
> the body, above the dialogs of the shell that remained.
|
|
130
|
+
>
|
|
117
131
|
> **The dock** (`C_YUI_WINDOW_MANAGER`, floating) lives in the shell's popup
|
|
118
132
|
> layer, at the top of it: above every window, below the dialogs and the
|
|
119
133
|
> toasts. It was `document.body` at z-index 1000000, above the whole shell --
|
|
@@ -123,6 +137,72 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
|
|
|
123
137
|
> (minimise / bring back, named by the window's title, through the FSM:
|
|
124
138
|
> `EV_TOGGLE_WINDOW`) and its ✕ (`close`). It was a `role="button"` holding
|
|
125
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.
|
|
126
206
|
|
|
127
207
|
## Two maintained lines
|
|
128
208
|
|
|
@@ -131,7 +211,7 @@ consumers. They are independent snapshots (no shared git ancestry):
|
|
|
131
211
|
|
|
132
212
|
| Line | Branch | Latest tag | Layout | Consumed by | How | Status |
|
|
133
213
|
|------|--------|------------|--------|-------------|-----|--------|
|
|
134
|
-
| **v2** | `main` | `7.26.x` | `src/` subdir | **gui_agent**, **gui_treedb**, **wattyzer**, the **yunovatios** GUIs, **estadodelaire** (since 2026-10-13) | published npm `@yuneta/gobj-ui` (dist-tag `latest`) | active development |
|
|
214
|
+
| **v2** | `main` | `7.26.x` | `src/` subdir | **gui_agent**, **gui_treedb**, **wattyzer**, the **yunovatios** GUIs, **yunomusica**, **estadodelaire** (since 2026-10-13) | published npm `@yuneta/gobj-ui` (dist-tag `latest`) | active development |
|
|
135
215
|
| **v1** | `v1` | `1.0.4` | `src/` subdir | **hidraulia** | published npm `@yuneta/gobj-ui@^1.0.4` (dist-tag `legacy`) | frozen, maintenance-only |
|
|
136
216
|
|
|
137
217
|
- **v2 / `main`** is the active development line: the declarative shell
|
|
@@ -211,6 +291,19 @@ toggles it closed. The tree model is `yui_shell_nav_map()` /
|
|
|
211
291
|
protocols (`yui_shell_set_sub_routes`, `yui_shell_register_event_handler`)
|
|
212
292
|
live in [`ROUTING.md`](ROUTING.md).
|
|
213
293
|
|
|
294
|
+
**A row says the name its control says** -- one rule names an item
|
|
295
|
+
everywhere. A menu entry (a submenu entry, a runtime tab) is labelled as the
|
|
296
|
+
nav names it: its `name`, else its `aria_label`, else its id. A toolbar item
|
|
297
|
+
and a row of its dropdown as the toolbar names them: `aria_label` first, then
|
|
298
|
+
`name`, then the library's own key for an avatar (`user menu`) or a
|
|
299
|
+
connection dot (`backend connection`), else the id. All of them are KEYS, and
|
|
300
|
+
change language with the map. Two labels are not: the id of another menu (a
|
|
301
|
+
menu declares no name, so its group row shows its id as DATA) and a route (a
|
|
302
|
+
row that no item names has no label; its route is in its own column, and is
|
|
303
|
+
its link's name as data). The root row is the brand's `wordmark`: it names
|
|
304
|
+
the APP, where the brand button's `aria_label` says what pressing it does. Up
|
|
305
|
+
to `7.26.41` a row was labelled `name || wordmark || id || route`.
|
|
306
|
+
|
|
214
307
|
### C_YUI_NODE — navigation as a tree of gobjs (prototype)
|
|
215
308
|
|
|
216
309
|
`C_YUI_SHELL`'s menu tree is **two levels** (a primary item and its
|
|
@@ -1584,9 +1677,39 @@ the shared `keep_canvas_tab_order()` (`src/g6_canvas_tab_order.js`) right after
|
|
|
1584
1677
|
import {keep_canvas_tab_order} from "./g6_canvas_tab_order.js";
|
|
1585
1678
|
|
|
1586
1679
|
const graph = priv.graph = new Graph({container: priv.$container /* ... */});
|
|
1587
|
-
keep_canvas_tab_order(gobj, graph); // main canvas 0, the other layers -1
|
|
1680
|
+
keep_canvas_tab_order(gobj, graph, "treedb graph"); // main canvas 0, named; the other layers -1
|
|
1588
1681
|
```
|
|
1589
1682
|
|
|
1683
|
+
**The main canvas is a control, and it is NAMED** for the graph it draws: a
|
|
1684
|
+
`title` and an `aria-label` through `t()`, each with its key
|
|
1685
|
+
(`data-i18n-title`, `data-i18n-aria-label`), so a language switch reaches them
|
|
1686
|
+
as it reaches any control, and `role="region"` -- the role maplibre gives its
|
|
1687
|
+
own canvas, because ARIA forbids a name on an element with no role. Each view
|
|
1688
|
+
passes its key: `C_G6_NODES_TREE` **`treedb graph`**, `C_YUI_JSON_GRAPH`
|
|
1689
|
+
**`json graph`**, `C_YUI_GOBJ_TREE_JS` **`gobj tree graph`**,
|
|
1690
|
+
`C_YUI_FSM_GRAPH` **`fsm graph`**, `C_YUI_TREEDB_SCHEMA` **`schema graph`** --
|
|
1691
|
+
keys an app that mounts the view has in its locales. From `7.26.28` to
|
|
1692
|
+
`7.26.41` Tab landed on the canvas and a reader announced nothing.
|
|
1693
|
+
|
|
1694
|
+
**And the focused canvas can be SEEN.** G6 writes `outline: none` on its
|
|
1695
|
+
canvases, inline, so a keyboard that Tabbed onto the graph had no sign of
|
|
1696
|
+
where it was. The main canvas takes the logical class `G6_MAIN_CANVAS`, and
|
|
1697
|
+
`src/g6_canvas_tab_order.css` -- imported by the module, so it comes with every
|
|
1698
|
+
view -- draws the library's focus ring on it, `!important` because only that
|
|
1699
|
+
reaches an inline style:
|
|
1700
|
+
|
|
1701
|
+
```css
|
|
1702
|
+
.G6_MAIN_CANVAS:focus-visible {
|
|
1703
|
+
outline: 2px solid var(--bulma-link-on-scheme, var(--bulma-link, #485fc7)) !important;
|
|
1704
|
+
outline-offset: -2px !important;
|
|
1705
|
+
}
|
|
1706
|
+
```
|
|
1707
|
+
|
|
1708
|
+
`:focus-visible`, so a press of the pointer draws no ring (nor the focus a view
|
|
1709
|
+
gives the canvas on a press); the link colour as INK, legible on both schemes
|
|
1710
|
+
(see "Colour" below); inset, so a container that clips the graph does not clip
|
|
1711
|
+
the ring; no transition.
|
|
1712
|
+
|
|
1590
1713
|
The buttons of the graph are buttons for the keyboard too: the items of both
|
|
1591
1714
|
toolbars, the round buttons beside a selection — the gear and the trash of a
|
|
1592
1715
|
node or an edge, the link and the gear of a port — and the ✕ of a node's
|
|
@@ -2491,8 +2614,8 @@ What the screens offer:
|
|
|
2491
2614
|
|
|
2492
2615
|
| Screen | What it is for |
|
|
2493
2616
|
|--------|----------------|
|
|
2494
|
-
| treedbs | one card per treedb, with its topic count and its `schema_version` beside the `c_schema_version` it was projected from |
|
|
2495
|
-
| topics | the topics of one treedb in schema order: pkey, column count, version, system flag |
|
|
2617
|
+
| treedbs | one card per treedb, with its topic count and its `schema_version` beside the `c_schema_version` it was projected from. A card is a control: named by its treedb (a `title` and an `aria-label`), its counts its description, opened by a click, Enter or Space |
|
|
2618
|
+
| topics | the topics of one treedb in schema order: pkey, column count, version, system flag. A row is a row of the TABLE: the topic's name is the button that opens it (a key presses it), and a click anywhere in the row opens it too. Up to 7.26.41 the row was a `<tr role=button>` with no name, which a reader hears as a button with no cells |
|
|
2496
2619
|
| columns | the heart. Rows in `order`, **draggable** — `order` is a field, so a drop writes the rows whose place actually changed, two or three and not forty |
|
|
2497
2620
|
| diagram | the treedb **drawn from the records being edited**, through `C_YUI_TREEDB_SCHEMA` |
|
|
2498
2621
|
|
|
@@ -3263,9 +3386,36 @@ is not even in the tree. So:
|
|
|
3263
3386
|
`yui_shell_set_toolbar_item_badge()` say it when the text a reader would see
|
|
3264
3387
|
CHANGES and is not empty: the same count is no news, a count going away is
|
|
3265
3388
|
not either, one coming back is. A menu entry drawn by three navs is said
|
|
3266
|
-
once. The
|
|
3389
|
+
once. The name is the one its control says: a menu entry's `name`, else its
|
|
3390
|
+
`aria_label`, else its id (up to `7.26.41` an entry with only an
|
|
3391
|
+
`aria_label` was said by its id); a toolbar item's own key, `aria_label`
|
|
3392
|
+
first. The phrase is a key of its own, `"{{name}}, {{n}}"`, so a language
|
|
3267
3393
|
orders and punctuates it its way; it goes through the translator the app gave
|
|
3268
|
-
the shell (`yui_shell_set_translator`)
|
|
3394
|
+
the shell (`yui_shell_set_translator`), and it is TEXT: the name is not
|
|
3395
|
+
escaped for HTML (i18next escapes an interpolated value by default, and a
|
|
3396
|
+
name such as *"Événements d'alarme"* was read *"d'alarme"*).
|
|
3397
|
+
- **Every change of one turn of the loop is said, in ONE message**: a line of
|
|
3398
|
+
the region each (`.SHELL_BADGE_NEWS`), in the order they came. A reader
|
|
3399
|
+
hears the region as it stands when the turn is over, and up to `7.26.41`
|
|
3400
|
+
each change replaced its text -- so of two changes in one action only the
|
|
3401
|
+
second was ever said (the toolbar's count and a menu entry's, updated
|
|
3402
|
+
together by the same feed: exactly what the test-app's *alerts* button
|
|
3403
|
+
does). A badge that moves twice in the turn says its last count; one whose
|
|
3404
|
+
count goes away in the turn it came is not said at all (the badge shows
|
|
3405
|
+
nothing); two controls of one name with one count say it once. The next
|
|
3406
|
+
turn starts a message of its own: the shell posts itself
|
|
3407
|
+
`EV_CLOSE_BADGE_NEWS` on the first change of a turn, which closes it on the
|
|
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.
|
|
3413
|
+
|
|
3414
|
+
```js
|
|
3415
|
+
/* One action: both are said -- "Alerts, 3" and "Modals, 3" */
|
|
3416
|
+
yui_shell_set_toolbar_item_badge(shell, "alerts", 3);
|
|
3417
|
+
yui_shell_set_nav_item_badge(shell, "modals", 3);
|
|
3418
|
+
```
|
|
3269
3419
|
|
|
3270
3420
|
Up to `7.26.34` the badge was its own `role="status"`: it said *"3"* with no
|
|
3271
3421
|
word of what has three, it was `hidden` while empty -- so the first count was
|
|
@@ -3325,13 +3475,43 @@ keeps working afterwards. With no guard a modal closes exactly as it always
|
|
|
3325
3475
|
did, and the returned `close()` always closes **unconditionally** — the veto is
|
|
3326
3476
|
for the user's dismiss, not for the code's.
|
|
3327
3477
|
|
|
3328
|
-
**A guard that ASKS returns the question's promise** (7.26.38+). It
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3478
|
+
**A guard that ASKS returns the question's promise** (7.26.38+). It tells the
|
|
3479
|
+
modal when the question is over: a browser Back that asked gets its history
|
|
3480
|
+
entry back THEN, below nothing. Opening the question and returning `false` put
|
|
3481
|
+
the entry back at once, above the question's own -- so the next Back, the one
|
|
3482
|
+
meant for the question, reached the modal, which asked again, and on a phone
|
|
3483
|
+
(where Back is a gesture) every Back stacked one more question.
|
|
3484
|
+
|
|
3485
|
+
**What the promise SETTLES with is the answer.** `true` closes the modal, as a
|
|
3486
|
+
`true` returned at once does; anything else -- `false`, `undefined` (what a
|
|
3487
|
+
`.then()` that returns nothing settles with), a string, a rejection (logged as
|
|
3488
|
+
a warning) -- is the veto, and a Back that asked gets its entry back when it
|
|
3489
|
+
settles. A `true` that comes after the guard closed the modal itself closes
|
|
3490
|
+
nothing twice. Up to `7.26.41` any promise was a veto, so an `async` guard --
|
|
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.
|
|
3500
|
+
|
|
3501
|
+
```js
|
|
3502
|
+
/* An async guard: true closes, false keeps it up */
|
|
3503
|
+
before_close: async () => {
|
|
3504
|
+
const kw = {};
|
|
3505
|
+
gobj_send_event(form, "EV_WINDOW_TO_CLOSE", kw, gobj);
|
|
3506
|
+
if(!kw.abort_close) {
|
|
3507
|
+
return true;
|
|
3508
|
+
}
|
|
3509
|
+
return yui_shell_confirm_yesno(shell, "all changes will be lost", {t}); // true on "yes"
|
|
3510
|
+
},
|
|
3511
|
+
```
|
|
3512
|
+
|
|
3513
|
+
The guard below closes the modal itself on "yes", through an event, and its
|
|
3514
|
+
`.then()` returns nothing: a veto in both cases, as before.
|
|
3335
3515
|
|
|
3336
3516
|
```js
|
|
3337
3517
|
const sheet = yui_shell_show_modal(shell, $body, {
|
|
@@ -3422,15 +3602,6 @@ true. A record that lacks a defaulted field opens changed and closes without
|
|
|
3422
3602
|
a question; until 7.26.39 it asked on every close, about nothing the reader
|
|
3423
3603
|
would lose.
|
|
3424
3604
|
|
|
3425
|
-
What the reader does to a TABLE of the form -- edits a cell, adds a row,
|
|
3426
|
-
deletes one, in a nested table too -- is `edited` like anything typed, whatever
|
|
3427
|
-
the record the form opened with. Each table hears it from the moment it is
|
|
3428
|
-
built (a nested one is built by its row, whenever the row is drawn); the rows
|
|
3429
|
-
the form loads itself say nothing. In 7.26.39 and 7.26.40 a form that opened
|
|
3430
|
-
changed did not hear its tables at all, so closing it lost a table edit without
|
|
3431
|
-
a question. And the titles of those tables change language with the shell's
|
|
3432
|
-
`EV_LANGUAGE_CHANGED` (7.26.41+), like the rest of the form.
|
|
3433
|
-
|
|
3434
3605
|
```js
|
|
3435
3606
|
const kw = {abort_close: false};
|
|
3436
3607
|
gobj_send_event(form, "EV_WINDOW_TO_CLOSE", kw, gobj);
|
|
@@ -3439,6 +3610,52 @@ if(kw.abort_close) {
|
|
|
3439
3610
|
}
|
|
3440
3611
|
```
|
|
3441
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
|
+
|
|
3442
3659
|
### `C_YUI_FORM` — which field is editable, and the one `writable` does not govern
|
|
3443
3660
|
|
|
3444
3661
|
A form opened to LOOK at a record has no editable field: that is a property of
|
|
@@ -3740,6 +3957,19 @@ and reads back the bundle each host serves (`--check` only reads back,
|
|
|
3740
3957
|
consumers are listed in `~/.yuneta/gobj-ui-consumers.json` (see
|
|
3741
3958
|
`scripts/gobj-ui-consumers.example.json`); the demo (`test-app/`) is built in.
|
|
3742
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
|
+
|
|
3743
3973
|
### Colour: a brand token as INK takes `-on-scheme`, as a FILL it does not
|
|
3744
3974
|
|
|
3745
3975
|
A Bulma brand colour (`--bulma-link`, `--bulma-danger`, …) is built to carry
|
|
@@ -3859,7 +4089,14 @@ DOM is a race with the next one:
|
|
|
3859
4089
|
that opens a dropdown, which the editor names not at all, is `more
|
|
3860
4090
|
options`. **A documented limit:** what the editor draws with no hook --
|
|
3861
4091
|
its search box, its repair messages, the tip at the foot of the context
|
|
3862
|
-
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;
|
|
3863
4100
|
- maplibre's canvas and default markers, whose `aria-label` maplibre writes
|
|
3864
4101
|
once from its locale: `yui_maplibre_relocalize()` rewrites them.
|
|
3865
4102
|
- **An `<option>`**, which is text like any other: it carries `data-i18n`,
|
|
@@ -3945,6 +4182,16 @@ locale, so they are drawn again and no column is rebuilt -- `updateDefinition()`
|
|
|
3945
4182
|
re-renders every row, and a row formatter that builds something in its row (a
|
|
3946
4183
|
nested table) builds it again, empty.
|
|
3947
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
|
+
|
|
3948
4195
|
**A missing key is invisible:** i18next answers an unknown key **with the key
|
|
3949
4196
|
itself**, so it renders (lower-case English) and simply never changes language.
|
|
3950
4197
|
A **duplicate** key in a locale file is silent too — an object literal keeps the
|
|
@@ -4000,6 +4247,64 @@ declaration is a literal when it is the endonym of one of the app's locales
|
|
|
4000
4247
|
(the `name` its catalog exports: `"中文"`, `"español"`); any other lower-case
|
|
4001
4248
|
text is a key, `"configuración"` included.
|
|
4002
4249
|
|
|
4250
|
+
The keys of the shell declaration are the `name`, `aria_label` and `tooltip`
|
|
4251
|
+
of every item, the `label` of a node and the `title` / `subtitle` of a route
|
|
4252
|
+
-- and (since `7.26.42`) the `id` of an item or a node that the library NAMES
|
|
4253
|
+
by it, because the item has no `name` (a node, no `label`):
|
|
4254
|
+
|
|
4255
|
+
- a menu item (of `menu.<id>.items` or of a `submenu.items`) with neither a
|
|
4256
|
+
`name` nor an `aria_label`: `C_YUI_NAV` names it `name || aria_label || id`
|
|
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;
|
|
4259
|
+
- a menu item with no `name` in a breadcrumb that shows its labels (the text
|
|
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);
|
|
4264
|
+
- a toolbar item, the menu of a toolbar dropdown, or an entry of one, with
|
|
4265
|
+
neither an `aria_label` nor a `name`: the shell names them
|
|
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;
|
|
4271
|
+
- a row the SITE MAP draws, labelled as its control is named: the rows of the
|
|
4272
|
+
dropdown action of a menu entry with no submenu (`name || aria_label ||
|
|
4273
|
+
id`), and every row under a toolbar item that is not the brand, at every
|
|
4274
|
+
level, an entry with no `action` included (`aria_label || name || id`);
|
|
4275
|
+
- a node of a `C_YUI_NODE` tree with no `label`. The tree is declared as
|
|
4276
|
+
`{"gclass": "C_YUI_NODE", "kw": {...}}` (a menu item's `target`, a route's):
|
|
4277
|
+
its root is the `kw` (its id is `node_id`), and the nodes below it are the
|
|
4278
|
+
specs of `children` (`id`). The library names a node `label || id`, as a
|
|
4279
|
+
key: its item in the navs of its parent, the label of its own navs, its
|
|
4280
|
+
crumb in a path, its node in the site map. A root with no children and no
|
|
4281
|
+
path draws no label.
|
|
4282
|
+
|
|
4283
|
+
Up to `7.26.41` such a menu or toolbar item was named by its raw id, with no
|
|
4284
|
+
key, and the validator read the `label` of a node but not the id that stands
|
|
4285
|
+
in for a missing one. A decorative item (`"type": "header"` or `"divider"`)
|
|
4286
|
+
is named by none of this.
|
|
4287
|
+
|
|
4288
|
+
```json
|
|
4289
|
+
"items": [
|
|
4290
|
+
{"id": "alarms", "icon": "yi-bell", "route": "/alarms"},
|
|
4291
|
+
{"id": "search", "aria_label": "search the site", "icon": "yi-search", "route": "/search"}
|
|
4292
|
+
]
|
|
4293
|
+
```
|
|
4294
|
+
|
|
4295
|
+
The first item asks the locales for "alarms"; the second one for
|
|
4296
|
+
"search the site", and not for "search".
|
|
4297
|
+
|
|
4298
|
+
```json
|
|
4299
|
+
"target": {"gclass": "C_YUI_NODE", "kw": {"node_id": "admin", "base_route": "/admin", "children": [
|
|
4300
|
+
{"id": "accounts", "content": {"gclass": "C_ACCOUNTS"}},
|
|
4301
|
+
{"id": "db", "label": "database", "content": {"gclass": "C_DB_VIEW"}}
|
|
4302
|
+
]}}
|
|
4303
|
+
```
|
|
4304
|
+
|
|
4305
|
+
This tree asks for "admin" (a root with children and no `label`), for
|
|
4306
|
+
"accounts", and for "database" -- not for "db".
|
|
4307
|
+
|
|
4003
4308
|
**The source is PARSED, never run** (since `7.26.28`, with `acorn`, a
|
|
4004
4309
|
dependency of this package since `7.26.29`: an app need not declare it). A
|
|
4005
4310
|
LOCALE is not a source: it is parsed, and then imported, so its top-level code
|
|
@@ -4007,7 +4312,14 @@ runs -- the app's own code, but code. Comments are not code. A key is read
|
|
|
4007
4312
|
where it is WRITTEN -- given to a translator, as an `i18n` or `data-i18n*`
|
|
4008
4313
|
value of an object literal, by `setAttribute()`, or (since `7.26.29`) written
|
|
4009
4314
|
as a member, `attrs.i18n = "save"`, `attrs["data-i18n-title"] = "save"` -- and
|
|
4010
|
-
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).
|
|
4011
4323
|
|
|
4012
4324
|
A **translator** is one notion, the same everywhere the reader asks "is this a
|
|
4013
4325
|
call of t()?" (since `7.26.32`; up to `7.26.31` it was a call NAMED `t` or
|
|
@@ -4018,16 +4330,27 @@ call of t()?" (since `7.26.32`; up to `7.26.31` it was a call NAMED `t` or
|
|
|
4018
4330
|
`const {t: tt} = i18next`, a parameter `{t: tt}`), a re-export of a module the
|
|
4019
4331
|
reader reads --, called as `t(k)`, `t?.(k)`, `t.call(x, k)` or
|
|
4020
4332
|
`t.apply(x, [k])`. An ARRAY given to it is i18next's list of fallback keys, and
|
|
4021
|
-
each one is a key: `t([specific, "generic"])` asks for "generic".
|
|
4333
|
+
each one is a key: `t([specific, "generic"])` asks for "generic". A `.bind()`
|
|
4334
|
+
that binds a KEY makes a translator whose calls hand i18next its options or its
|
|
4335
|
+
default value: `const tk = t.bind(null, "save"); tk({count: 2})` (since
|
|
4336
|
+
`7.26.42`; up to `7.26.41` what `tk()` was handed was asked for as a key). The
|
|
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,
|
|
4022
4339
|
since `7.26.32`, also include `el.dataset.i18nTitle = k` (`dataset.i18nX` IS
|
|
4023
4340
|
the attribute `data-i18n-x`), and an attribute or property NAMED by a const:
|
|
4024
4341
|
`el.setAttribute(ATTR, k)`, `{[ATTR]: k}`, `x[ATTR] = k`, with `const ATTR =
|
|
4025
4342
|
"data-i18n-title"`; and since `7.26.35` `el.setAttributeNS(ns, ATTR, k)`, and a
|
|
4026
|
-
translator handed as a CALLBACK:
|
|
4027
|
-
|
|
4028
|
-
- `
|
|
4029
|
-
`some`, `every`
|
|
4030
|
-
|
|
4343
|
+
translator handed as a CALLBACK -- in these forms, and no other:
|
|
4344
|
+
|
|
4345
|
+
- the methods `map`, `flatMap`, `forEach`, `filter`, `find`, `findIndex`,
|
|
4346
|
+
`findLast`, `findLastIndex`, `some`, `every` (`findIndex` and
|
|
4347
|
+
`findLastIndex` since `7.26.42`), called on the array -- `keys.map(t)`,
|
|
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)`,
|
|
4351
|
+
`[].forEach.apply(keys, [t])`; and `Array.from(keys, t)`,
|
|
4352
|
+
`Array.fromAsync(keys, t)`: each ELEMENT is a key, read like any other -- a
|
|
4353
|
+
const array, a published list, an import of one are followed;
|
|
4031
4354
|
- `promise.then(t)`, `.catch(t)`: what the promise settles with is a key no
|
|
4032
4355
|
source writes.
|
|
4033
4356
|
|
|
@@ -4037,7 +4360,11 @@ and any promise, fails unless the call is marked
|
|
|
4037
4360
|
`load().then(/* i18n: data */ t)`). A translator handed to a FUNCTION is not
|
|
4038
4361
|
one of these: `{t: t}`, `yui_tabulator_lang(t)`, `refresh_language($el, t)` --
|
|
4039
4362
|
it is how gobj-ui receives one, and the function calls it with keys of its
|
|
4040
|
-
own.
|
|
4363
|
+
own. Neither is one handed to any other method (`keys.reduce(t)`,
|
|
4364
|
+
`keys.sort(t)`), to an alias of one of those methods (`const map =
|
|
4365
|
+
Array.prototype.map; map.call(keys, t)`), through `Reflect.apply()`, or with a
|
|
4366
|
+
key bound (`keys.map(t.bind(null, k))`: each element goes to i18next as
|
|
4367
|
+
options). What is followed:
|
|
4041
4368
|
|
|
4042
4369
|
- a string literal, a template with no `${}`, and every branch of `?:`, `||`
|
|
4043
4370
|
and `??` (the right one of `&&`), so
|
|
@@ -4054,9 +4381,11 @@ own. What is followed:
|
|
|
4054
4381
|
computed one, `NOTES[verdict]`, every value the object holds; also of a
|
|
4055
4382
|
COPY of one (since `7.26.32`): `{...BASE, title: "t"}`,
|
|
4056
4383
|
`Object.assign({}, BASE)`;
|
|
4057
|
-
- the element of a const array literal that a
|
|
4058
|
-
|
|
4059
|
-
|
|
4384
|
+
- the element of a const array literal that a `for...of` walks, or that the
|
|
4385
|
+
first parameter of a callback of one of the methods above receives (in the
|
|
4386
|
+
same forms, and since `7.26.42` also the callback of `Array.from(ROWS, cb)`,
|
|
4387
|
+
of `.findIndex()` and of `Array.prototype.forEach.call(ROWS, cb)`), and what a
|
|
4388
|
+
destructuring reads from it (`for(const {key} of ROWS)`);
|
|
4060
4389
|
- `String(x)`, and a template that is only `${x}`, as `x` (since `7.26.29`);
|
|
4061
4390
|
- a parameter, however it is read (since `7.26.32`): `opts.title`,
|
|
4062
4391
|
`opts?.title`, `arguments[1]`, `rest[0]` of a rest parameter, a destructuring
|
|
@@ -4095,13 +4424,13 @@ element of one -- is followed (below). A source file that cannot be parsed
|
|
|
4095
4424
|
fails the build, because its keys would go unchecked.
|
|
4096
4425
|
|
|
4097
4426
|
**An UNMARKED `let` that is only ever given literals IS followed** (since
|
|
4098
|
-
`7.26.35`), where `t()`, an `i18n`
|
|
4427
|
+
`7.26.35`), where `t()`, an `i18n` value or a `data-i18n*` attribute
|
|
4099
4428
|
reads a key: when every value it is given in its scope -- its initializer, every
|
|
4100
|
-
`=`, `||=`, `??=`,
|
|
4101
|
-
|
|
4102
|
-
`?:` / `||` / `??` of those (the
|
|
4103
|
-
|
|
4104
|
-
it
|
|
4429
|
+
`=`, `||=`, `??=`, `&&=`, the value of a `var` of it declared again -- is
|
|
4430
|
+
WRITTEN as a string literal, a const bound to one (of the module, or imported),
|
|
4431
|
+
`null` / `undefined`, another such `let`, or a `?:` / `||` / `??` of those (the
|
|
4432
|
+
right one of `&&`), the variable can only ever hold those literals, and EVERY
|
|
4433
|
+
literal it is given in its scope is a key asked for.
|
|
4105
4434
|
|
|
4106
4435
|
```js
|
|
4107
4436
|
let state_key = (st === "ST_MONITORING")? "monitor monitoring" : "monitor disconnected";
|
|
@@ -4112,13 +4441,62 @@ $state.setAttribute("data-i18n", state_key); // asks for all three
|
|
|
4112
4441
|
$state.textContent = t(state_key);
|
|
4113
4442
|
```
|
|
4114
4443
|
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4444
|
+
The rule reads the WRITES, not the order in which they run: it is
|
|
4445
|
+
flow-insensitive, by design. A literal that an `if` keeps away from the place
|
|
4446
|
+
that reads the key is asked for, and so is a literal that is overwritten
|
|
4447
|
+
before the read. So a SENTINEL that is no key fails the build, as a missing
|
|
4448
|
+
key. `7.26.35` said that the rule was exact and failed nothing new. That was
|
|
4449
|
+
not true: it asks for every literal whatever the flow, and up to `7.26.41` it
|
|
4450
|
+
also missed some writes (below).
|
|
4451
|
+
|
|
4452
|
+
```js
|
|
4453
|
+
let key = "-"; // asks for "-" too: the `if` below does not hide it
|
|
4454
|
+
if(saving) {
|
|
4455
|
+
key = "save";
|
|
4456
|
+
}
|
|
4457
|
+
if(key !== "-") {
|
|
4458
|
+
t(key); // fails: "-" is defined in no locale
|
|
4459
|
+
}
|
|
4460
|
+
```
|
|
4461
|
+
|
|
4462
|
+
Write a sentinel as `null`, which is never asked for. Or give the key its own
|
|
4463
|
+
`const`:
|
|
4464
|
+
|
|
4465
|
+
```js
|
|
4466
|
+
let key = null; // a sentinel that is never asked for
|
|
4467
|
+
if(saving) {
|
|
4468
|
+
key = "save";
|
|
4469
|
+
}
|
|
4470
|
+
if(key) {
|
|
4471
|
+
t(key); // asks for "save"
|
|
4472
|
+
}
|
|
4473
|
+
```
|
|
4474
|
+
|
|
4475
|
+
```js
|
|
4476
|
+
const key = saving? "save" : null; // asks for "save"
|
|
4477
|
+
if(key) {
|
|
4478
|
+
t(key);
|
|
4479
|
+
}
|
|
4480
|
+
```
|
|
4481
|
+
|
|
4482
|
+
**EVERY write to the variable counts** (since `7.26.42`). A write whose value
|
|
4483
|
+
the reader does not read makes the variable not followed, and it stays
|
|
4484
|
+
invisible: a property of a table (`let m = MONTHS[i]`: the reader would read
|
|
4485
|
+
every value of the table, which is enough for a marker that names lists, and
|
|
4486
|
+
too much to ask the locales for), a call (`let k = busy_key(gobj)`), a
|
|
4487
|
+
parameter, data, a `+=` or `++`, a destructuring (`[k, x] = pair`,
|
|
4488
|
+
`({k} = row)`, `var [k] = pair`), a `for...of` / `for...in` head that writes
|
|
4489
|
+
it -- the variable itself (`for(k of rows)`), a destructuring of it
|
|
4490
|
+
(`for([k, label] of rows)`, `for({k} of rows)`, `for([k] in obj)`), or a `var`
|
|
4491
|
+
of it declared again there (`for(var k of rows)`) --, and a direct `eval()` in
|
|
4492
|
+
its scope. A `var` declared again anywhere in its function or module (a block,
|
|
4493
|
+
a `for(;;)` init, a `switch` case) gives it the value it is declared with. Up
|
|
4494
|
+
to `7.26.41` the loop heads that destructure or declare a `var` did not count,
|
|
4495
|
+
and a module `var` declared again outside the top level was not seen:
|
|
4496
|
+
`let key = "-"; for([key, label] of rows) el.setAttribute("data-i18n", key)`
|
|
4497
|
+
asked for "-", and failed. At a key position of a key function nothing
|
|
4498
|
+
changes: a `let` there is still a violation of the rule per call (below),
|
|
4499
|
+
which wants a const or a marker.
|
|
4122
4500
|
|
|
4123
4501
|
**A key handed to a FUNCTION is read where it is handed.**
|
|
4124
4502
|
`yui_shell_show_error(shell, "some records were gone before the delete")` asks
|
|
@@ -4138,7 +4516,26 @@ that receives a key, and where it is:
|
|
|
4138
4516
|
|
|
4139
4517
|
A position is an argument (`"1"`), a property of the object given there
|
|
4140
4518
|
(`"2.title"`, also through `Object.assign()` or a spread of a const object),
|
|
4141
|
-
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
|
|
4142
4539
|
given at those positions is read like any other key (literals, consts,
|
|
4143
4540
|
branches): in the app's own code, on a call that reaches that function of
|
|
4144
4541
|
gobj-ui (an app function of the same name is not mistaken for it), and in
|
|
@@ -4149,7 +4546,12 @@ member): an import under any name, a re-export from a file of the app
|
|
|
4149
4546
|
(`export {yui_shell_show_info as say} from "@yuneta/gobj-ui/src/shell_modals.js"`),
|
|
4150
4547
|
a const alias (`const show = yui_shell_show_info`), a map in a const
|
|
4151
4548
|
(`const API = {info: yui_shell_show_info}; API.info(...)`, imported too),
|
|
4152
|
-
`.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
|
|
4153
4555
|
DOM, which is no key (since `7.26.29`): an array (a `createElement2` spec), a
|
|
4154
4556
|
call of `createElement2()`, `createOneHtml()` or `html_markup()` imported
|
|
4155
4557
|
from gobj-js, of `text_node()` from gobj-ui, of `document.createElement()`
|
|
@@ -4163,8 +4565,10 @@ variable: `$box` says nothing. The exported ones an app calls:
|
|
|
4163
4565
|
`no_label`), `yui_selection_bar` (each action's `label`), `yui_asset_missing`
|
|
4164
4566
|
/ `yui_asset_element` (`key`), `hook_cell_spec` (the title key),
|
|
4165
4567
|
`period_name` (a granularity id), `card_descriptor` / `cards_grid_descriptor`
|
|
4166
|
-
(a nav item's `name`, `tooltip`, `aria_label
|
|
4167
|
-
|
|
4568
|
+
(a nav item's `name`, `tooltip`, `aria_label`, and its `id`: the key of an
|
|
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).
|
|
4168
4572
|
|
|
4169
4573
|
**Every function that forwards a key is in the table, and a test finds them**
|
|
4170
4574
|
(since `7.26.29`: up to `7.26.28` the table lacked 39 of them, and 6 entries
|
|
@@ -4402,10 +4806,10 @@ GIVEN, in the scope that declares it -- its initializer and every `=` (`||=`,
|
|
|
4402
4806
|
`??=`, `&&=` too) -- and reads each value like any other. Each literal it finds
|
|
4403
4807
|
is a key the locales are asked for and, under a list marker, must be in the
|
|
4404
4808
|
lists it names. A write it cannot read (`+=`, `++`, a destructuring, a
|
|
4405
|
-
`for...of`
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
fails:
|
|
4809
|
+
`for...of` / `for...in` head that writes it, a direct `eval()`: every write of
|
|
4810
|
+
the list above) keeps the variable unknown; a parameter or another variable of
|
|
4811
|
+
the same name is not a write to it. And a variable that is given nothing but
|
|
4812
|
+
literals is a const that was not written as one, so it fails:
|
|
4409
4813
|
|
|
4410
4814
|
```js
|
|
4411
4815
|
let key = maximized ? "restore" : "maximize";
|
|
@@ -4415,9 +4819,10 @@ t(/* i18n: C_YUI_WINDOW_I18N_KEYS */ key);
|
|
|
4415
4819
|
```
|
|
4416
4820
|
|
|
4417
4821
|
The rule is the same under `i18n: data`: the literals of a marked variable are
|
|
4418
|
-
read, and one that holds nothing else fails. (Unmarked, such a variable
|
|
4419
|
-
|
|
4420
|
-
is
|
|
4822
|
+
read, and one that holds nothing else fails. (Unmarked, such a variable is no
|
|
4823
|
+
violation of its own: since `7.26.35` its literals are asked for, above --
|
|
4824
|
+
every one of them, so a literal that is no key fails as a missing key. The
|
|
4825
|
+
marker is what makes it a claim to check.)
|
|
4421
4826
|
|
|
4422
4827
|
**A `let` that holds a TABLE is held the same way** (since the same round:
|
|
4423
4828
|
up to then a marked member of one passed unread). When what is marked is read
|
|
@@ -4502,10 +4907,7 @@ unmarked `tr()` failed with *"cannot follow"*, whose advice was the marker that
|
|
|
4502
4907
|
then let it pass), and (since `7.26.35`) a string BUILT from one: a
|
|
4503
4908
|
concatenation or a template holding one (`t("k") + ":"`, `` `${t("k")}:` ``),
|
|
4504
4909
|
a method called on one (`t("k").toUpperCase()`, `[t("a"), name].join(" ")`);
|
|
4505
|
-
DOM built with one (`createElement2(["p", {}, t("k")])`) is DOM.
|
|
4506
|
-
excuses such a text anywhere a key is read -- `t(/* i18n: data */ t("k") +
|
|
4507
|
-
"!")` and `{i18n: /* i18n: data */ t("k").trim()}` fail too, with *"hand the
|
|
4508
|
-
key, not t(key)"*:
|
|
4910
|
+
DOM built with one (`createElement2(["p", {}, t("k")])`) is DOM.
|
|
4509
4911
|
|
|
4510
4912
|
```js
|
|
4511
4913
|
yui_install_ask_once(shell, {t: t, message: t("install this app")}); // fails
|
|
@@ -4518,6 +4920,21 @@ src/c_app.js:734 (call at line 732): yui_install_ask_once() [1.message] is given
|
|
|
4518
4920
|
it never changes language, and no marker excuses it): hand the key, not t(key)
|
|
4519
4921
|
```
|
|
4520
4922
|
|
|
4923
|
+
Such a text fails EVERYWHERE a key is read, marked or not: given to `t()`
|
|
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
|
|
4926
|
+
`data-i18n*` attribute (`el.setAttribute("data-i18n-title", t("k"))`), and
|
|
4927
|
+
through a `const` that holds one. The place keeps the translation as its key,
|
|
4928
|
+
so it never changes language. Up to `7.26.41` only a MARKED one failed there:
|
|
4929
|
+
`{i18n: t("k")}` passed, and `{i18n: /* i18n: data */ t("k")}` failed. No
|
|
4930
|
+
consumer had one.
|
|
4931
|
+
|
|
4932
|
+
```
|
|
4933
|
+
src/main.js:2: `t("saved")` is a TRANSLATED text given to a property that holds a key (i18n, code,
|
|
4934
|
+
data-i18n*): the translation is kept as its key and never changes language: hand the key, not t(key)
|
|
4935
|
+
src/main.js:8: `t("saved")` is a TRANSLATED text given to a data-i18n* attribute (read at line 9): ...
|
|
4936
|
+
```
|
|
4937
|
+
|
|
4521
4938
|
In an app, what a wrapper of its own hands on is marked where it hands it:
|
|
4522
4939
|
`/* i18n: data */` when it is data (a backend's comment, a key built from a
|
|
4523
4940
|
name, the DOM its callers built). When its callers give it the module's own
|
|
@@ -4589,7 +5006,8 @@ reading the page in another language:
|
|
|
4589
5006
|
|
|
4590
5007
|
- a key handed to a translator, an `i18n` or a `data-i18n*` value by an
|
|
4591
5008
|
UNMARKED `let` given anything but literals (a property of a table, a call, a
|
|
4592
|
-
parameter, data, a
|
|
5009
|
+
parameter, data, a `+=`, a destructuring, a loop head that writes it: one
|
|
5010
|
+
only ever given literals is followed, above), a
|
|
4593
5011
|
call the reader does not follow (a recursion, one whose returns mix keys and
|
|
4594
5012
|
data, a function of a package) or a computed string:
|
|
4595
5013
|
a translator is not a key function, and only the positions of
|
|
@@ -4602,15 +5020,16 @@ reading the page in another language:
|
|
|
4602
5020
|
`let` alias, `opts.translate(k)`, `i18next.getFixedT()` --, or one called
|
|
4603
5021
|
through what is no name of it: `(0, t)(k)`, `[t][0](k)`,
|
|
4604
5022
|
`Reflect.apply(t, x, [k])`, `Function.prototype.call.call(t, x, k)`;
|
|
4605
|
-
- a key BOUND with the translator, `t.bind(null, k)` (`.bind()` is read as an
|
|
4606
|
-
alias of the translator, and the key it binds is not read);
|
|
4607
5023
|
- a translator handed to a FUNCTION (`{t: t}`, `yui_tabulator_lang(t)`,
|
|
4608
|
-
`run(t)`)
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
5024
|
+
`run(t)`) or to any method but those listed above (`keys.reduce(t)`,
|
|
5025
|
+
`keys.sort(t)`, an alias of a method, `Reflect.apply()`): only those
|
|
5026
|
+
methods, in those forms, and `.then()` / `.catch()` are read as calling it
|
|
5027
|
+
with what they walk or settle with;
|
|
5028
|
+
- a translated text held in a `let`, marked or not (`let label = t(k);` ...
|
|
5029
|
+
`label`): the reader reads the literals of a `let`, not its translations;
|
|
5030
|
+
and one returned by a function (`{i18n: label_of(k)}`, `label_of` returning
|
|
5031
|
+
`t(k)`). A translated text written where the key is read fails, marked or
|
|
5032
|
+
not, and so does one a `const` holds (below);
|
|
4614
5033
|
- a key function reached through a parameter (`apply(fn)` calling
|
|
4615
5034
|
`fn(shell, "k")`), a `let` given more than one function, a map in a `let`,
|
|
4616
5035
|
a computed member (`API[name](...)`), or `.apply()` of an array the source
|
|
@@ -4653,14 +5072,27 @@ reading the page in another language:
|
|
|
4653
5072
|
`var`, or mutated (also through an alias or a namespace member);
|
|
4654
5073
|
- a marker that is wrong (above): a `data` marker on what the reader follows
|
|
4655
5074
|
to keys, or on what would hide a key (a call mixing keys and data, an array
|
|
4656
|
-
of string literals),
|
|
4657
|
-
|
|
4658
|
-
|
|
5075
|
+
of string literals), a list marker on a template whose shape no key of the
|
|
5076
|
+
list has -- or whose every key of that shape a narrower marked template
|
|
5077
|
+
builds;
|
|
5078
|
+
- a TRANSLATED text where a key is read, marked or not: given to `t()`, to an
|
|
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);
|
|
4659
5082
|
- a key position of a key function, in the app's own code, given what the
|
|
4660
|
-
reader cannot follow and unmarked
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
5083
|
+
reader cannot follow and unmarked (the rule per call, above); and so a
|
|
5084
|
+
translator handed as a callback to one of the methods above over an array
|
|
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.
|
|
4664
5096
|
|
|
4665
5097
|
Up to `7.26.27` the locale cases were "skipped" with an OK: one language less
|
|
4666
5098
|
validated, and nobody told. A file of the locales directory with a locale's
|