@yuneta/gobj-ui 7.26.1 → 7.26.3
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/dist/gobj-ui.cjs.js +50 -7
- package/dist/gobj-ui.es.js +50 -7
- package/package.json +1 -1
- package/src/c_yui_shell.js +32 -0
- package/src/c_yui_treedb_topics.js +28 -6
- package/src/yui_shell_last_route.test.js +53 -0
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -2699,6 +2699,31 @@ function yui_shell_last_route_under(shell_gobj, route) {
|
|
|
2699
2699
|
return route;
|
|
2700
2700
|
}
|
|
2701
2701
|
/************************************************************
|
|
2702
|
+
* Where the reader last was OUTSIDE `route`: the most recent
|
|
2703
|
+
* visited route that is neither `route` nor below it, or "" when
|
|
2704
|
+
* there is none (the page landed there and never left).
|
|
2705
|
+
*
|
|
2706
|
+
* It is the other half of yui_shell_last_route_under(), and it is
|
|
2707
|
+
* what a "back" button of a view means: the view the reader CAME
|
|
2708
|
+
* FROM, wherever that was. Browser Back already does that; a
|
|
2709
|
+
* button that names one fixed route instead only agrees with it
|
|
2710
|
+
* when the reader happened to come from there. Excluding the
|
|
2711
|
+
* whole subtree is the point -- going from one record of a detail
|
|
2712
|
+
* view to the next must not make "back" step through them.
|
|
2713
|
+
*
|
|
2714
|
+
* Like the other memories, a mirror of the url for the page: the
|
|
2715
|
+
* caller decides what to do with "" (a fixed fallback, usually).
|
|
2716
|
+
************************************************************/
|
|
2717
|
+
function yui_shell_last_route_outside(shell_gobj, route) {
|
|
2718
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
2719
|
+
if (!priv || !(0, _yuneta_gobj_js.is_array)(priv.route_mru) || !route) return "";
|
|
2720
|
+
for (let i = priv.route_mru.length - 1; i >= 0; i--) {
|
|
2721
|
+
let r = priv.route_mru[i];
|
|
2722
|
+
if (r !== route && r.indexOf(route + "/") !== 0) return r;
|
|
2723
|
+
}
|
|
2724
|
+
return "";
|
|
2725
|
+
}
|
|
2726
|
+
/************************************************************
|
|
2702
2727
|
* Resolve the shell that governs `gobj`: the nearest
|
|
2703
2728
|
* C_YUI_SHELL ancestor, else the last shell created on the
|
|
2704
2729
|
* page (apps have exactly one). Null when no shell exists —
|
|
@@ -23944,10 +23969,10 @@ function build_ui$6(gobj) {
|
|
|
23944
23969
|
"button",
|
|
23945
23970
|
{
|
|
23946
23971
|
class: "button TREEDB_TOPICS_BACK is-hidden",
|
|
23947
|
-
title: (0, i18next.t)("
|
|
23948
|
-
"aria-label": (0, i18next.t)("
|
|
23949
|
-
"data-i18n-title": "
|
|
23950
|
-
"data-i18n-aria-label": "
|
|
23972
|
+
title: (0, i18next.t)("back"),
|
|
23973
|
+
"aria-label": (0, i18next.t)("back"),
|
|
23974
|
+
"data-i18n-title": "back",
|
|
23975
|
+
"data-i18n-aria-label": "back"
|
|
23951
23976
|
},
|
|
23952
23977
|
[[
|
|
23953
23978
|
"span",
|
|
@@ -23955,8 +23980,8 @@ function build_ui$6(gobj) {
|
|
|
23955
23980
|
[yui_toolbar_icon("yi-arrow-left")]
|
|
23956
23981
|
], [
|
|
23957
23982
|
"span",
|
|
23958
|
-
{ i18n: "
|
|
23959
|
-
"
|
|
23983
|
+
{ i18n: "back" },
|
|
23984
|
+
"back"
|
|
23960
23985
|
]],
|
|
23961
23986
|
{ click: (evt) => {
|
|
23962
23987
|
evt.stopPropagation();
|
|
@@ -25605,9 +25630,27 @@ function ac_set_landing_view(gobj, event, kw, src) {
|
|
|
25605
25630
|
return 0;
|
|
25606
25631
|
}
|
|
25607
25632
|
/************************************************************
|
|
25608
|
-
* Back from a topic to
|
|
25633
|
+
* Back from a topic to WHERE THE READER WAS.
|
|
25634
|
+
*
|
|
25635
|
+
* Browser Back and this button must land on the same place, or the
|
|
25636
|
+
* reader cannot tell which one to trust (2026-10-10). The button went to
|
|
25637
|
+
* the landing whatever came before it, so "linked records" from
|
|
25638
|
+
* `device_types` opened `devices`, and the arrow then showed the cards
|
|
25639
|
+
* instead of `device_types`, where Back went.
|
|
25640
|
+
*
|
|
25641
|
+
* So it asks the shell for the last route outside the topic on screen
|
|
25642
|
+
* (yui_shell_last_route_outside): the previous topic, the landing, or
|
|
25643
|
+
* the view the reader came from. With none -- the page landed on this
|
|
25644
|
+
* topic -- it goes to the landing, as before.
|
|
25609
25645
|
************************************************************/
|
|
25610
25646
|
function ac_back_to_topics(gobj, event, kw, src) {
|
|
25647
|
+
let shell = yui_shell_of(gobj);
|
|
25648
|
+
let here = shell ? (0, _yuneta_gobj_js.gobj_read_attr)(shell, "current_route") || "" : "";
|
|
25649
|
+
let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
|
|
25650
|
+
if (came_from) {
|
|
25651
|
+
yui_shell_navigate(shell, came_from, { push: true });
|
|
25652
|
+
return 0;
|
|
25653
|
+
}
|
|
25611
25654
|
let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "landing_routes");
|
|
25612
25655
|
let href = (0, _yuneta_gobj_js.is_object)(routes) ? routes[gobj.priv._landing_view] : null;
|
|
25613
25656
|
if (href && typeof window !== "undefined") {
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -2694,6 +2694,31 @@ function yui_shell_last_route_under(shell_gobj, route) {
|
|
|
2694
2694
|
return route;
|
|
2695
2695
|
}
|
|
2696
2696
|
/************************************************************
|
|
2697
|
+
* Where the reader last was OUTSIDE `route`: the most recent
|
|
2698
|
+
* visited route that is neither `route` nor below it, or "" when
|
|
2699
|
+
* there is none (the page landed there and never left).
|
|
2700
|
+
*
|
|
2701
|
+
* It is the other half of yui_shell_last_route_under(), and it is
|
|
2702
|
+
* what a "back" button of a view means: the view the reader CAME
|
|
2703
|
+
* FROM, wherever that was. Browser Back already does that; a
|
|
2704
|
+
* button that names one fixed route instead only agrees with it
|
|
2705
|
+
* when the reader happened to come from there. Excluding the
|
|
2706
|
+
* whole subtree is the point -- going from one record of a detail
|
|
2707
|
+
* view to the next must not make "back" step through them.
|
|
2708
|
+
*
|
|
2709
|
+
* Like the other memories, a mirror of the url for the page: the
|
|
2710
|
+
* caller decides what to do with "" (a fixed fallback, usually).
|
|
2711
|
+
************************************************************/
|
|
2712
|
+
function yui_shell_last_route_outside(shell_gobj, route) {
|
|
2713
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
2714
|
+
if (!priv || !is_array(priv.route_mru) || !route) return "";
|
|
2715
|
+
for (let i = priv.route_mru.length - 1; i >= 0; i--) {
|
|
2716
|
+
let r = priv.route_mru[i];
|
|
2717
|
+
if (r !== route && r.indexOf(route + "/") !== 0) return r;
|
|
2718
|
+
}
|
|
2719
|
+
return "";
|
|
2720
|
+
}
|
|
2721
|
+
/************************************************************
|
|
2697
2722
|
* Resolve the shell that governs `gobj`: the nearest
|
|
2698
2723
|
* C_YUI_SHELL ancestor, else the last shell created on the
|
|
2699
2724
|
* page (apps have exactly one). Null when no shell exists —
|
|
@@ -23939,10 +23964,10 @@ function build_ui$6(gobj) {
|
|
|
23939
23964
|
"button",
|
|
23940
23965
|
{
|
|
23941
23966
|
class: "button TREEDB_TOPICS_BACK is-hidden",
|
|
23942
|
-
title: t("
|
|
23943
|
-
"aria-label": t("
|
|
23944
|
-
"data-i18n-title": "
|
|
23945
|
-
"data-i18n-aria-label": "
|
|
23967
|
+
title: t("back"),
|
|
23968
|
+
"aria-label": t("back"),
|
|
23969
|
+
"data-i18n-title": "back",
|
|
23970
|
+
"data-i18n-aria-label": "back"
|
|
23946
23971
|
},
|
|
23947
23972
|
[[
|
|
23948
23973
|
"span",
|
|
@@ -23950,8 +23975,8 @@ function build_ui$6(gobj) {
|
|
|
23950
23975
|
[yui_toolbar_icon("yi-arrow-left")]
|
|
23951
23976
|
], [
|
|
23952
23977
|
"span",
|
|
23953
|
-
{ i18n: "
|
|
23954
|
-
"
|
|
23978
|
+
{ i18n: "back" },
|
|
23979
|
+
"back"
|
|
23955
23980
|
]],
|
|
23956
23981
|
{ click: (evt) => {
|
|
23957
23982
|
evt.stopPropagation();
|
|
@@ -25600,9 +25625,27 @@ function ac_set_landing_view(gobj, event, kw, src) {
|
|
|
25600
25625
|
return 0;
|
|
25601
25626
|
}
|
|
25602
25627
|
/************************************************************
|
|
25603
|
-
* Back from a topic to
|
|
25628
|
+
* Back from a topic to WHERE THE READER WAS.
|
|
25629
|
+
*
|
|
25630
|
+
* Browser Back and this button must land on the same place, or the
|
|
25631
|
+
* reader cannot tell which one to trust (2026-10-10). The button went to
|
|
25632
|
+
* the landing whatever came before it, so "linked records" from
|
|
25633
|
+
* `device_types` opened `devices`, and the arrow then showed the cards
|
|
25634
|
+
* instead of `device_types`, where Back went.
|
|
25635
|
+
*
|
|
25636
|
+
* So it asks the shell for the last route outside the topic on screen
|
|
25637
|
+
* (yui_shell_last_route_outside): the previous topic, the landing, or
|
|
25638
|
+
* the view the reader came from. With none -- the page landed on this
|
|
25639
|
+
* topic -- it goes to the landing, as before.
|
|
25604
25640
|
************************************************************/
|
|
25605
25641
|
function ac_back_to_topics(gobj, event, kw, src) {
|
|
25642
|
+
let shell = yui_shell_of(gobj);
|
|
25643
|
+
let here = shell ? gobj_read_attr(shell, "current_route") || "" : "";
|
|
25644
|
+
let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
|
|
25645
|
+
if (came_from) {
|
|
25646
|
+
yui_shell_navigate(shell, came_from, { push: true });
|
|
25647
|
+
return 0;
|
|
25648
|
+
}
|
|
25606
25649
|
let routes = gobj_read_attr(gobj, "landing_routes");
|
|
25607
25650
|
let href = is_object(routes) ? routes[gobj.priv._landing_view] : null;
|
|
25608
25651
|
if (href && typeof window !== "undefined") {
|
package/package.json
CHANGED
package/src/c_yui_shell.js
CHANGED
|
@@ -3276,6 +3276,37 @@ function yui_shell_last_route_under(shell_gobj, route)
|
|
|
3276
3276
|
return route;
|
|
3277
3277
|
}
|
|
3278
3278
|
|
|
3279
|
+
/************************************************************
|
|
3280
|
+
* Where the reader last was OUTSIDE `route`: the most recent
|
|
3281
|
+
* visited route that is neither `route` nor below it, or "" when
|
|
3282
|
+
* there is none (the page landed there and never left).
|
|
3283
|
+
*
|
|
3284
|
+
* It is the other half of yui_shell_last_route_under(), and it is
|
|
3285
|
+
* what a "back" button of a view means: the view the reader CAME
|
|
3286
|
+
* FROM, wherever that was. Browser Back already does that; a
|
|
3287
|
+
* button that names one fixed route instead only agrees with it
|
|
3288
|
+
* when the reader happened to come from there. Excluding the
|
|
3289
|
+
* whole subtree is the point -- going from one record of a detail
|
|
3290
|
+
* view to the next must not make "back" step through them.
|
|
3291
|
+
*
|
|
3292
|
+
* Like the other memories, a mirror of the url for the page: the
|
|
3293
|
+
* caller decides what to do with "" (a fixed fallback, usually).
|
|
3294
|
+
************************************************************/
|
|
3295
|
+
function yui_shell_last_route_outside(shell_gobj, route)
|
|
3296
|
+
{
|
|
3297
|
+
let priv = shell_gobj && shell_gobj.priv;
|
|
3298
|
+
if(!priv || !is_array(priv.route_mru) || !route) {
|
|
3299
|
+
return "";
|
|
3300
|
+
}
|
|
3301
|
+
for(let i = priv.route_mru.length - 1; i >= 0; i--) {
|
|
3302
|
+
let r = priv.route_mru[i];
|
|
3303
|
+
if(r !== route && r.indexOf(route + "/") !== 0) {
|
|
3304
|
+
return r;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
return "";
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3279
3310
|
/************************************************************
|
|
3280
3311
|
* Resolve the shell that governs `gobj`: the nearest
|
|
3281
3312
|
* C_YUI_SHELL ancestor, else the last shell created on the
|
|
@@ -3716,6 +3747,7 @@ export {
|
|
|
3716
3747
|
yui_shell_zone,
|
|
3717
3748
|
yui_shell_navigate,
|
|
3718
3749
|
yui_shell_last_route_under,
|
|
3750
|
+
yui_shell_last_route_outside,
|
|
3719
3751
|
yui_shell_nav_map,
|
|
3720
3752
|
yui_shell_set_sub_routes,
|
|
3721
3753
|
yui_shell_register_event_handler,
|
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
yui_shell_set_sub_routes,
|
|
70
70
|
yui_shell_navigate,
|
|
71
71
|
yui_shell_last_route_under,
|
|
72
|
+
yui_shell_last_route_outside,
|
|
72
73
|
} from "./c_yui_shell.js";
|
|
73
74
|
import {nodes_answer} from "./nodes_answer.js";
|
|
74
75
|
import {yui_toolbar_icon} from "./yui_toolbar.js";
|
|
@@ -367,13 +368,15 @@ function build_ui(gobj)
|
|
|
367
368
|
* graph's toolbar has many more, so it keeps
|
|
368
369
|
* is-hidden-mobile. */
|
|
369
370
|
|
|
370
|
-
/* Back to the
|
|
371
|
-
* hidden until a topic is open.
|
|
371
|
+
/* Back to where the reader was (cards-landing mode only);
|
|
372
|
+
* hidden until a topic is open. It is 'back' and not
|
|
373
|
+
* 'topics' because that is where it goes: the previous
|
|
374
|
+
* topic, the landing, or the view the reader came from. */
|
|
372
375
|
['button', {class: 'button TREEDB_TOPICS_BACK is-hidden',
|
|
373
|
-
title: t('
|
|
374
|
-
'data-i18n-title': '
|
|
376
|
+
title: t('back'), 'aria-label': t('back'),
|
|
377
|
+
'data-i18n-title': 'back', 'data-i18n-aria-label': 'back'}, [
|
|
375
378
|
['span', {class: 'icon'}, [yui_toolbar_icon('yi-arrow-left')]],
|
|
376
|
-
['span', {i18n: '
|
|
379
|
+
['span', {i18n: 'back'}, 'back']
|
|
377
380
|
], {
|
|
378
381
|
click: (evt) => {
|
|
379
382
|
evt.stopPropagation();
|
|
@@ -2749,10 +2752,29 @@ function ac_set_landing_view(gobj, event, kw, src)
|
|
|
2749
2752
|
}
|
|
2750
2753
|
|
|
2751
2754
|
/************************************************************
|
|
2752
|
-
* Back from a topic to
|
|
2755
|
+
* Back from a topic to WHERE THE READER WAS.
|
|
2756
|
+
*
|
|
2757
|
+
* Browser Back and this button must land on the same place, or the
|
|
2758
|
+
* reader cannot tell which one to trust (2026-10-10). The button went to
|
|
2759
|
+
* the landing whatever came before it, so "linked records" from
|
|
2760
|
+
* `device_types` opened `devices`, and the arrow then showed the cards
|
|
2761
|
+
* instead of `device_types`, where Back went.
|
|
2762
|
+
*
|
|
2763
|
+
* So it asks the shell for the last route outside the topic on screen
|
|
2764
|
+
* (yui_shell_last_route_outside): the previous topic, the landing, or
|
|
2765
|
+
* the view the reader came from. With none -- the page landed on this
|
|
2766
|
+
* topic -- it goes to the landing, as before.
|
|
2753
2767
|
************************************************************/
|
|
2754
2768
|
function ac_back_to_topics(gobj, event, kw, src)
|
|
2755
2769
|
{
|
|
2770
|
+
let shell = yui_shell_of(gobj);
|
|
2771
|
+
let here = shell ? (gobj_read_attr(shell, "current_route") || "") : "";
|
|
2772
|
+
let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
|
|
2773
|
+
if(came_from) {
|
|
2774
|
+
yui_shell_navigate(shell, came_from, {push: true});
|
|
2775
|
+
return 0;
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2756
2778
|
/* With host routes the landing is a POSITION, so Back GOES there, the
|
|
2757
2779
|
* way the toggle does, and the route drives the switch.
|
|
2758
2780
|
*
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* yui_shell_last_route_under() / yui_shell_last_route_outside():
|
|
3
|
+
* the two questions asked of the shell's memory of visited routes.
|
|
4
|
+
* They read only `priv.route_mru`, so a bare object stands in for
|
|
5
|
+
* the shell.
|
|
6
|
+
*/
|
|
7
|
+
import {describe, it, expect} from "vitest";
|
|
8
|
+
import {
|
|
9
|
+
yui_shell_last_route_under,
|
|
10
|
+
yui_shell_last_route_outside,
|
|
11
|
+
} from "./c_yui_shell.js";
|
|
12
|
+
|
|
13
|
+
function shell(mru)
|
|
14
|
+
{
|
|
15
|
+
return {priv: {route_mru: mru}};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("yui_shell_last_route_outside", () => {
|
|
19
|
+
it("answers the view the reader came from", () => {
|
|
20
|
+
const s = shell(["/devices/list", "/devices/map/table", "/devices/detail/E1"]);
|
|
21
|
+
expect(yui_shell_last_route_outside(s, "/devices/detail")).toBe("/devices/map/table");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("skips every record of the same view, not only the current one", () => {
|
|
25
|
+
const s = shell(["/alarms", "/devices/detail/E1", "/devices/detail/E2"]);
|
|
26
|
+
expect(yui_shell_last_route_outside(s, "/devices/detail")).toBe("/alarms");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("answers the bare route of a view too", () => {
|
|
30
|
+
const s = shell(["/devices/map", "/devices/detail"]);
|
|
31
|
+
expect(yui_shell_last_route_outside(s, "/devices/detail")).toBe("/devices/map");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("does not take a sibling that only shares a prefix for a child", () => {
|
|
35
|
+
const s = shell(["/devices/detailed", "/devices/detail/E1"]);
|
|
36
|
+
expect(yui_shell_last_route_outside(s, "/devices/detail")).toBe("/devices/detailed");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("answers empty when the page never left the view", () => {
|
|
40
|
+
expect(yui_shell_last_route_outside(shell(["/devices/detail/E1"]), "/devices/detail")).toBe("");
|
|
41
|
+
expect(yui_shell_last_route_outside(shell([]), "/devices/detail")).toBe("");
|
|
42
|
+
expect(yui_shell_last_route_outside(null, "/devices/detail")).toBe("");
|
|
43
|
+
expect(yui_shell_last_route_outside(shell(["/x"]), "")).toBe("");
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("yui_shell_last_route_under", () => {
|
|
48
|
+
it("answers the deepest recent position under a route, or the route", () => {
|
|
49
|
+
const s = shell(["/graph/users", "/alarms"]);
|
|
50
|
+
expect(yui_shell_last_route_under(s, "/graph")).toBe("/graph/users");
|
|
51
|
+
expect(yui_shell_last_route_under(s, "/cards")).toBe("/cards");
|
|
52
|
+
});
|
|
53
|
+
});
|