@yuneta/gobj-ui 7.26.9 → 7.26.11
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 +48 -1
- package/dist/gobj-ui.cjs.js +154 -79
- package/dist/gobj-ui.es.js +155 -80
- package/package.json +9 -4
- package/scripts/check-markup-strings.mjs +278 -0
- package/src/c_g6_nodes_tree.js +9 -3
- package/src/c_yui_form.js +10 -8
- package/src/c_yui_gclass.js +3 -3
- package/src/c_yui_json.js +1 -1
- package/src/c_yui_schema_editor.js +2 -2
- package/src/c_yui_shell.js +43 -2
- package/src/c_yui_treedb_topic_with_form.js +8 -4
- package/src/c_yui_window.js +14 -11
- package/src/c_yui_window_manager.js +69 -7
- package/src/overlay_marker_after_back.wiring.test.js +79 -0
- package/src/window_show.wiring.test.js +98 -3
- package/src/yui_text.js +16 -0
- package/src/yui_text.test.js +13 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/***********************************************************************
|
|
3
|
+
* check-markup-strings.mjs
|
|
4
|
+
*
|
|
5
|
+
* createElement2() reads a plain string that starts with '<' as
|
|
6
|
+
* html (gobj-js), so whether a string RUNS depends on its content,
|
|
7
|
+
* not on who wrote it. The way out is to say markup out loud --
|
|
8
|
+
* html_markup('<i class="yi-copy"></i>') -- and, once every
|
|
9
|
+
* deliberate markup does, to turn on set_strings_are_text(true),
|
|
10
|
+
* where a plain string is always text.
|
|
11
|
+
*
|
|
12
|
+
* This check finds, in the CONTENT of a createElement2()
|
|
13
|
+
* description (`[tag, attrs, content]`) and in its list of
|
|
14
|
+
* children:
|
|
15
|
+
*
|
|
16
|
+
* literal a string literal that starts with '<': deliberate
|
|
17
|
+
* markup, to be wrapped in html_markup().
|
|
18
|
+
* built a template with ${...} or a '+' concatenation that
|
|
19
|
+
* starts with '<': markup BUILT WITH VALUES. If a value
|
|
20
|
+
* is data, that is the hole; build the element with
|
|
21
|
+
* createElement2() and pass the value as text.
|
|
22
|
+
* in-list a string that starts with '<' inside a LIST of
|
|
23
|
+
* children: since gobj-js 7.26.2 a string there is
|
|
24
|
+
* text, so it renders as the literal tags.
|
|
25
|
+
* list-head a list of children whose FIRST item is a string that
|
|
26
|
+
* starts with '<': createElement2() reads such a list as
|
|
27
|
+
* one description, so the string would be its tag.
|
|
28
|
+
*
|
|
29
|
+
* A ternary or a `||`/`&&` in the content is checked branch by
|
|
30
|
+
* branch; `'<b>'.concat(x)` counts as built; a computed tag is
|
|
31
|
+
* taken when the attrs slot is an object literal.
|
|
32
|
+
*
|
|
33
|
+
* What it cannot see: a VARIABLE or a function result holding a
|
|
34
|
+
* string (its type is not known before running); a description
|
|
35
|
+
* built piece by piece (push() into an array that is later the
|
|
36
|
+
* content); a computed tag with an attrs slot that is not an object
|
|
37
|
+
* literal; markup given to innerHTML, or to a widget (Tabulator,
|
|
38
|
+
* G6), which are other sinks. set_strings_are_text(true) logs, once
|
|
39
|
+
* at run time, every string that reaches createElement2() starting
|
|
40
|
+
* with '<': that is the other half of the check.
|
|
41
|
+
*
|
|
42
|
+
* Usage (from the package root):
|
|
43
|
+
* node scripts/check-markup-strings.mjs [dir|file ...] # default: src
|
|
44
|
+
* Exit 1 when anything is found.
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) 2026, ArtGins.
|
|
47
|
+
* All Rights Reserved.
|
|
48
|
+
***********************************************************************/
|
|
49
|
+
import {readFileSync, readdirSync, statSync, realpathSync} from "node:fs";
|
|
50
|
+
import {join, relative} from "node:path";
|
|
51
|
+
import {fileURLToPath} from "node:url";
|
|
52
|
+
import {parse} from "acorn";
|
|
53
|
+
|
|
54
|
+
const TAG_RE = /^[a-z][a-z0-9-]*$/;
|
|
55
|
+
const SKIP_DIRS = new Set(["node_modules", "dist", ".git", "build", "_build"]);
|
|
56
|
+
|
|
57
|
+
function list_files(path, out)
|
|
58
|
+
{
|
|
59
|
+
let st = statSync(path);
|
|
60
|
+
if(st.isDirectory()) {
|
|
61
|
+
for(const name of readdirSync(path)) {
|
|
62
|
+
if(SKIP_DIRS.has(name)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
list_files(join(path, name), out);
|
|
66
|
+
}
|
|
67
|
+
} else if(/\.(js|mjs)$/.test(path) && !/\.test\.(js|mjs)$/.test(path)) {
|
|
68
|
+
out.push(path);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function is_string_literal(n)
|
|
74
|
+
{
|
|
75
|
+
return n && n.type === "Literal" && typeof n.value === "string";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function static_string(n)
|
|
79
|
+
{
|
|
80
|
+
if(is_string_literal(n)) {
|
|
81
|
+
return n.value;
|
|
82
|
+
}
|
|
83
|
+
if(n && n.type === "TemplateLiteral" && n.expressions.length === 0) {
|
|
84
|
+
return n.quasis[0].value.cooked;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function starts_with_markup(s)
|
|
90
|
+
{
|
|
91
|
+
return typeof s === "string" && s.trim().startsWith("<");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* The leftmost string of a '+' chain, the head of a template, or the
|
|
95
|
+
* receiver of a '.concat()'. */
|
|
96
|
+
function built_markup(n)
|
|
97
|
+
{
|
|
98
|
+
if(!n) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if(n.type === "CallExpression" && n.callee.type === "MemberExpression" &&
|
|
102
|
+
!n.callee.computed && n.callee.property.name === "concat") {
|
|
103
|
+
let head = n.callee.object;
|
|
104
|
+
let s = static_string(head);
|
|
105
|
+
if(s !== null) {
|
|
106
|
+
return starts_with_markup(s);
|
|
107
|
+
}
|
|
108
|
+
return built_markup(head);
|
|
109
|
+
}
|
|
110
|
+
if(n.type === "TemplateLiteral" && n.expressions.length > 0) {
|
|
111
|
+
return starts_with_markup(n.quasis[0].value.cooked);
|
|
112
|
+
}
|
|
113
|
+
if(n.type === "BinaryExpression" && n.operator === "+") {
|
|
114
|
+
let left = n;
|
|
115
|
+
while(left.type === "BinaryExpression" && left.operator === "+") {
|
|
116
|
+
left = left.left;
|
|
117
|
+
}
|
|
118
|
+
let s = static_string(left);
|
|
119
|
+
if(s !== null) {
|
|
120
|
+
return starts_with_markup(s);
|
|
121
|
+
}
|
|
122
|
+
return left.type === "TemplateLiteral" && starts_with_markup(left.quasis[0].value.cooked);
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* [tag, attrs, content, events?]: a tag and an attrs slot. A literal
|
|
128
|
+
* tag must look like one; a computed tag (a variable, a ternary) is
|
|
129
|
+
* taken when the attrs slot is an object literal, which is what makes
|
|
130
|
+
* the array a description and not some other triple. */
|
|
131
|
+
function is_description(n)
|
|
132
|
+
{
|
|
133
|
+
if(!n || n.type !== "ArrayExpression" || n.elements.length < 3 || n.elements.length > 4) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
let tag = n.elements[0];
|
|
137
|
+
let attrs = n.elements[1];
|
|
138
|
+
if(!tag || !attrs) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if(is_string_literal(tag)) {
|
|
142
|
+
if(!TAG_RE.test(tag.value)) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
return attrs.type === "ObjectExpression" || attrs.type === "Identifier" ||
|
|
146
|
+
attrs.type === "MemberExpression" || attrs.type === "CallExpression" ||
|
|
147
|
+
attrs.type === "ConditionalExpression" ||
|
|
148
|
+
(attrs.type === "Literal" && attrs.value === null);
|
|
149
|
+
}
|
|
150
|
+
if(tag.type === "SpreadElement" || tag.type === "ArrayExpression" ||
|
|
151
|
+
tag.type === "ObjectExpression" || tag.type === "Literal") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return attrs.type === "ObjectExpression";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function walk(node, visit)
|
|
158
|
+
{
|
|
159
|
+
if(!node || typeof node.type !== "string") {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
visit(node);
|
|
163
|
+
for(const key of Object.keys(node)) {
|
|
164
|
+
if(key === "loc" || key === "start" || key === "end") {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
let v = node[key];
|
|
168
|
+
if(Array.isArray(v)) {
|
|
169
|
+
for(const c of v) {
|
|
170
|
+
if(c && typeof c.type === "string") {
|
|
171
|
+
walk(c, visit);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else if(v && typeof v.type === "string") {
|
|
175
|
+
walk(v, visit);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function check_content(n, findings, file, src, where)
|
|
181
|
+
{
|
|
182
|
+
if(!n) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if(n.type === "ConditionalExpression") {
|
|
186
|
+
check_content(n.consequent, findings, file, src, where);
|
|
187
|
+
check_content(n.alternate, findings, file, src, where);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if(n.type === "LogicalExpression") {
|
|
191
|
+
check_content(n.left, findings, file, src, where);
|
|
192
|
+
check_content(n.right, findings, file, src, where);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
let s = static_string(n);
|
|
196
|
+
if(s !== null && starts_with_markup(s)) {
|
|
197
|
+
findings.push({file, line: n.loc.start.line, rule: where === "list" ? "in-list" : "literal",
|
|
198
|
+
text: src.slice(n.start, Math.min(n.end, n.start + 90))});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if(built_markup(n)) {
|
|
202
|
+
findings.push({file, line: n.loc.start.line, rule: "built",
|
|
203
|
+
text: src.slice(n.start, Math.min(n.end, n.start + 90))});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function check_file(file, root)
|
|
208
|
+
{
|
|
209
|
+
const src = readFileSync(file, "utf8");
|
|
210
|
+
let ast;
|
|
211
|
+
try {
|
|
212
|
+
ast = parse(src, {ecmaVersion: "latest", sourceType: "module", locations: true,
|
|
213
|
+
allowHashBang: true, allowAwaitOutsideFunction: true});
|
|
214
|
+
} catch(e) {
|
|
215
|
+
console.error(`${relative(root, file)}: cannot parse: ${e.message}`);
|
|
216
|
+
return [{file, line: 0, rule: "parse", text: e.message}];
|
|
217
|
+
}
|
|
218
|
+
const findings = [];
|
|
219
|
+
const rel = relative(root, file);
|
|
220
|
+
walk(ast, (n) => {
|
|
221
|
+
if(!is_description(n)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
let content = n.elements[2];
|
|
225
|
+
if(content && content.type === "ArrayExpression" && content.elements.length > 0) {
|
|
226
|
+
let head = static_string(content.elements[0]);
|
|
227
|
+
if(head !== null && starts_with_markup(head)) {
|
|
228
|
+
/* createElement2() reads a list that starts with a string
|
|
229
|
+
* as ONE description: '<b>' would be its tag. */
|
|
230
|
+
findings.push({file: rel, line: content.loc.start.line, rule: "list-head",
|
|
231
|
+
text: src.slice(content.start, Math.min(content.end, content.start + 90))});
|
|
232
|
+
} else if(head === null) {
|
|
233
|
+
for(const child of content.elements) {
|
|
234
|
+
check_content(child, findings, rel, src, "list");
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
check_content(content, findings, rel, src, "slot");
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
return findings;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export {check_file};
|
|
245
|
+
|
|
246
|
+
/* Run as a command (not imported by a test). Both sides through
|
|
247
|
+
* realpath: argv[1] keeps a symlinked path, import.meta.url does not. */
|
|
248
|
+
if(process.argv[1] &&
|
|
249
|
+
realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1])) {
|
|
250
|
+
main();
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function main()
|
|
254
|
+
{
|
|
255
|
+
const root = process.cwd();
|
|
256
|
+
const targets = process.argv.slice(2).length ? process.argv.slice(2) : ["src"];
|
|
257
|
+
let files = [];
|
|
258
|
+
for(const t of targets) {
|
|
259
|
+
list_files(join(root, t), files);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let all = [];
|
|
263
|
+
for(const f of files) {
|
|
264
|
+
all = all.concat(check_file(f, root));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const by_rule = {};
|
|
268
|
+
for(const f of all) {
|
|
269
|
+
by_rule[f.rule] = (by_rule[f.rule] || 0) + 1;
|
|
270
|
+
console.log(`${f.file}:${f.line}: ${f.rule}: ${f.text.replace(/\s+/g, " ")}`);
|
|
271
|
+
}
|
|
272
|
+
if(all.length) {
|
|
273
|
+
console.log(`\ncheck-markup-strings: ${all.length} found ` +
|
|
274
|
+
`(${Object.entries(by_rule).map(([k, v]) => `${k} ${v}`).join(", ")}) in ${files.length} files`);
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
console.log(`check-markup-strings: OK (${files.length} files)`);
|
|
278
|
+
}
|
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -229,7 +229,7 @@ class YuiToolbar extends Toolbar
|
|
|
229
229
|
const is_text = (item.text !== undefined);
|
|
230
230
|
const kind_class = is_text ? ' g6-toolbar-item-text' : '';
|
|
231
231
|
const body = is_text
|
|
232
|
-
? `<span class="g6-toolbar-text">${item.text}</span>`
|
|
232
|
+
? `<span class="g6-toolbar-text">${escapeHtml(String(item.text))}</span>`
|
|
233
233
|
: `<svg aria-hidden="true" focusable="false">` +
|
|
234
234
|
`<use xlink:href="#${item.id}"></use>` +
|
|
235
235
|
`</svg>`;
|
|
@@ -2301,6 +2301,8 @@ function topic_defaults_of(gobj, topic_name)
|
|
|
2301
2301
|
* It is written into a card's html (see yui_data_color.js): a
|
|
2302
2302
|
* refused value logs, and the node wears the topic's colour.
|
|
2303
2303
|
************************************************************/
|
|
2304
|
+
const refused_colors_logged = new Set(); // once per (gobj, value): every repaint asks again
|
|
2305
|
+
|
|
2304
2306
|
function data_color(gobj, value)
|
|
2305
2307
|
{
|
|
2306
2308
|
if(value === undefined || value === null || value === "") {
|
|
@@ -2308,7 +2310,11 @@ function data_color(gobj, value)
|
|
|
2308
2310
|
}
|
|
2309
2311
|
let color = css_color_or_null(value);
|
|
2310
2312
|
if(!color) {
|
|
2311
|
-
|
|
2313
|
+
let key = `${gobj_short_name(gobj)}\u0000${String(value)}`;
|
|
2314
|
+
if(!refused_colors_logged.has(key) && refused_colors_logged.size < 200) {
|
|
2315
|
+
refused_colors_logged.add(key);
|
|
2316
|
+
log_warning(`${gobj_short_name(gobj)}: colour refused, not a css colour: ${JSON.stringify(value)}`);
|
|
2317
|
+
}
|
|
2312
2318
|
}
|
|
2313
2319
|
return color;
|
|
2314
2320
|
}
|
|
@@ -9017,7 +9023,7 @@ function ctx_item(icon_id, label, value)
|
|
|
9017
9023
|
`vertical-align:-0.125em;margin-right:8px;` +
|
|
9018
9024
|
`pointer-events:none;fill:currentColor">` +
|
|
9019
9025
|
`<use href="#${icon_id}"></use></svg>` +
|
|
9020
|
-
`${label}`;
|
|
9026
|
+
`${escapeHtml(String(label))}`; // text: G6 innerHTMLs the name
|
|
9021
9027
|
return { name: name, value: value };
|
|
9022
9028
|
}
|
|
9023
9029
|
|
package/src/c_yui_form.js
CHANGED
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
treedb_decoder_fkey,
|
|
49
49
|
gclass_find_by_name,
|
|
50
50
|
gobj_is_destroying,
|
|
51
|
+
html_markup,
|
|
51
52
|
} from "@yuneta/gobj-js";
|
|
52
53
|
|
|
53
54
|
import {t} from "i18next";
|
|
@@ -91,7 +92,7 @@ import "./tabulator.css";
|
|
|
91
92
|
import {is_time_field} from "./json_view_helpers.js";
|
|
92
93
|
import {date_to_datetime_local, datetime_local_to_epoch} from "./form_time_value.js";
|
|
93
94
|
import {parse_json_field, json_editor_value} from "./form_json_field.js";
|
|
94
|
-
import {text_node, text_title_formatter} from "./yui_text.js";
|
|
95
|
+
import {text_node, text_title_formatter, text_list_item_formatter} from "./yui_text.js";
|
|
95
96
|
import { TabulatorFull as Tabulator } from "tabulator-tables"; // Import Full Tabulator JS
|
|
96
97
|
// import { Tabulator } from "tabulator-tables"; // Import light Tabulator JS
|
|
97
98
|
|
|
@@ -384,7 +385,7 @@ function toolbar_button(gobj, name)
|
|
|
384
385
|
switch(name) {
|
|
385
386
|
case "save":
|
|
386
387
|
return ['button', {class: 'button p-1 button-save', title: t('save'), 'data-i18n-title': 'save', 'aria-label': t('save'), 'data-i18n-aria-label': 'save', disabled: true}, [
|
|
387
|
-
['span', {class: 'icon m-0'}, '<i class="yi-floppy-disk"></i>'],
|
|
388
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-floppy-disk"></i>')],
|
|
388
389
|
['span', {class: 'is-hidden-mobile pl-1 pr-1', i18n: 'save'}, 'save']
|
|
389
390
|
], {
|
|
390
391
|
click: function(evt) {
|
|
@@ -394,7 +395,7 @@ function toolbar_button(gobj, name)
|
|
|
394
395
|
}];
|
|
395
396
|
case "undo":
|
|
396
397
|
return ['button', {class: 'button p-1 button-undo', title: t('undo'), 'data-i18n-title': 'undo', 'aria-label': t('undo'), 'data-i18n-aria-label': 'undo', disabled: true}, [
|
|
397
|
-
['span', {class: 'icon m-0'}, '<i class="yi-arrow-rotate-left"></i>'],
|
|
398
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-arrow-rotate-left"></i>')],
|
|
398
399
|
['span', {class: 'is-hidden-mobile pl-1 pr-1', i18n: 'undo'}, 'undo']
|
|
399
400
|
], {
|
|
400
401
|
click: function(evt) {
|
|
@@ -404,7 +405,7 @@ function toolbar_button(gobj, name)
|
|
|
404
405
|
}];
|
|
405
406
|
case "clear":
|
|
406
407
|
return ['button', {class: 'button p-1 button-clear', title: t('clear'), 'data-i18n-title': 'clear', 'aria-label': t('clear'), 'data-i18n-aria-label': 'clear'}, [
|
|
407
|
-
['span', {class: 'icon m-0'}, '<i class="yi-broom-wide"></i>'],
|
|
408
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-broom-wide"></i>')],
|
|
408
409
|
['span', {class: 'is-hidden-mobile pl-1 pr-1', i18n: 'clear'}, 'clear']
|
|
409
410
|
], {
|
|
410
411
|
click: function(evt) {
|
|
@@ -414,7 +415,7 @@ function toolbar_button(gobj, name)
|
|
|
414
415
|
}];
|
|
415
416
|
case "copy":
|
|
416
417
|
return ['button', {class: 'button p-1 button-copy', title: t('copy'), 'data-i18n-title': 'copy', 'aria-label': t('copy'), 'data-i18n-aria-label': 'copy'}, [
|
|
417
|
-
['span', {class: 'icon m-0'}, '<i class="yi-copy"></i>'],
|
|
418
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-copy"></i>')],
|
|
418
419
|
['span', {class: 'is-hidden-mobile pl-1 pr-1', i18n: 'copy'}, 'copy']
|
|
419
420
|
], {click: function(evt) {
|
|
420
421
|
evt.stopPropagation();
|
|
@@ -423,7 +424,7 @@ function toolbar_button(gobj, name)
|
|
|
423
424
|
}];
|
|
424
425
|
case "paste":
|
|
425
426
|
return ['button', {class: 'button p-1 button-paste', title: t('paste'), 'data-i18n-title': 'paste', 'aria-label': t('paste'), 'data-i18n-aria-label': 'paste'}, [
|
|
426
|
-
['span', {class: 'icon m-0'}, '<i class="yi-paste"></i>'],
|
|
427
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-paste"></i>')],
|
|
427
428
|
['span', {class: 'is-hidden-mobile pl-1 pr-1', i18n: 'paste'}, 'paste']
|
|
428
429
|
], {click: async function(evt) {
|
|
429
430
|
evt.stopPropagation();
|
|
@@ -1379,7 +1380,7 @@ function create_form_field(
|
|
|
1379
1380
|
['button', {class: 'button p-1',
|
|
1380
1381
|
title: t('add'), 'data-i18n-title': 'add',
|
|
1381
1382
|
'aria-label': t('add'), 'data-i18n-aria-label': 'add'}, [
|
|
1382
|
-
['span', {class: 'icon m-0'}, '<i class="yi-plus"></i>'],
|
|
1383
|
+
['span', {class: 'icon m-0'}, html_markup('<i class="yi-plus"></i>')],
|
|
1383
1384
|
['span', {class: 'p-1 pr-2 is-hidden-mobile', i18n: 'add'}, 'add'],
|
|
1384
1385
|
], {
|
|
1385
1386
|
click: function(evt) {
|
|
@@ -2063,7 +2064,7 @@ function create_coordinates(gobj, attrs)
|
|
|
2063
2064
|
{
|
|
2064
2065
|
class: 'icon is-left is-clickable'
|
|
2065
2066
|
},
|
|
2066
|
-
'<i class="yi-location-crosshairs"></i>',
|
|
2067
|
+
html_markup('<i class="yi-location-crosshairs"></i>'),
|
|
2067
2068
|
{
|
|
2068
2069
|
'click': function (evt) {
|
|
2069
2070
|
evt.stopPropagation();
|
|
@@ -2324,6 +2325,7 @@ function template2columns(gobj, columns, template, sub_elements)
|
|
|
2324
2325
|
case "enum":
|
|
2325
2326
|
column.editor = "list";
|
|
2326
2327
|
column.editorParams = {
|
|
2328
|
+
itemFormatter: text_list_item_formatter // schema data
|
|
2327
2329
|
};
|
|
2328
2330
|
switch(field_desc.real_type) {
|
|
2329
2331
|
case "string": // TODO review types
|
package/src/c_yui_gclass.js
CHANGED
|
@@ -462,7 +462,7 @@ function render_raw(gobj)
|
|
|
462
462
|
if(dump.error) {
|
|
463
463
|
children.push(
|
|
464
464
|
['div', {class: 'GCLASS_RAW_ERROR has-text-danger is-size-7 p-2'},
|
|
465
|
-
dump.error]);
|
|
465
|
+
text_node(dump.error)]); // the backend's words
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
let $body = createElement2(['div', {class: 'GCLASS_RAW_WRAP'}, children]);
|
|
@@ -819,14 +819,14 @@ function build_methods(model)
|
|
|
819
819
|
if(model.methods.length) {
|
|
820
820
|
blocks.push(['div', {class: 'GCLASS_CHIPS'},
|
|
821
821
|
model.methods.map((m) =>
|
|
822
|
-
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), m])]);
|
|
822
|
+
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), text_node(m)])]);
|
|
823
823
|
}
|
|
824
824
|
if(model.internal_methods.length) {
|
|
825
825
|
blocks.push(['div', {class: 'GCLASS_SUBTITLE', i18n: 'internal methods'},
|
|
826
826
|
t("internal methods")]);
|
|
827
827
|
blocks.push(['div', {class: 'GCLASS_CHIPS'},
|
|
828
828
|
model.internal_methods.map((m) =>
|
|
829
|
-
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), m])]);
|
|
829
|
+
['span', row_attrs(m, {class: 'GCLASS_CHIP GCLASS_METHOD'}), text_node(m)])]);
|
|
830
830
|
}
|
|
831
831
|
|
|
832
832
|
return ['div', {class: 'GCLASS_METHODS'}, blocks];
|
package/src/c_yui_json.js
CHANGED
|
@@ -905,7 +905,7 @@ function push_collapsed_row(ctx, value, segments, depth, key, rows)
|
|
|
905
905
|
'data-i18n': err.error}, t(err.error)]);
|
|
906
906
|
} else if(err) {
|
|
907
907
|
children.push(['span', {class: 'JSON_STUB_ERR has-text-danger is-size-7 ml-2'},
|
|
908
|
-
|
|
908
|
+
text_node(err.error)]); // the backend's words
|
|
909
909
|
}
|
|
910
910
|
|
|
911
911
|
let attrs = {
|
|
@@ -1989,7 +1989,7 @@ function select_input(name, value, options)
|
|
|
1989
1989
|
let $options = options.map((option) => {
|
|
1990
1990
|
return ["option", el_attrs({value: `${option}`,
|
|
1991
1991
|
selected: `${option}` === `${value}` ? "selected" : undefined}),
|
|
1992
|
-
`${option}`];
|
|
1992
|
+
text_node(`${option}`)]; // names from the schema: data
|
|
1993
1993
|
});
|
|
1994
1994
|
|
|
1995
1995
|
return ["div", {class: "select is-fullwidth"}, [
|
|
@@ -2002,7 +2002,7 @@ function textarea_input(name, value, rows, placeholder)
|
|
|
2002
2002
|
return ["textarea", {class: "textarea", "data-name": name,
|
|
2003
2003
|
rows: `${rows || 3}`,
|
|
2004
2004
|
placeholder: placeholder || ""},
|
|
2005
|
-
value === undefined || value === null ? "" : `${value}`];
|
|
2005
|
+
text_node(value === undefined || value === null ? "" : `${value}`)];
|
|
2006
2006
|
}
|
|
2007
2007
|
|
|
2008
2008
|
/***************************************************************
|
package/src/c_yui_shell.js
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
} from "./shell_toolbar_helpers.js";
|
|
65
65
|
|
|
66
66
|
import { resolve_route, normalize_route } from "./route_resolver.js";
|
|
67
|
+
import { text_node } from "./yui_text.js";
|
|
67
68
|
import { build_nav_map } from "./route_map_model.js";
|
|
68
69
|
import {
|
|
69
70
|
section_index_target,
|
|
@@ -155,6 +156,11 @@ let PRIVATE_DATA = {
|
|
|
155
156
|
/* Count of history.back() calls WE issued to retire a dismissed
|
|
156
157
|
* overlay; the popstate they trigger is expected and ignored. */
|
|
157
158
|
expected_pops: 0,
|
|
159
|
+
/* The hash those history.back() calls were issued on: a back() of
|
|
160
|
+
* ours steps off a marker and lands on the SAME hash. A landing on
|
|
161
|
+
* another hash means the browser dropped ours (a navigation in the
|
|
162
|
+
* same turn cancels a queued traversal), see drop_expected_pops(). */
|
|
163
|
+
expected_pop_hash: "",
|
|
158
164
|
/* Overlays registered while one of those history.back() calls is
|
|
159
165
|
* still in flight: their marker is pushed once it has landed. */
|
|
160
166
|
pending_markers: [],
|
|
@@ -260,6 +266,11 @@ function mt_start(gobj)
|
|
|
260
266
|
|
|
261
267
|
if(gobj_read_attr(gobj, "use_hash")) {
|
|
262
268
|
priv.hash_handler = () => {
|
|
269
|
+
let p = gobj.priv;
|
|
270
|
+
if(p && p.expected_pops > 0 &&
|
|
271
|
+
window.location.hash !== p.expected_pop_hash) {
|
|
272
|
+
drop_expected_pops(gobj); // a back() of ours never landed
|
|
273
|
+
}
|
|
263
274
|
let route = hash_to_route(window.location.hash);
|
|
264
275
|
if(!empty_string(route)) {
|
|
265
276
|
navigate_to(gobj, route);
|
|
@@ -277,6 +288,12 @@ function mt_start(gobj)
|
|
|
277
288
|
if(!p) {
|
|
278
289
|
return;
|
|
279
290
|
}
|
|
291
|
+
if(p.expected_pops > 0 &&
|
|
292
|
+
window.location.hash !== p.expected_pop_hash) {
|
|
293
|
+
/* Not the landing of ours: it was dropped. Whatever
|
|
294
|
+
* this traversal is, it is handled below as any other. */
|
|
295
|
+
drop_expected_pops(gobj);
|
|
296
|
+
}
|
|
280
297
|
if(p.expected_pops > 0) {
|
|
281
298
|
/* A history.back() we issued to retire a dismissed
|
|
282
299
|
* overlay — the teardown already happened. */
|
|
@@ -397,6 +414,10 @@ function mt_stop(gobj)
|
|
|
397
414
|
window.removeEventListener("popstate", priv.popstate_handler);
|
|
398
415
|
priv.popstate_handler = null;
|
|
399
416
|
}
|
|
417
|
+
/* Nothing listens for the landings any more. */
|
|
418
|
+
priv.expected_pops = 0;
|
|
419
|
+
priv.expected_pop_hash = "";
|
|
420
|
+
priv.pending_markers = [];
|
|
400
421
|
if(priv.keydown_handler) {
|
|
401
422
|
window.removeEventListener("keydown", priv.keydown_handler);
|
|
402
423
|
priv.keydown_handler = null;
|
|
@@ -1787,7 +1808,7 @@ function build_toolbar_action_item(gobj, it)
|
|
|
1787
1808
|
}
|
|
1788
1809
|
if(!empty_string(it.name)) {
|
|
1789
1810
|
children.push(["span", {class: "yui-toolbar-item-label", i18n: it.name},
|
|
1790
|
-
it.name]);
|
|
1811
|
+
text_node(it.name)]);
|
|
1791
1812
|
}
|
|
1792
1813
|
|
|
1793
1814
|
let aria_key = it.aria_label || it.name || it.id || "";
|
|
@@ -2372,7 +2393,7 @@ function build_dropdown_row(gobj, sub, idx)
|
|
|
2372
2393
|
}
|
|
2373
2394
|
if(!empty_string(sub.name)) {
|
|
2374
2395
|
children.push(["span", {class: "yui-toolbar-dropdown-label",
|
|
2375
|
-
i18n: sub.name}, sub.name]);
|
|
2396
|
+
i18n: sub.name}, text_node(sub.name)]);
|
|
2376
2397
|
}
|
|
2377
2398
|
/* Trailing check for the ACTIVE option. The element is always
|
|
2378
2399
|
* rendered and hidden by CSS when not selected, so every row keeps
|
|
@@ -2646,6 +2667,25 @@ function push_overlay_marker(gobj, entry)
|
|
|
2646
2667
|
return true;
|
|
2647
2668
|
}
|
|
2648
2669
|
|
|
2670
|
+
/* A history.back() of ours that the browser dropped: nothing will land
|
|
2671
|
+
* for it, so it must not wait for a landing and swallow the reader's
|
|
2672
|
+
* next Back. The overlays that waited for it get their markers now, on
|
|
2673
|
+
* the hash they are on. */
|
|
2674
|
+
function drop_expected_pops(gobj)
|
|
2675
|
+
{
|
|
2676
|
+
let priv = gobj.priv;
|
|
2677
|
+
if(!priv || priv.expected_pops === 0) {
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
log_warning(
|
|
2681
|
+
`C_YUI_SHELL: ${priv.expected_pops} history.back() of ours did ` +
|
|
2682
|
+
`not land on '${priv.expected_pop_hash}' (now '${window.location.hash}'), dropped`
|
|
2683
|
+
);
|
|
2684
|
+
priv.expected_pops = 0;
|
|
2685
|
+
priv.expected_pop_hash = "";
|
|
2686
|
+
push_pending_markers(gobj);
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2649
2689
|
/* The history.back() calls of ours have all landed: push the markers of
|
|
2650
2690
|
* the overlays registered meanwhile, in their order. One closed in the
|
|
2651
2691
|
* meantime (dismissed, drained, or no longer on the stack) has none. */
|
|
@@ -2699,6 +2739,7 @@ function overlay_dismissed(gobj, entry)
|
|
|
2699
2739
|
let st = window.history.state;
|
|
2700
2740
|
if(st && st.__yui_overlay__ === entry.id) {
|
|
2701
2741
|
priv.expected_pops++;
|
|
2742
|
+
priv.expected_pop_hash = window.location.hash;
|
|
2702
2743
|
try {
|
|
2703
2744
|
window.history.back();
|
|
2704
2745
|
} catch(e) {
|
|
@@ -122,7 +122,7 @@ import "./tabulator.css";
|
|
|
122
122
|
import {cell_text, hook_cell_spec} from "./table_cell_text.js";
|
|
123
123
|
|
|
124
124
|
import { TabulatorFull as Tabulator } from "tabulator-tables";
|
|
125
|
-
import {text_node} from "./yui_text.js";
|
|
125
|
+
import {text_node, text_list_item_formatter} from "./yui_text.js";
|
|
126
126
|
|
|
127
127
|
/***************************************************************
|
|
128
128
|
* Constants
|
|
@@ -1288,7 +1288,10 @@ function create_tabulator(gobj)
|
|
|
1288
1288
|
break;
|
|
1289
1289
|
case "enum":
|
|
1290
1290
|
colDef.editor = "list";
|
|
1291
|
-
colDef.editorParams = {
|
|
1291
|
+
colDef.editorParams = {
|
|
1292
|
+
values: field_desc.enum_list || [],
|
|
1293
|
+
itemFormatter: text_list_item_formatter // schema data
|
|
1294
|
+
};
|
|
1292
1295
|
break;
|
|
1293
1296
|
case "integer":
|
|
1294
1297
|
case "real":
|
|
@@ -1339,7 +1342,8 @@ function create_tabulator(gobj)
|
|
|
1339
1342
|
colDef.headerFilter = "list";
|
|
1340
1343
|
colDef.headerFilterParams = {
|
|
1341
1344
|
values: field_desc.enum_list || [],
|
|
1342
|
-
clearable: true
|
|
1345
|
+
clearable: true,
|
|
1346
|
+
itemFormatter: text_list_item_formatter // schema data
|
|
1343
1347
|
};
|
|
1344
1348
|
break;
|
|
1345
1349
|
case "fkey":
|
|
@@ -2080,7 +2084,7 @@ function icon_formatter(cell)
|
|
|
2080
2084
|
return createElement2([
|
|
2081
2085
|
"span",
|
|
2082
2086
|
{class: "ICON_CELL_UNKNOWN is-size-7 yui-text-quiet", title: name},
|
|
2083
|
-
name
|
|
2087
|
+
text_node(name) // data, not markup: it failed the name check
|
|
2084
2088
|
]);
|
|
2085
2089
|
}
|
|
2086
2090
|
|