@yuneta/gobj-ui 7.26.6 → 7.26.8
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 +74 -25
- package/dist/gobj-ui.cjs.js +967 -377
- package/dist/gobj-ui.es.js +967 -377
- package/index.js +5 -1
- package/package.json +2 -2
- package/src/c_g6_nodes_tree.js +69 -24
- package/src/c_yui_form.js +331 -140
- package/src/c_yui_gclass.js +26 -21
- package/src/c_yui_gobj_tree_js.js +16 -5
- package/src/c_yui_json.js +7 -6
- package/src/c_yui_json_graph.js +42 -14
- package/src/c_yui_json_pad.js +2 -1
- package/src/c_yui_map.js +139 -75
- package/src/c_yui_nav.js +60 -20
- package/src/c_yui_pager.js +14 -9
- package/src/c_yui_period.js +16 -6
- package/src/c_yui_schema_editor.js +3 -2
- package/src/c_yui_shell.js +96 -31
- package/src/c_yui_treedb_topic_with_form.js +50 -56
- package/src/c_yui_treedb_topics.js +8 -7
- package/src/c_yui_uplot.js +1 -1
- package/src/c_yui_window.js +123 -36
- package/src/c_yui_window_manager.js +8 -3
- package/src/c_yui_wizard.js +23 -8
- package/src/delete_impact.js +5 -3
- package/src/form_json_field.js +123 -0
- package/src/form_json_field.test.js +49 -0
- package/src/form_json_field.wiring.test.js +137 -0
- package/src/form_table_rearm.wiring.test.js +158 -0
- package/src/g6_event_kw.js +36 -0
- package/src/nav_cards_helpers.js +2 -1
- package/src/nav_cards_helpers.test.js +7 -3
- package/src/schema_to_c.js +27 -1
- package/src/schema_to_c.test.js +15 -1
- package/src/shell_modals.js +5 -3
- package/src/shell_route_map.js +18 -13
- package/src/treedb_topics_transport.wiring.test.js +35 -1
- package/src/vite_plugin_yuneta_html.test.js +79 -0
- package/src/window_show.wiring.test.js +83 -0
- package/src/window_veto_back.wiring.test.js +136 -0
- package/src/wizard_chrome.wiring.test.js +87 -0
- package/src/yui_dev.js +23 -14
- package/src/yui_frontend_view.js +4 -4
- package/src/yui_gclass_view.js +3 -3
- package/src/yui_table_filter_clear.js +44 -44
- package/src/yui_text.js +31 -0
- package/src/yui_text.test.js +39 -0
- package/vite-plugin-yuneta-html.js +36 -9
|
@@ -113,6 +113,7 @@ import {
|
|
|
113
113
|
yui_asset_ids, yui_asset_element, yui_asset_open_link, yui_asset_release
|
|
114
114
|
} from "./yui_asset.js";
|
|
115
115
|
import {delete_impact} from "./delete_impact.js";
|
|
116
|
+
import {parse_json_field} from "./form_json_field.js";
|
|
116
117
|
|
|
117
118
|
import "./c_yui_treedb_topic_with_form.css";
|
|
118
119
|
import {yui_shell_show_error} from "./shell_modals.js";
|
|
@@ -121,6 +122,7 @@ import "./tabulator.css";
|
|
|
121
122
|
import {cell_text, hook_cell_spec} from "./table_cell_text.js";
|
|
122
123
|
|
|
123
124
|
import { TabulatorFull as Tabulator } from "tabulator-tables";
|
|
125
|
+
import {text_node} from "./yui_text.js";
|
|
124
126
|
|
|
125
127
|
/***************************************************************
|
|
126
128
|
* Constants
|
|
@@ -495,6 +497,7 @@ function mt_stop(gobj)
|
|
|
495
497
|
close_cell_file_dialog(gobj);
|
|
496
498
|
close_hook_choice(gobj);
|
|
497
499
|
drop_pending_assets(gobj);
|
|
500
|
+
drop_pending_pages(gobj);
|
|
498
501
|
table__destroy(gobj);
|
|
499
502
|
}
|
|
500
503
|
|
|
@@ -610,8 +613,8 @@ function build_ui(gobj)
|
|
|
610
613
|
{
|
|
611
614
|
function create_table_toolbar()
|
|
612
615
|
{
|
|
613
|
-
// TODO
|
|
614
|
-
// TODO
|
|
616
|
+
// TODO authorization: only when the user may modify the data!!!
|
|
617
|
+
// TODO keep these buttons at the top when scrolling (clip ?)
|
|
615
618
|
let $table_toolbar = [];
|
|
616
619
|
/* One plan decides every write affordance (treedb_write_plan.js):
|
|
617
620
|
* `readonly` is the STATE of the topic and beats each with_* flag,
|
|
@@ -1785,6 +1788,7 @@ function create_tabulator(gobj)
|
|
|
1785
1788
|
try {
|
|
1786
1789
|
n = tabulator.getDataCount("active");
|
|
1787
1790
|
} catch(e) {
|
|
1791
|
+
log_warning(`${gobj_short_name(gobj)}: cannot count the table's rows: ${e}`);
|
|
1788
1792
|
n = 0;
|
|
1789
1793
|
}
|
|
1790
1794
|
}
|
|
@@ -1883,9 +1887,9 @@ function create_tabulator(gobj)
|
|
|
1883
1887
|
tabulator._ready = true;
|
|
1884
1888
|
apply_row_filters(gobj);
|
|
1885
1889
|
update_rowcount();
|
|
1886
|
-
/*
|
|
1887
|
-
*
|
|
1888
|
-
*
|
|
1890
|
+
/* The ✕ of each header filter. A filter is removed by erasing what
|
|
1891
|
+
* was typed, and with several columns filtered, getting back to the
|
|
1892
|
+
* whole table meant remembering which ones were touched. */
|
|
1889
1893
|
yui_table_filter_clear(tabulator);
|
|
1890
1894
|
if(tabulator._pendingData !== undefined) {
|
|
1891
1895
|
tabulator.setData(tabulator._pendingData);
|
|
@@ -2138,10 +2142,12 @@ function build_json_cell_preview(value)
|
|
|
2138
2142
|
['a', {
|
|
2139
2143
|
class: 'JSON_CELL',
|
|
2140
2144
|
title: t('show json'),
|
|
2141
|
-
'data-i18n-title': 'show json'
|
|
2145
|
+
'data-i18n-title': 'show json',
|
|
2146
|
+
'aria-label': t('show json'),
|
|
2147
|
+
'data-i18n-aria-label': 'show json'
|
|
2142
2148
|
}, [
|
|
2143
2149
|
['span', {class: 'JSON_CELL_ICON icon yi-eye'}],
|
|
2144
|
-
['span', {class: 'JSON_CELL_PREVIEW'}, text]
|
|
2150
|
+
['span', {class: 'JSON_CELL_PREVIEW'}, text_node(text)]
|
|
2145
2151
|
]]
|
|
2146
2152
|
);
|
|
2147
2153
|
}
|
|
@@ -2997,7 +3003,7 @@ function open_cell_file_dialog(gobj, row_id, col_id)
|
|
|
2997
3003
|
['span', {class: 'CELL_FILE_LOADING', i18n: 'loading'}, 'loading']
|
|
2998
3004
|
]],
|
|
2999
3005
|
['div', {class: 'CELL_FILE_CAPTION'}, [
|
|
3000
|
-
['span', {class: 'CELL_FILE_ID'}, id]
|
|
3006
|
+
['span', {class: 'CELL_FILE_ID'}, text_node(id)]
|
|
3001
3007
|
]]
|
|
3002
3008
|
]]
|
|
3003
3009
|
));
|
|
@@ -3060,7 +3066,7 @@ function fill_cell_file_slot(gobj, pend, answer, error)
|
|
|
3060
3066
|
.filter((s) => !!s).join(" · ");
|
|
3061
3067
|
if(meta) {
|
|
3062
3068
|
$caption.appendChild(
|
|
3063
|
-
createElement2(['span', {class: 'CELL_FILE_META'}, meta])
|
|
3069
|
+
createElement2(['span', {class: 'CELL_FILE_META'}, text_node(meta)])
|
|
3064
3070
|
);
|
|
3065
3071
|
}
|
|
3066
3072
|
/* Full size, in the browser's own viewer: a photo is read at its
|
|
@@ -3144,7 +3150,7 @@ function open_hook_choice_dialog(gobj, targets, parent_id, hook)
|
|
|
3144
3150
|
'aria-label': t(tg.topic_name),
|
|
3145
3151
|
'data-i18n-aria-label': tg.topic_name
|
|
3146
3152
|
}, [
|
|
3147
|
-
['span', {i18n: tg.topic_name}, tg.topic_name]
|
|
3153
|
+
['span', {i18n: tg.topic_name}, text_node(tg.topic_name)]
|
|
3148
3154
|
], {
|
|
3149
3155
|
click: () => {
|
|
3150
3156
|
gobj_send_event(gobj, "EV_CHOOSE_LINKED", {
|
|
@@ -3480,54 +3486,23 @@ function transform__form_value_2_treedb_value(gobj, col, value, operation)
|
|
|
3480
3486
|
case "object":
|
|
3481
3487
|
case "dict":
|
|
3482
3488
|
case "template":
|
|
3483
|
-
if(is_string(value)) {
|
|
3484
|
-
// Come from the form
|
|
3485
|
-
try {
|
|
3486
|
-
value = JSON.parse(value);
|
|
3487
|
-
} catch (e) {
|
|
3488
|
-
value = {};
|
|
3489
|
-
}
|
|
3490
|
-
} else if(is_object(value)) {
|
|
3491
|
-
// Come from the table
|
|
3492
|
-
}
|
|
3493
|
-
if(!is_object(value)) {
|
|
3494
|
-
value = {};
|
|
3495
|
-
}
|
|
3496
|
-
break;
|
|
3497
3489
|
case "array":
|
|
3498
3490
|
case "list":
|
|
3499
|
-
if(is_string(value)) {
|
|
3500
|
-
// Come from the form
|
|
3501
|
-
try {
|
|
3502
|
-
value = JSON.parse(value);
|
|
3503
|
-
} catch (e) {
|
|
3504
|
-
value = [];
|
|
3505
|
-
}
|
|
3506
|
-
} else if(is_array(value)) {
|
|
3507
|
-
// Come from the table
|
|
3508
|
-
}
|
|
3509
|
-
if(!is_array(value)) {
|
|
3510
|
-
value = [];
|
|
3511
|
-
}
|
|
3512
|
-
break;
|
|
3513
3491
|
case "coordinates":
|
|
3514
|
-
case "blob":
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
} else if(is_object(value)) {
|
|
3524
|
-
// Come from the table
|
|
3525
|
-
} else if(is_array(value)) {
|
|
3526
|
-
// Come from the table
|
|
3492
|
+
case "blob": {
|
|
3493
|
+
/* A value that is no json of the column's shape is logged and
|
|
3494
|
+
* handed on AS IT IS, the same as C_YUI_FORM does: an empty
|
|
3495
|
+
* {} / [] in its place is a value nobody wrote (a copy put it
|
|
3496
|
+
* on the clipboard, a save wiped the column). The form refuses
|
|
3497
|
+
* to save such a field before it gets here. */
|
|
3498
|
+
let r = parse_json_field(value, field_desc.type);
|
|
3499
|
+
if(r.error) {
|
|
3500
|
+
log_error(`${gobj_short_name(gobj)}: column '${col.id}' (${field_desc.type}) holds no valid json, handed on as it is`);
|
|
3527
3501
|
} else {
|
|
3528
|
-
value =
|
|
3502
|
+
value = r.value;
|
|
3529
3503
|
}
|
|
3530
3504
|
break;
|
|
3505
|
+
}
|
|
3531
3506
|
|
|
3532
3507
|
case "enum":
|
|
3533
3508
|
switch(field_desc.real_type) {
|
|
@@ -3850,7 +3825,7 @@ function ac_load_nodes(gobj, event, kw, src)
|
|
|
3850
3825
|
}
|
|
3851
3826
|
|
|
3852
3827
|
/*
|
|
3853
|
-
* TODO
|
|
3828
|
+
* TODO scroll to the updated row ???
|
|
3854
3829
|
* Select only if it has update/create mode
|
|
3855
3830
|
*/
|
|
3856
3831
|
// if(data.length == 1) {
|
|
@@ -3890,7 +3865,7 @@ function ac_load_node_created(gobj, event, kw, src)
|
|
|
3890
3865
|
}
|
|
3891
3866
|
|
|
3892
3867
|
/*
|
|
3893
|
-
* TODO
|
|
3868
|
+
* TODO scroll to the updated row ???
|
|
3894
3869
|
* Select only if it has update/create mode
|
|
3895
3870
|
*/
|
|
3896
3871
|
|
|
@@ -3932,7 +3907,7 @@ function ac_load_node_updated(gobj, event, kw, src)
|
|
|
3932
3907
|
}
|
|
3933
3908
|
|
|
3934
3909
|
/*
|
|
3935
|
-
* TODO
|
|
3910
|
+
* TODO scroll to the updated row ???
|
|
3936
3911
|
* Select only if it has update/create mode
|
|
3937
3912
|
*/
|
|
3938
3913
|
|
|
@@ -4086,7 +4061,7 @@ function ac_new_row(gobj, event, kw, src)
|
|
|
4086
4061
|
return -1; /* Error already logged */
|
|
4087
4062
|
}
|
|
4088
4063
|
/*
|
|
4089
|
-
* Build default values. TODO
|
|
4064
|
+
* Build default values. TODO should this not be in the desc configuration?
|
|
4090
4065
|
*/
|
|
4091
4066
|
let row = {};
|
|
4092
4067
|
let desc = gobj_read_attr(gobj, "desc");
|
|
@@ -4932,6 +4907,25 @@ function request_page(gobj, page, size)
|
|
|
4932
4907
|
});
|
|
4933
4908
|
}
|
|
4934
4909
|
|
|
4910
|
+
/************************************************************
|
|
4911
|
+
* The view stops: no page request is waited for any more. Each
|
|
4912
|
+
* one's watchdog would otherwise fire EV_PAGE_TIMEOUT on a gobj
|
|
4913
|
+
* stopped -- or destroyed -- 20 s later.
|
|
4914
|
+
************************************************************/
|
|
4915
|
+
function drop_pending_pages(gobj)
|
|
4916
|
+
{
|
|
4917
|
+
let priv = gobj.priv;
|
|
4918
|
+
let pending = priv._pending_pages || {};
|
|
4919
|
+
priv._pending_pages = {};
|
|
4920
|
+
for(let req_id of Object.keys(pending)) {
|
|
4921
|
+
let pend = pending[req_id];
|
|
4922
|
+
if(pend.timer) {
|
|
4923
|
+
window.clearTimeout(pend.timer);
|
|
4924
|
+
}
|
|
4925
|
+
pend.reject(new Error("the view stopped"));
|
|
4926
|
+
}
|
|
4927
|
+
}
|
|
4928
|
+
|
|
4935
4929
|
/************************************************************
|
|
4936
4930
|
* Settle a parked page request, however it ended.
|
|
4937
4931
|
************************************************************/
|
|
@@ -85,6 +85,7 @@ import {
|
|
|
85
85
|
} from "./treedb_topic_keys.js";
|
|
86
86
|
|
|
87
87
|
import {t} from "i18next";
|
|
88
|
+
import {text_node} from "./yui_text.js";
|
|
88
89
|
|
|
89
90
|
/***************************************************************
|
|
90
91
|
* Constants
|
|
@@ -440,7 +441,7 @@ function build_ui(gobj)
|
|
|
440
441
|
'TREEDB_TOPICS_SOURCE' : 'TREEDB_TOPICS_SOURCE is-hidden',
|
|
441
442
|
title: source_url, 'aria-label': source_url}, [
|
|
442
443
|
['span', {class: 'icon'}, [yui_toolbar_icon('yi-cloudversify')]],
|
|
443
|
-
['span', {class: 'TREEDB_TOPICS_SOURCE_URL'}, source_url]
|
|
444
|
+
['span', {class: 'TREEDB_TOPICS_SOURCE_URL'}, text_node(source_url)]
|
|
444
445
|
]],
|
|
445
446
|
...graph_items,
|
|
446
447
|
/* Inspect the treedb's raw tranger json (whole service,
|
|
@@ -622,7 +623,7 @@ function add_tab(gobj, gobj2, id, text, icon)
|
|
|
622
623
|
* TAB: Add text
|
|
623
624
|
*/
|
|
624
625
|
$a.appendChild(
|
|
625
|
-
createElement2(['span', {i18n: text, class: ''}, text])
|
|
626
|
+
createElement2(['span', {i18n: text, class: ''}, text_node(text)])
|
|
626
627
|
);
|
|
627
628
|
|
|
628
629
|
/*
|
|
@@ -824,7 +825,7 @@ function add_topic_card(gobj, id, text, icon, desc)
|
|
|
824
825
|
'aria-label': text, 'data-i18n-aria-label': text}, [
|
|
825
826
|
['span', {class: 'icon is-medium'}, [['i', {class: icon || 'yi-table',
|
|
826
827
|
'aria-hidden': 'true'}]]],
|
|
827
|
-
['span', {class: 'yui-nav-label', i18n: text}, text]
|
|
828
|
+
['span', {class: 'yui-nav-label', i18n: text}, text_node(text)]
|
|
828
829
|
]]
|
|
829
830
|
);
|
|
830
831
|
$card.addEventListener("click", function(ev) {
|
|
@@ -861,7 +862,7 @@ function add_topic_card(gobj, id, text, icon, desc)
|
|
|
861
862
|
|
|
862
863
|
let $card = createElement2(
|
|
863
864
|
['div', {class: 'TREEDB_TOPIC_CARD', 'data-topic': topic}, [
|
|
864
|
-
['span', {class: 'TREEDB_TOPIC_CARD_NAME', i18n: text}, text],
|
|
865
|
+
['span', {class: 'TREEDB_TOPIC_CARD_NAME', i18n: text}, text_node(text)],
|
|
865
866
|
...topic_card_meta(desc),
|
|
866
867
|
['div', {class: 'TREEDB_TOPIC_CARD_ACTIONS'}, actions]
|
|
867
868
|
]]
|
|
@@ -1169,15 +1170,15 @@ function build_topic_info_panel(gobj, $info, topic, desc)
|
|
|
1169
1170
|
push_meta("system", ["code", {title: `${desc.system_flag}`}, sf_names.join(" | ")]);
|
|
1170
1171
|
}
|
|
1171
1172
|
if(pkey) {
|
|
1172
|
-
push_meta("pkey", ["code", {}, pkey]);
|
|
1173
|
+
push_meta("pkey", ["code", {}, text_node(pkey)]);
|
|
1173
1174
|
}
|
|
1174
1175
|
if(pkey2s.length > 0) {
|
|
1175
1176
|
push_meta("pkey2s", ["span", {class: "tags"},
|
|
1176
|
-
pkey2s.map(name => ["span", {class: "tag is-warning"}, name])
|
|
1177
|
+
pkey2s.map(name => ["span", {class: "tag is-warning"}, text_node(name)])
|
|
1177
1178
|
]);
|
|
1178
1179
|
}
|
|
1179
1180
|
push_meta("tkey", tkey
|
|
1180
|
-
? ["code", {}, tkey]
|
|
1181
|
+
? ["code", {}, text_node(tkey)]
|
|
1181
1182
|
: ["span", {class: "has-text-grey", i18n: "append time"}, "append time"]
|
|
1182
1183
|
);
|
|
1183
1184
|
|
package/src/c_yui_uplot.js
CHANGED
package/src/c_yui_window.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Window - position fixed
|
|
5
5
|
*
|
|
6
|
-
* Copyright (c) 2025, ArtGins.
|
|
6
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
7
7
|
* All Rights Reserved.
|
|
8
8
|
***********************************************************************/
|
|
9
9
|
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
gclass_create,
|
|
15
15
|
event_flag_t,
|
|
16
16
|
log_error,
|
|
17
|
+
log_warning,
|
|
17
18
|
gobj_read_pointer_attr,
|
|
18
19
|
gobj_subscribe_event,
|
|
19
20
|
gobj_write_attr,
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
} from "./c_yui_shell.js";
|
|
54
55
|
|
|
55
56
|
import "./c_yui_window.css";
|
|
57
|
+
import {text_node} from "./yui_text.js";
|
|
56
58
|
|
|
57
59
|
/***************************************************************
|
|
58
60
|
* Constants
|
|
@@ -102,10 +104,10 @@ SDATA(data_type_t.DTP_STRING, "logical_class",0, "", "Logical UPPER_SNAKE
|
|
|
102
104
|
SDATA(data_type_t.DTP_STRING, "title_prefix", 0, "", "Optional DATA half of the title (a topic/service/marker name), shown before `title` and never translated. Use it instead of composing `${name} · ${t(key)}` into `title`, which cannot re-translate"),
|
|
103
105
|
SDATA(data_type_t.DTP_STRING, "title", 0, "", "Window title, an i18n KEY: painted in the title bar (unless `header` overrides it) and on the dock chip. Pass the key, not t(key), or it cannot re-translate"),
|
|
104
106
|
SDATA(data_type_t.DTP_STRING, "icon", 0, "", "Window icon (by window type), leading the title bar and the dock chip: a yi-* class name or inline SVG"),
|
|
105
|
-
// TODO
|
|
106
|
-
SDATA(data_type_t.DTP_POINTER, "focus", 0, null, "
|
|
107
|
-
SDATA(data_type_t.DTP_BOOLEAN, "modal", 0, false, "
|
|
108
|
-
SDATA(data_type_t.DTP_BOOLEAN, "keyboard", 0, true, "
|
|
107
|
+
// TODO declared, NOT implemented yet: focus, modal, keyboard (Escape does not close a window)
|
|
108
|
+
SDATA(data_type_t.DTP_POINTER, "focus", 0, null, "NOT implemented yet: would bring focus to the element, a number or a selector"),
|
|
109
|
+
SDATA(data_type_t.DTP_BOOLEAN, "modal", 0, false, "NOT implemented yet: would enable modal mode"),
|
|
110
|
+
SDATA(data_type_t.DTP_BOOLEAN, "keyboard", 0, true, "NOT implemented yet: would close the window on ESC (Escape does nothing today)"),
|
|
109
111
|
SDATA(data_type_t.DTP_BOOLEAN, "back_dismissable", 0, true, "Browser Back closes this window (floating overlays only; ignored when it has a `manager`)"),
|
|
110
112
|
SDATA(data_type_t.DTP_BOOLEAN, "keep_on_navigate", 0, false, "This window is a navigation PANEL: a route change does not close it"),
|
|
111
113
|
SDATA(data_type_t.DTP_POINTER, "back_overlay", 0, null, "Internal: overlay-history entry (Back-button integration)"),
|
|
@@ -188,15 +190,7 @@ function mt_create(gobj)
|
|
|
188
190
|
* is also why a navigation panel prefers a manager, and falls
|
|
189
191
|
* back to `keep_on_navigate` when the app has no dock.
|
|
190
192
|
* Retired in mt_destroy (covers every teardown path). */
|
|
191
|
-
|
|
192
|
-
if(shell) {
|
|
193
|
-
let overlay = yui_shell_register_overlay(
|
|
194
|
-
shell,
|
|
195
|
-
function() { close_window(gobj); },
|
|
196
|
-
{keep_on_navigate: gobj_read_bool_attr(gobj, "keep_on_navigate")}
|
|
197
|
-
);
|
|
198
|
-
gobj_write_attr(gobj, "back_overlay", overlay);
|
|
199
|
-
}
|
|
193
|
+
register_back_overlay(gobj);
|
|
200
194
|
}
|
|
201
195
|
|
|
202
196
|
/* Keep the window inside the viewport on a breakpoint change.
|
|
@@ -347,7 +341,7 @@ function build_default_header(gobj)
|
|
|
347
341
|
if(!empty_string(prefix)) {
|
|
348
342
|
items.push(
|
|
349
343
|
['span', {class: 'WINDOW_TITLE_PREFIX has-text-weight-semibold'},
|
|
350
|
-
prefix]
|
|
344
|
+
text_node(prefix)] // data, not markup
|
|
351
345
|
);
|
|
352
346
|
}
|
|
353
347
|
if(!empty_string(title)) {
|
|
@@ -400,7 +394,11 @@ function resolve_manager(gobj)
|
|
|
400
394
|
return null;
|
|
401
395
|
}
|
|
402
396
|
if(typeof m === "string") {
|
|
403
|
-
|
|
397
|
+
let name = m;
|
|
398
|
+
m = gobj_find_service(name, false) || null;
|
|
399
|
+
if(!m) {
|
|
400
|
+
log_warning(`${GCLASS_NAME}: window manager '${name}' not found: no dock, no minimize`);
|
|
401
|
+
}
|
|
404
402
|
gobj_write_attr(gobj, "manager", m);
|
|
405
403
|
}
|
|
406
404
|
return m;
|
|
@@ -550,7 +548,9 @@ function build_ui(gobj)
|
|
|
550
548
|
* Minimize (to dock)
|
|
551
549
|
*----------------------------*/
|
|
552
550
|
['button', {
|
|
553
|
-
class: 'WINDOW_MIN yui-wc wc-min', type: 'button',
|
|
551
|
+
class: 'WINDOW_MIN yui-wc wc-min', type: 'button',
|
|
552
|
+
title: t('minimize'), 'data-i18n-title': 'minimize',
|
|
553
|
+
'aria-label': t('minimize'), 'data-i18n-aria-label': 'minimize',
|
|
554
554
|
style: (gobj_read_bool_attr(gobj, "showMin") &&
|
|
555
555
|
gobj_read_pointer_attr(gobj, "manager")) ? '' : 'display:none;',
|
|
556
556
|
}, WC_MIN, {
|
|
@@ -563,7 +563,9 @@ function build_ui(gobj)
|
|
|
563
563
|
* Maximize / restore
|
|
564
564
|
*----------------------------*/
|
|
565
565
|
['button', {
|
|
566
|
-
class: 'WINDOW_MAX yui-wc wc-max', type: 'button',
|
|
566
|
+
class: 'WINDOW_MAX yui-wc wc-max', type: 'button',
|
|
567
|
+
title: t('maximize'), 'data-i18n-title': 'maximize',
|
|
568
|
+
'aria-label': t('maximize'), 'data-i18n-aria-label': 'maximize',
|
|
567
569
|
style: gobj_read_bool_attr(gobj, "showMax") ? '' : 'display:none;',
|
|
568
570
|
}, WC_MAX, {
|
|
569
571
|
click: (evt) => {
|
|
@@ -575,11 +577,13 @@ function build_ui(gobj)
|
|
|
575
577
|
* Close
|
|
576
578
|
*----------------------------*/
|
|
577
579
|
['button', {
|
|
578
|
-
class: 'WINDOW_CLOSE yui-wc wc-close', type: 'button',
|
|
580
|
+
class: 'WINDOW_CLOSE yui-wc wc-close', type: 'button',
|
|
581
|
+
title: t('close'), 'data-i18n-title': 'close',
|
|
582
|
+
'aria-label': t('close'), 'data-i18n-aria-label': 'close',
|
|
579
583
|
}, WC_CLOSE, {
|
|
580
584
|
click: (evt) => {
|
|
581
585
|
evt.stopPropagation();
|
|
582
|
-
|
|
586
|
+
gobj_send_event(gobj, "EV_CLOSE_WINDOW", {}, gobj);
|
|
583
587
|
}
|
|
584
588
|
}]
|
|
585
589
|
]]
|
|
@@ -753,7 +757,55 @@ function destroy_ui(gobj)
|
|
|
753
757
|
}
|
|
754
758
|
|
|
755
759
|
/************************************************************
|
|
760
|
+
* Register this floating window in the shell's overlay history,
|
|
761
|
+
* so the browser Back closes it.
|
|
756
762
|
*
|
|
763
|
+
* The shell takes the entry off its stack BEFORE it calls the
|
|
764
|
+
* close function (Back, or a route change draining overlays). When
|
|
765
|
+
* a subscriber of EV_WINDOW_TO_CLOSE vetoes the close, the window
|
|
766
|
+
* stays up with no entry: Back would no longer close it, and it
|
|
767
|
+
* would float over the next views. So a window that survives its
|
|
768
|
+
* own close function registers again.
|
|
769
|
+
************************************************************/
|
|
770
|
+
function register_back_overlay(gobj)
|
|
771
|
+
{
|
|
772
|
+
let shell = yui_shell_of(gobj);
|
|
773
|
+
if(!shell) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
/* A window that survives its close gets its entry back -- but only
|
|
777
|
+
* once the question is over. A close that ASKS (unsaved changes)
|
|
778
|
+
* opened a dialog that registered its own entry; one put back now
|
|
779
|
+
* would sit ABOVE the question, and every Back would stack another
|
|
780
|
+
* dialog instead of closing the one on screen. */
|
|
781
|
+
const rearm = function() {
|
|
782
|
+
if(!gobj_is_destroying(gobj) && !gobj_read_attr(gobj, "back_overlay")) {
|
|
783
|
+
register_back_overlay(gobj);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
let overlay = yui_shell_register_overlay(
|
|
787
|
+
shell,
|
|
788
|
+
function() {
|
|
789
|
+
gobj_write_attr(gobj, "back_overlay", null);
|
|
790
|
+
const closing = close_window(gobj);
|
|
791
|
+
if(closing.state === "vetoed") {
|
|
792
|
+
rearm();
|
|
793
|
+
} else if(closing.state === "asking") {
|
|
794
|
+
closing.answer.then(rearm);
|
|
795
|
+
}
|
|
796
|
+
},
|
|
797
|
+
{keep_on_navigate: gobj_read_bool_attr(gobj, "keep_on_navigate")}
|
|
798
|
+
);
|
|
799
|
+
gobj_write_attr(gobj, "back_overlay", overlay);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/************************************************************
|
|
803
|
+
* Ask to close the window. Answers what happened:
|
|
804
|
+
* {state: "closed"} the window is destroyed
|
|
805
|
+
* {state: "vetoed"} a subscriber kept it open
|
|
806
|
+
* {state: "asking", answer} a subscriber asked a question
|
|
807
|
+
* first; `answer` resolves to
|
|
808
|
+
* it once it is over
|
|
757
809
|
************************************************************/
|
|
758
810
|
function close_window(gobj)
|
|
759
811
|
{
|
|
@@ -775,21 +827,34 @@ function close_window(gobj)
|
|
|
775
827
|
}
|
|
776
828
|
gobj_stop_children(gobj);
|
|
777
829
|
gobj_destroy(gobj);
|
|
778
|
-
|
|
779
|
-
yui_shell_confirm_yesnocancel(
|
|
780
|
-
yui_shell_of(gobj), kw_close.warning,
|
|
781
|
-
{t: t, yes_label: "yes", no_label: "no", cancel_label: "cancel"}
|
|
782
|
-
).then(function(answer) {
|
|
783
|
-
if(answer === "yes") {
|
|
784
|
-
if(on_close) {
|
|
785
|
-
on_close();
|
|
786
|
-
}
|
|
787
|
-
gobj_stop(gobj);
|
|
788
|
-
gobj_stop_children(gobj);
|
|
789
|
-
gobj_destroy(gobj);
|
|
790
|
-
}
|
|
791
|
-
});
|
|
830
|
+
return {state: "closed"};
|
|
792
831
|
}
|
|
832
|
+
if(!kw_close.warning) {
|
|
833
|
+
return {state: "vetoed"};
|
|
834
|
+
}
|
|
835
|
+
const answer = yui_shell_confirm_yesnocancel(
|
|
836
|
+
yui_shell_of(gobj), kw_close.warning,
|
|
837
|
+
{t: t, yes_label: "yes", no_label: "no", cancel_label: "cancel"}
|
|
838
|
+
).then(function(answer) {
|
|
839
|
+
if(answer !== "yes") {
|
|
840
|
+
return answer;
|
|
841
|
+
}
|
|
842
|
+
/* The question was asynchronous: the window may have been
|
|
843
|
+
* torn down by another path while it was open. */
|
|
844
|
+
if(gobj_is_destroying(gobj)) {
|
|
845
|
+
return answer;
|
|
846
|
+
}
|
|
847
|
+
if(on_close) {
|
|
848
|
+
on_close();
|
|
849
|
+
}
|
|
850
|
+
if(gobj_is_running(gobj)) {
|
|
851
|
+
gobj_stop(gobj);
|
|
852
|
+
}
|
|
853
|
+
gobj_stop_children(gobj);
|
|
854
|
+
gobj_destroy(gobj);
|
|
855
|
+
return answer;
|
|
856
|
+
});
|
|
857
|
+
return {state: "asking", answer: answer};
|
|
793
858
|
}
|
|
794
859
|
|
|
795
860
|
/************************************************************
|
|
@@ -841,8 +906,12 @@ function set_max_icon(gobj, maximized)
|
|
|
841
906
|
}
|
|
842
907
|
let $btn = $container.querySelector('.wc-max');
|
|
843
908
|
if($btn) {
|
|
909
|
+
let key = maximized ? 'restore' : 'maximize';
|
|
844
910
|
$btn.innerHTML = maximized ? WC_RESTORE : WC_MAX;
|
|
845
|
-
$btn.setAttribute('
|
|
911
|
+
$btn.setAttribute('title', t(key));
|
|
912
|
+
$btn.setAttribute('data-i18n-title', key);
|
|
913
|
+
$btn.setAttribute('aria-label', t(key));
|
|
914
|
+
$btn.setAttribute('data-i18n-aria-label', key);
|
|
846
915
|
}
|
|
847
916
|
}
|
|
848
917
|
|
|
@@ -1165,7 +1234,25 @@ function ac_refresh(gobj, event, kw, src)
|
|
|
1165
1234
|
************************************************************/
|
|
1166
1235
|
function ac_show(gobj, event, kw, src)
|
|
1167
1236
|
{
|
|
1168
|
-
|
|
1237
|
+
/* Bring the window back in front of the reader: out of the dock if
|
|
1238
|
+
* it was minimized, above the others. The manager owns both when
|
|
1239
|
+
* there is one; without one the window is just made visible and
|
|
1240
|
+
* moved to the top of its layer. */
|
|
1241
|
+
let manager = gobj_read_pointer_attr(gobj, "manager");
|
|
1242
|
+
if(manager) {
|
|
1243
|
+
gobj_send_event(manager, "EV_FOCUS_WINDOW", {window: gobj}, gobj);
|
|
1244
|
+
return 0;
|
|
1245
|
+
}
|
|
1246
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
1247
|
+
if(!$container) {
|
|
1248
|
+
log_error(`${gobj_short_name(gobj)}: EV_SHOW without a container`);
|
|
1249
|
+
return -1;
|
|
1250
|
+
}
|
|
1251
|
+
$container.style.removeProperty('display');
|
|
1252
|
+
let $parent = $container.parentNode;
|
|
1253
|
+
if($parent && $parent.lastChild !== $container) {
|
|
1254
|
+
$parent.appendChild($container);
|
|
1255
|
+
}
|
|
1169
1256
|
return 0;
|
|
1170
1257
|
}
|
|
1171
1258
|
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
} from "@yuneta/gobj-js";
|
|
46
46
|
|
|
47
47
|
import {t} from "i18next";
|
|
48
|
+
import {text_node} from "./yui_text.js";
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
/***************************************************************
|
|
@@ -469,7 +470,8 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
469
470
|
let prefix = kw.title_prefix || "";
|
|
470
471
|
let label_items = [];
|
|
471
472
|
if(prefix) {
|
|
472
|
-
label_items.push(['span', {class: 'yui-dock-label-prefix'},
|
|
473
|
+
label_items.push(['span', {class: 'yui-dock-label-prefix'},
|
|
474
|
+
text_node(prefix)]); // data, not markup
|
|
473
475
|
}
|
|
474
476
|
if(title_key) {
|
|
475
477
|
label_items.push(
|
|
@@ -479,7 +481,8 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
479
481
|
}
|
|
480
482
|
if(label_items.length === 0) {
|
|
481
483
|
/* No split halves supplied (legacy caller): plain text. */
|
|
482
|
-
label_items.push(['span', {class: 'yui-dock-label-kind'},
|
|
484
|
+
label_items.push(['span', {class: 'yui-dock-label-kind'},
|
|
485
|
+
text_node(title)]); // data, not markup
|
|
483
486
|
}
|
|
484
487
|
|
|
485
488
|
let entry = {gobj: win, $chip: null, minimized: false};
|
|
@@ -496,7 +499,9 @@ function ac_register_window(gobj, event, kw, src)
|
|
|
496
499
|
), [
|
|
497
500
|
chip_lead(kw.icon),
|
|
498
501
|
['span', {class: 'yui-dock-label'}, label_items],
|
|
499
|
-
['button', {class: 'yui-dock-close', type: 'button',
|
|
502
|
+
['button', {class: 'yui-dock-close', type: 'button',
|
|
503
|
+
title: t('close'), 'data-i18n-title': 'close',
|
|
504
|
+
'aria-label': t('close'), 'data-i18n-aria-label': 'close'}, WC_X, {
|
|
500
505
|
click: (evt) => {
|
|
501
506
|
evt.stopPropagation();
|
|
502
507
|
gobj_send_event(entry.gobj, "EV_CLOSE_WINDOW", {}, gobj);
|
package/src/c_yui_wizard.js
CHANGED
|
@@ -156,6 +156,8 @@ function mt_destroy(gobj)
|
|
|
156
156
|
************************************************************/
|
|
157
157
|
function build_ui(gobj)
|
|
158
158
|
{
|
|
159
|
+
let back_label = gobj_read_attr(gobj, "back_label");
|
|
160
|
+
let next_label = gobj_read_attr(gobj, "next_label");
|
|
159
161
|
let $container = createElement2(
|
|
160
162
|
['div', {class: 'C_YUI_WIZARD', style: 'height:100%; display:flex; flex-direction:column;'}, [
|
|
161
163
|
['div', {class: 'yui-wizard-header is-flex is-align-items-center is-flex-grow-0',
|
|
@@ -168,17 +170,21 @@ function build_ui(gobj)
|
|
|
168
170
|
],
|
|
169
171
|
['div', {class: 'yui-wizard-footer is-flex is-justify-content-space-between is-flex-grow-0',
|
|
170
172
|
style: 'gap:.5rem; padding:.5rem;'}, [
|
|
171
|
-
['button', {class: 'yui-wizard-back button',
|
|
173
|
+
['button', {class: 'yui-wizard-back button',
|
|
174
|
+
title: t(back_label), 'data-i18n-title': back_label,
|
|
175
|
+
'aria-label': t(back_label), 'data-i18n-aria-label': back_label}, [
|
|
172
176
|
['span', {class: 'icon'}, ['i', {class: 'yi-arrow-left'}]],
|
|
173
|
-
['span', {class: 'is-hidden-mobile', i18n:
|
|
177
|
+
['span', {class: 'is-hidden-mobile', i18n: back_label}, back_label]
|
|
174
178
|
], {
|
|
175
179
|
click: function(evt) {
|
|
176
180
|
evt.stopPropagation();
|
|
177
181
|
gobj_send_event(gobj, "EV_PREV", {}, gobj);
|
|
178
182
|
}
|
|
179
183
|
}],
|
|
180
|
-
['button', {class: 'yui-wizard-primary button is-link',
|
|
181
|
-
|
|
184
|
+
['button', {class: 'yui-wizard-primary button is-link',
|
|
185
|
+
title: t(next_label), 'data-i18n-title': next_label,
|
|
186
|
+
'aria-label': t(next_label), 'data-i18n-aria-label': next_label}, [
|
|
187
|
+
['span', {class: 'yui-wizard-primary-label', i18n: next_label}, next_label]
|
|
182
188
|
], {
|
|
183
189
|
click: function(evt) {
|
|
184
190
|
evt.stopPropagation();
|
|
@@ -243,10 +249,15 @@ function render_chrome(gobj)
|
|
|
243
249
|
let $title = $container.querySelector('.yui-wizard-title');
|
|
244
250
|
let $counter = $container.querySelector('.yui-wizard-counter');
|
|
245
251
|
let $back = $container.querySelector('.yui-wizard-back');
|
|
252
|
+
let $primary = $container.querySelector('.yui-wizard-primary');
|
|
246
253
|
let $plabel = $container.querySelector('.yui-wizard-primary-label');
|
|
247
254
|
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
/* render_chrome runs on every step change, AFTER the host's one-time
|
|
256
|
+
* refresh_language($container,t): translate HERE, and stamp the
|
|
257
|
+
* canonical `data-i18n` (a bare `i18n` attribute is not read by
|
|
258
|
+
* refresh_language) so a later language switch re-translates it. */
|
|
259
|
+
$title.setAttribute('data-i18n', model.title);
|
|
260
|
+
$title.textContent = t(model.title);
|
|
250
261
|
|
|
251
262
|
if(model.count > 0) {
|
|
252
263
|
$counter.textContent = `${model.idx + 1} / ${model.count}`;
|
|
@@ -256,8 +267,12 @@ function render_chrome(gobj)
|
|
|
256
267
|
|
|
257
268
|
$back.classList.toggle('is-hidden', !model.show_back);
|
|
258
269
|
|
|
259
|
-
$plabel.setAttribute('i18n', model.primary_label);
|
|
260
|
-
$plabel.textContent = model.primary_label;
|
|
270
|
+
$plabel.setAttribute('data-i18n', model.primary_label);
|
|
271
|
+
$plabel.textContent = t(model.primary_label);
|
|
272
|
+
$primary.setAttribute('title', t(model.primary_label));
|
|
273
|
+
$primary.setAttribute('data-i18n-title', model.primary_label);
|
|
274
|
+
$primary.setAttribute('aria-label', t(model.primary_label));
|
|
275
|
+
$primary.setAttribute('data-i18n-aria-label', model.primary_label);
|
|
261
276
|
|
|
262
277
|
/*
|
|
263
278
|
* Show only the current step
|