@yuneta/gobj-ui 7.26.13 → 7.26.15
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 +10 -0
- package/dist/gobj-ui.cjs.js +97 -32
- package/dist/gobj-ui.es.js +97 -32
- package/package.json +2 -1
- package/scripts/check-markup-strings.mjs +41 -1
- package/src/c_g6_nodes_tree.js +46 -38
- package/src/c_yui_schema_editor.js +5 -1
- package/src/c_yui_shell.js +134 -5
- package/src/c_yui_treedb_graph.js +16 -5
- package/src/c_yui_treedb_topic_with_form.js +6 -1
- package/src/c_yui_window_manager.js +8 -21
- package/src/data_as_text.wiring.test.js +196 -0
- package/src/gclass_head_text.wiring.test.js +39 -0
- package/src/overlay_marker_after_back.wiring.test.js +271 -6
- package/src/window_show.wiring.test.js +5 -5
- package/src/window_veto_back.wiring.test.js +6 -2
|
@@ -50,6 +50,48 @@ function url_hash(url)
|
|
|
50
50
|
url.slice(url.indexOf("#")) : null;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/* The model's own writes of the fragment: never a "link". */
|
|
54
|
+
function set_hash(h)
|
|
55
|
+
{
|
|
56
|
+
if(session.raw_hash_set) {
|
|
57
|
+
session.raw_hash_set(h);
|
|
58
|
+
} else {
|
|
59
|
+
window.location.hash = h;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* As a browser does with `location.hash = x` -- what the push of
|
|
64
|
+
* yui_shell_navigate() does: a new entry, popstate, then the queued
|
|
65
|
+
* hashchange. Opt-in, and undone by links_on_hash_assign_off(): the
|
|
66
|
+
* other tests assign the hash to set their page up. */
|
|
67
|
+
function links_on_hash_assign()
|
|
68
|
+
{
|
|
69
|
+
let raw = window.location.hash;
|
|
70
|
+
session.raw_hash_set = (h) => {
|
|
71
|
+
raw = h;
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(window.location, "hash", {
|
|
74
|
+
configurable: true,
|
|
75
|
+
get() {
|
|
76
|
+
return raw;
|
|
77
|
+
},
|
|
78
|
+
set(v) {
|
|
79
|
+
if(v === raw) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
link_to(v);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function links_on_hash_assign_off()
|
|
88
|
+
{
|
|
89
|
+
const h = window.location.hash;
|
|
90
|
+
delete window.location.hash;
|
|
91
|
+
session.raw_hash_set = null;
|
|
92
|
+
window.location.hash = h;
|
|
93
|
+
}
|
|
94
|
+
|
|
53
95
|
function install_history_model()
|
|
54
96
|
{
|
|
55
97
|
session.entries = [{state: null, hash: window.location.hash}];
|
|
@@ -64,7 +106,7 @@ function install_history_model()
|
|
|
64
106
|
pushState(state, title, url) {
|
|
65
107
|
const h = url_hash(url);
|
|
66
108
|
if(h !== null) {
|
|
67
|
-
|
|
109
|
+
set_hash(h);
|
|
68
110
|
}
|
|
69
111
|
session.entries.splice(session.index + 1);
|
|
70
112
|
session.entries.push({state: state, hash: window.location.hash});
|
|
@@ -73,7 +115,7 @@ function install_history_model()
|
|
|
73
115
|
replaceState(state, title, url) {
|
|
74
116
|
const h = url_hash(url);
|
|
75
117
|
if(h !== null) {
|
|
76
|
-
|
|
118
|
+
set_hash(h);
|
|
77
119
|
}
|
|
78
120
|
session.entries[session.index] = {state: state, hash: window.location.hash};
|
|
79
121
|
},
|
|
@@ -112,7 +154,7 @@ function traverse_to(index)
|
|
|
112
154
|
{
|
|
113
155
|
const left = window.location.hash;
|
|
114
156
|
session.index = index;
|
|
115
|
-
|
|
157
|
+
set_hash(session.entries[index].hash);
|
|
116
158
|
fire_popstate();
|
|
117
159
|
if(session.entries[index].hash !== left) {
|
|
118
160
|
queue_hashchange();
|
|
@@ -126,7 +168,7 @@ function link_to(hash)
|
|
|
126
168
|
session.entries.splice(session.index + 1);
|
|
127
169
|
session.entries.push({state: null, hash: hash});
|
|
128
170
|
session.index++;
|
|
129
|
-
|
|
171
|
+
set_hash(hash);
|
|
130
172
|
fire_popstate();
|
|
131
173
|
queue_hashchange();
|
|
132
174
|
}
|
|
@@ -224,6 +266,9 @@ function routed_shell(name, app)
|
|
|
224
266
|
/* A test leaves no shell listening and no queued hashchange behind: the
|
|
225
267
|
* next test's shell would otherwise hear the previous test's traversal. */
|
|
226
268
|
afterEach(async () => {
|
|
269
|
+
if(session.raw_hash_set) {
|
|
270
|
+
links_on_hash_assign_off(); // a test that failed half-way
|
|
271
|
+
}
|
|
227
272
|
await next_task();
|
|
228
273
|
await next_task();
|
|
229
274
|
for(const sh of shells.splice(0)) {
|
|
@@ -312,7 +357,7 @@ describe("an overlay registered while a back() of ours is in flight", () => {
|
|
|
312
357
|
expect(shell.priv.expected_pops).toBe(0);
|
|
313
358
|
expect(session.entries.length).toBe(2); // the dead first marker, ahead
|
|
314
359
|
expect(session.index).toBe(0);
|
|
315
|
-
expect(window.history.state).
|
|
360
|
+
expect(window.history.state).toEqual({__yui_below__: 1}); // stamped, no marker
|
|
316
361
|
expect(errors()).toEqual([]);
|
|
317
362
|
});
|
|
318
363
|
|
|
@@ -484,8 +529,40 @@ describe("a routed shell, a realistic history (V5)", () => {
|
|
|
484
529
|
|
|
485
530
|
user_back();
|
|
486
531
|
await next_task();
|
|
532
|
+
await next_task();
|
|
487
533
|
expect(closed).toBe(1);
|
|
488
534
|
expect(shell.priv.overlay_stack).toEqual([]);
|
|
535
|
+
/* Back closed the panel; it did not move the view. */
|
|
536
|
+
expect(window.location.hash).toBe("#/home/pos");
|
|
537
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/home/pos");
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
test("a dialog's action that closes it and navigates in the same turn: the navigation survives", async () => {
|
|
541
|
+
const app = gobj_create("vapp_go", "C_TEST_MARKER_APP", {}, yuno);
|
|
542
|
+
gobj_start(app);
|
|
543
|
+
window.location.hash = "#/home";
|
|
544
|
+
install_history_model();
|
|
545
|
+
const shell = routed_shell("vshell_go", app);
|
|
546
|
+
const {yui_shell_register_overlay, yui_shell_overlay_dismissed, yui_shell_navigate} =
|
|
547
|
+
await import("./c_yui_shell.js");
|
|
548
|
+
const entry = yui_shell_register_overlay(shell, () => {});
|
|
549
|
+
await next_task();
|
|
550
|
+
links_on_hash_assign();
|
|
551
|
+
|
|
552
|
+
yui_shell_overlay_dismissed(shell, entry); // the close: a back() of ours
|
|
553
|
+
yui_shell_navigate(shell, "/prev"); // and the navigation, same turn
|
|
554
|
+
for(let i = 0; i < 4; i++) {
|
|
555
|
+
await next_task();
|
|
556
|
+
}
|
|
557
|
+
expect(shell.priv.expected_pops).toBe(0);
|
|
558
|
+
expect(window.location.hash).toBe("#/prev");
|
|
559
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/prev");
|
|
560
|
+
expect(window.history.state).toBe(null); // no marker left
|
|
561
|
+
|
|
562
|
+
user_back();
|
|
563
|
+
await next_task();
|
|
564
|
+
await next_task();
|
|
565
|
+
expect(window.location.hash).toBe("#/home"); // not swallowed
|
|
489
566
|
});
|
|
490
567
|
|
|
491
568
|
test("a button close after a replace navigation keeps the position", async () => {
|
|
@@ -506,7 +583,7 @@ describe("a routed shell, a realistic history (V5)", () => {
|
|
|
506
583
|
expect(shell.priv.expected_pops).toBe(0);
|
|
507
584
|
expect(window.location.hash).toBe("#/home/pos");
|
|
508
585
|
expect(gobj_read_attr(shell, "current_route")).toBe("/home/pos");
|
|
509
|
-
expect(window.history.state).
|
|
586
|
+
expect(window.history.state).toEqual({__yui_below__: entry.id}); // stamped, no marker
|
|
510
587
|
expect(errors()).toEqual([]);
|
|
511
588
|
});
|
|
512
589
|
|
|
@@ -579,3 +656,191 @@ describe("a routed shell, a realistic history (V5)", () => {
|
|
|
579
656
|
});
|
|
580
657
|
});
|
|
581
658
|
|
|
659
|
+
/*
|
|
660
|
+
* Sixth check of the review (V6).
|
|
661
|
+
*/
|
|
662
|
+
/* The test app declares no route event: what the shell says is what
|
|
663
|
+
* these tests read. */
|
|
664
|
+
function shell_warnings()
|
|
665
|
+
{
|
|
666
|
+
return errors().filter((m) => m.includes("C_YUI_SHELL"));
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
describe("a link is not a Back (V6.1)", () => {
|
|
670
|
+
test("a link back to the hash a kept panel was opened on keeps it open", async () => {
|
|
671
|
+
const app = gobj_create("v6app1", "C_TEST_MARKER_APP", {}, yuno);
|
|
672
|
+
gobj_start(app);
|
|
673
|
+
window.location.hash = "#/home";
|
|
674
|
+
install_history_model();
|
|
675
|
+
const shell = routed_shell("v6shell1", app);
|
|
676
|
+
const {yui_shell_register_overlay} = await import("./c_yui_shell.js");
|
|
677
|
+
let closed = 0;
|
|
678
|
+
yui_shell_register_overlay(shell, () => { closed++; }, {keep_on_navigate: true});
|
|
679
|
+
|
|
680
|
+
link_to("#/other");
|
|
681
|
+
await next_task();
|
|
682
|
+
link_to("#/home"); // the panel's own hash
|
|
683
|
+
await next_task();
|
|
684
|
+
await next_task();
|
|
685
|
+
expect(closed).toBe(0);
|
|
686
|
+
expect(shell.priv.overlay_stack.length).toBe(1);
|
|
687
|
+
expect(window.location.hash).toBe("#/home");
|
|
688
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/home");
|
|
689
|
+
expect(shell_warnings()).toEqual([]);
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
test("after a replace navigation, a link to the hash under the marker: URL and view agree", async () => {
|
|
693
|
+
const app = gobj_create("v6app2", "C_TEST_MARKER_APP", {}, yuno);
|
|
694
|
+
gobj_start(app);
|
|
695
|
+
window.location.hash = "#/home";
|
|
696
|
+
install_history_model();
|
|
697
|
+
const shell = routed_shell("v6shell2", app);
|
|
698
|
+
const {yui_shell_register_overlay, yui_shell_navigate} = await import("./c_yui_shell.js");
|
|
699
|
+
let closed = 0;
|
|
700
|
+
yui_shell_register_overlay(shell, () => { closed++; }, {keep_on_navigate: true});
|
|
701
|
+
yui_shell_navigate(shell, "/home/pos", {replace: true});
|
|
702
|
+
|
|
703
|
+
link_to("#/other");
|
|
704
|
+
await next_task();
|
|
705
|
+
link_to("#/home"); // the hash of the entry under the marker
|
|
706
|
+
await next_task();
|
|
707
|
+
await next_task();
|
|
708
|
+
expect(closed).toBe(0);
|
|
709
|
+
expect(window.location.hash).toBe("#/home");
|
|
710
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/home");
|
|
711
|
+
expect(shell_warnings()).toEqual([]);
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
test("from the position, a link to the panel's hash is a push; Back walks it, then closes the panel", async () => {
|
|
715
|
+
const app = gobj_create("v6app3", "C_TEST_MARKER_APP", {}, yuno);
|
|
716
|
+
gobj_start(app);
|
|
717
|
+
window.location.hash = "#/home";
|
|
718
|
+
install_history_model();
|
|
719
|
+
const shell = routed_shell("v6shell3", app);
|
|
720
|
+
const {yui_shell_register_overlay, yui_shell_navigate} = await import("./c_yui_shell.js");
|
|
721
|
+
let closed = 0;
|
|
722
|
+
yui_shell_register_overlay(shell, () => { closed++; }, {keep_on_navigate: true});
|
|
723
|
+
yui_shell_navigate(shell, "/home/pos", {replace: true});
|
|
724
|
+
|
|
725
|
+
link_to("#/home");
|
|
726
|
+
await next_task();
|
|
727
|
+
await next_task();
|
|
728
|
+
expect(closed).toBe(0);
|
|
729
|
+
expect(window.location.hash).toBe("#/home");
|
|
730
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/home");
|
|
731
|
+
|
|
732
|
+
user_back(); // onto the marker: the panel is home
|
|
733
|
+
await next_task();
|
|
734
|
+
await next_task();
|
|
735
|
+
expect(closed).toBe(0);
|
|
736
|
+
expect(window.location.hash).toBe("#/home/pos");
|
|
737
|
+
|
|
738
|
+
user_back(); // off it: closes the panel
|
|
739
|
+
await next_task();
|
|
740
|
+
await next_task();
|
|
741
|
+
expect(closed).toBe(1);
|
|
742
|
+
expect(window.location.hash).toBe("#/home/pos");
|
|
743
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/home/pos");
|
|
744
|
+
expect(shell_warnings()).toEqual([]);
|
|
745
|
+
});
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
describe("a route waiting for a back() of ours (V6.2)", () => {
|
|
749
|
+
test("a newer route replaces the waiting one, and says so", async () => {
|
|
750
|
+
const app = gobj_create("v6app4", "C_TEST_MARKER_APP", {}, yuno);
|
|
751
|
+
gobj_start(app);
|
|
752
|
+
window.location.hash = "#/home";
|
|
753
|
+
install_history_model();
|
|
754
|
+
const shell = routed_shell("v6shell4", app);
|
|
755
|
+
const {yui_shell_register_overlay, yui_shell_overlay_dismissed, yui_shell_navigate} =
|
|
756
|
+
await import("./c_yui_shell.js");
|
|
757
|
+
const entry = yui_shell_register_overlay(shell, () => {});
|
|
758
|
+
links_on_hash_assign();
|
|
759
|
+
|
|
760
|
+
yui_shell_overlay_dismissed(shell, entry);
|
|
761
|
+
yui_shell_navigate(shell, "/prev");
|
|
762
|
+
yui_shell_navigate(shell, "/other");
|
|
763
|
+
for(let i = 0; i < 4; i++) {
|
|
764
|
+
await next_task();
|
|
765
|
+
}
|
|
766
|
+
expect(window.location.hash).toBe("#/other");
|
|
767
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/other");
|
|
768
|
+
expect(shell_warnings().filter(m => m.includes("is replaced by '/other'")).length).toBe(1);
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
test("a back() that never lands is given up on, and the waiting route runs", async () => {
|
|
772
|
+
const app = gobj_create("v6app5", "C_TEST_MARKER_APP", {}, yuno);
|
|
773
|
+
gobj_start(app);
|
|
774
|
+
window.location.hash = "#/home";
|
|
775
|
+
install_history_model();
|
|
776
|
+
const shell = routed_shell("v6shell5", app);
|
|
777
|
+
const {yui_shell_register_overlay, yui_shell_overlay_dismissed, yui_shell_navigate} =
|
|
778
|
+
await import("./c_yui_shell.js");
|
|
779
|
+
const entry = yui_shell_register_overlay(shell, () => {});
|
|
780
|
+
window.history.back = () => {}; // it never lands
|
|
781
|
+
links_on_hash_assign();
|
|
782
|
+
|
|
783
|
+
yui_shell_overlay_dismissed(shell, entry);
|
|
784
|
+
yui_shell_navigate(shell, "/prev");
|
|
785
|
+
await next_task();
|
|
786
|
+
expect(window.location.hash).toBe("#/home"); // still waiting
|
|
787
|
+
await new Promise(resolve => setTimeout(resolve, 1100));
|
|
788
|
+
await next_task();
|
|
789
|
+
expect(shell.priv.expected_pops).toBe(0);
|
|
790
|
+
expect(window.location.hash).toBe("#/prev");
|
|
791
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/prev");
|
|
792
|
+
expect(shell_warnings().filter(m => m.includes("given up")).length).toBe(1);
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
test("a user's link while a route waits: the link wins, the route is dropped out loud", async () => {
|
|
796
|
+
const app = gobj_create("v6app6", "C_TEST_MARKER_APP", {}, yuno);
|
|
797
|
+
gobj_start(app);
|
|
798
|
+
window.location.hash = "#/home";
|
|
799
|
+
install_history_model();
|
|
800
|
+
const shell = routed_shell("v6shell6", app);
|
|
801
|
+
const {yui_shell_register_overlay, yui_shell_overlay_dismissed, yui_shell_navigate} =
|
|
802
|
+
await import("./c_yui_shell.js");
|
|
803
|
+
const entry = yui_shell_register_overlay(shell, () => {});
|
|
804
|
+
window.history.back = () => {}; // the link cancels the traversal
|
|
805
|
+
|
|
806
|
+
yui_shell_overlay_dismissed(shell, entry);
|
|
807
|
+
yui_shell_navigate(shell, "/prev");
|
|
808
|
+
link_to("#/other");
|
|
809
|
+
for(let i = 0; i < 4; i++) {
|
|
810
|
+
await next_task();
|
|
811
|
+
}
|
|
812
|
+
expect(window.location.hash).toBe("#/other");
|
|
813
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/other");
|
|
814
|
+
expect(shell.priv.deferred_route).toBe("");
|
|
815
|
+
expect(shell_warnings().filter(m => m.includes("'/prev' waited for that back() and is dropped")).length).toBe(1);
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
test("a menu click in the same turn as a close waits for the back() too", async () => {
|
|
819
|
+
const app = gobj_create("v6app7", "C_TEST_MARKER_APP", {}, yuno);
|
|
820
|
+
gobj_start(app);
|
|
821
|
+
window.location.hash = "#/home";
|
|
822
|
+
install_history_model();
|
|
823
|
+
const shell = routed_shell("v6shell7", app);
|
|
824
|
+
const {yui_shell_register_overlay, yui_shell_overlay_dismissed} = await import("./c_yui_shell.js");
|
|
825
|
+
const {gobj_send_event} = await import("@yuneta/gobj-js");
|
|
826
|
+
const entry = yui_shell_register_overlay(shell, () => {});
|
|
827
|
+
await next_task();
|
|
828
|
+
links_on_hash_assign();
|
|
829
|
+
|
|
830
|
+
yui_shell_overlay_dismissed(shell, entry);
|
|
831
|
+
gobj_send_event(shell, "EV_NAV_CLICKED", {route: "/prev"}, app);
|
|
832
|
+
for(let i = 0; i < 4; i++) {
|
|
833
|
+
await next_task();
|
|
834
|
+
}
|
|
835
|
+
expect(shell.priv.expected_pops).toBe(0);
|
|
836
|
+
expect(window.location.hash).toBe("#/prev");
|
|
837
|
+
expect(gobj_read_attr(shell, "current_route")).toBe("/prev");
|
|
838
|
+
expect(window.history.state).toBe(null); // the pushed entry, no marker
|
|
839
|
+
expect(shell_warnings()).toEqual([]);
|
|
840
|
+
|
|
841
|
+
user_back();
|
|
842
|
+
await next_task();
|
|
843
|
+
await next_task();
|
|
844
|
+
expect(window.location.hash).toBe("#/home"); // not swallowed
|
|
845
|
+
});
|
|
846
|
+
});
|
|
@@ -98,12 +98,12 @@ describe("EV_SHOW", () => {
|
|
|
98
98
|
expect($w.style.getPropertyValue("display")).toBe("");
|
|
99
99
|
expect(errors().some((m) => m.includes("is not the src"))).toBe(true);
|
|
100
100
|
|
|
101
|
-
/* The old form (the gobj in the kw)
|
|
101
|
+
/* The old form (the gobj in the kw) is refused since 7.26.14,
|
|
102
|
+
* even from the window itself. */
|
|
102
103
|
logged.length = 0;
|
|
103
104
|
gobj_send_event(dock, "EV_MINIMIZE_WINDOW", {window: w}, w);
|
|
104
|
-
expect($w.style.getPropertyValue("display")).toBe("
|
|
105
|
-
expect(errors()).
|
|
106
|
-
expect(logged.some((l) => l.level === "warning" && l.msg.includes("gobj_full_name"))).toBe(true);
|
|
105
|
+
expect($w.style.getPropertyValue("display")).toBe("");
|
|
106
|
+
expect(errors().some((m) => m.includes("carries the window gobj"))).toBe(true);
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
test("with plain strings as TEXT (set_strings_are_text) the controls are still svg", () => {
|
|
@@ -148,7 +148,7 @@ describe("EV_SHOW", () => {
|
|
|
148
148
|
/* The OLD form (the gobj in the kw), sent by another gobj. */
|
|
149
149
|
logged.length = 0;
|
|
150
150
|
gobj_send_event(dock, ev, {window: w}, other);
|
|
151
|
-
expect(errors().some((m) => m.includes("
|
|
151
|
+
expect(errors().some((m) => m.includes("carries the window gobj"))).toBe(true);
|
|
152
152
|
}
|
|
153
153
|
expect(dock.priv.windows.length).toBe(n_windows); // nothing unregistered
|
|
154
154
|
expect(dock.priv.windows.some((e) => e.gobj === other)).toBe(false); // nothing registered
|
|
@@ -69,10 +69,14 @@ function errors()
|
|
|
69
69
|
return logged.filter((l) => l.level === "error").map((l) => l.msg);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/* A Back off a marker lands on the entry under it, which the shell
|
|
73
|
+
* stamped when it pushed the marker: a landing with NO state is a push
|
|
74
|
+
* (a link), not a Back. */
|
|
72
75
|
function press_back()
|
|
73
76
|
{
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const ev = new Event("popstate");
|
|
78
|
+
ev.state = {__yui_below__: 0};
|
|
79
|
+
window.dispatchEvent(ev);
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
describe("a floating window that vetoes its close", () => {
|