@yuneta/gobj-ui 7.18.1 → 7.18.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 +31 -3
- package/dist/gobj-ui.es.js +31 -3
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +67 -3
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -53869,6 +53869,7 @@ var PRIVATE_DATA$1 = {
|
|
|
53869
53869
|
_focus_topic: null,
|
|
53870
53870
|
_focus_ids: [],
|
|
53871
53871
|
_on_pointerdown_focus: null,
|
|
53872
|
+
_on_focusout_restore: null,
|
|
53872
53873
|
_selected_paint_ids: [],
|
|
53873
53874
|
_pending_focus_topic: null,
|
|
53874
53875
|
_pending_find: null,
|
|
@@ -53934,9 +53935,13 @@ function mt_destroy$1(gobj) {
|
|
|
53934
53935
|
priv._on_language_changed = null;
|
|
53935
53936
|
}
|
|
53936
53937
|
if (priv._on_pointerdown_focus) {
|
|
53937
|
-
priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
|
|
53938
|
+
priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
53938
53939
|
priv._on_pointerdown_focus = null;
|
|
53939
53940
|
}
|
|
53941
|
+
if (priv._on_focusout_restore) {
|
|
53942
|
+
priv.$container.removeEventListener("focusout", priv._on_focusout_restore);
|
|
53943
|
+
priv._on_focusout_restore = null;
|
|
53944
|
+
}
|
|
53940
53945
|
if (priv.theme_observer) {
|
|
53941
53946
|
priv.theme_observer.disconnect();
|
|
53942
53947
|
priv.theme_observer = null;
|
|
@@ -54108,10 +54113,17 @@ function configure_events(gobj) {
|
|
|
54108
54113
|
if (target.closest("input, textarea, select, [contenteditable]")) return;
|
|
54109
54114
|
if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
|
|
54110
54115
|
}
|
|
54111
|
-
let $canvas = priv.$container
|
|
54116
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54112
54117
|
if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
|
|
54113
54118
|
};
|
|
54114
|
-
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
|
|
54119
|
+
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
54120
|
+
priv._on_focusout_restore = (ev) => {
|
|
54121
|
+
if (ev.relatedTarget) return;
|
|
54122
|
+
if ((0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) return;
|
|
54123
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54124
|
+
if ($canvas && $canvas.isConnected && document.activeElement !== $canvas) $canvas.focus({ preventScroll: true });
|
|
54125
|
+
};
|
|
54126
|
+
priv.$container.addEventListener("focusout", priv._on_focusout_restore);
|
|
54115
54127
|
graph.on("keydown", (evt) => {
|
|
54116
54128
|
let ctrl = !!(evt.ctrlKey || evt.metaKey);
|
|
54117
54129
|
if (ctrl && (evt.key === "a" || evt.key === "A")) {
|
|
@@ -55604,6 +55616,22 @@ function perform_history_op(gobj, is_redo) {
|
|
|
55604
55616
|
}
|
|
55605
55617
|
}
|
|
55606
55618
|
/************************************************************
|
|
55619
|
+
* The canvas G6 listens on.
|
|
55620
|
+
*
|
|
55621
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
55622
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
55623
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
55624
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
55625
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
55626
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
55627
|
+
* and delivers no key.
|
|
55628
|
+
************************************************************/
|
|
55629
|
+
function main_canvas_of($container) {
|
|
55630
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
55631
|
+
for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
|
|
55632
|
+
return canvases[0] || null;
|
|
55633
|
+
}
|
|
55634
|
+
/************************************************************
|
|
55607
55635
|
* The selection.
|
|
55608
55636
|
*
|
|
55609
55637
|
* G6's `selected` element state IS the selection: `drag-element`
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -53856,6 +53856,7 @@ var PRIVATE_DATA$1 = {
|
|
|
53856
53856
|
_focus_topic: null,
|
|
53857
53857
|
_focus_ids: [],
|
|
53858
53858
|
_on_pointerdown_focus: null,
|
|
53859
|
+
_on_focusout_restore: null,
|
|
53859
53860
|
_selected_paint_ids: [],
|
|
53860
53861
|
_pending_focus_topic: null,
|
|
53861
53862
|
_pending_find: null,
|
|
@@ -53921,9 +53922,13 @@ function mt_destroy$1(gobj) {
|
|
|
53921
53922
|
priv._on_language_changed = null;
|
|
53922
53923
|
}
|
|
53923
53924
|
if (priv._on_pointerdown_focus) {
|
|
53924
|
-
priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
|
|
53925
|
+
priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
53925
53926
|
priv._on_pointerdown_focus = null;
|
|
53926
53927
|
}
|
|
53928
|
+
if (priv._on_focusout_restore) {
|
|
53929
|
+
priv.$container.removeEventListener("focusout", priv._on_focusout_restore);
|
|
53930
|
+
priv._on_focusout_restore = null;
|
|
53931
|
+
}
|
|
53927
53932
|
if (priv.theme_observer) {
|
|
53928
53933
|
priv.theme_observer.disconnect();
|
|
53929
53934
|
priv.theme_observer = null;
|
|
@@ -54095,10 +54100,17 @@ function configure_events(gobj) {
|
|
|
54095
54100
|
if (target.closest("input, textarea, select, [contenteditable]")) return;
|
|
54096
54101
|
if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
|
|
54097
54102
|
}
|
|
54098
|
-
let $canvas = priv.$container
|
|
54103
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54099
54104
|
if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
|
|
54100
54105
|
};
|
|
54101
|
-
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
|
|
54106
|
+
priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
|
|
54107
|
+
priv._on_focusout_restore = (ev) => {
|
|
54108
|
+
if (ev.relatedTarget) return;
|
|
54109
|
+
if (gobj_is_destroying(gobj)) return;
|
|
54110
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
54111
|
+
if ($canvas && $canvas.isConnected && document.activeElement !== $canvas) $canvas.focus({ preventScroll: true });
|
|
54112
|
+
};
|
|
54113
|
+
priv.$container.addEventListener("focusout", priv._on_focusout_restore);
|
|
54102
54114
|
graph.on("keydown", (evt) => {
|
|
54103
54115
|
let ctrl = !!(evt.ctrlKey || evt.metaKey);
|
|
54104
54116
|
if (ctrl && (evt.key === "a" || evt.key === "A")) {
|
|
@@ -55591,6 +55603,22 @@ function perform_history_op(gobj, is_redo) {
|
|
|
55591
55603
|
}
|
|
55592
55604
|
}
|
|
55593
55605
|
/************************************************************
|
|
55606
|
+
* The canvas G6 listens on.
|
|
55607
|
+
*
|
|
55608
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
55609
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
55610
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
55611
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
55612
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
55613
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
55614
|
+
* and delivers no key.
|
|
55615
|
+
************************************************************/
|
|
55616
|
+
function main_canvas_of($container) {
|
|
55617
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
55618
|
+
for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
|
|
55619
|
+
return canvases[0] || null;
|
|
55620
|
+
}
|
|
55621
|
+
/************************************************************
|
|
55594
55622
|
* The selection.
|
|
55595
55623
|
*
|
|
55596
55624
|
* G6's `selected` element state IS the selection: `drag-element`
|
package/package.json
CHANGED
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
gobj_parent,
|
|
38
38
|
gobj_name,
|
|
39
39
|
gobj_short_name,
|
|
40
|
+
gobj_is_destroying,
|
|
40
41
|
gobj_subscribe_event,
|
|
41
42
|
gobj_publish_event,
|
|
42
43
|
gobj_send_event,
|
|
@@ -334,6 +335,7 @@ let PRIVATE_DATA = {
|
|
|
334
335
|
_focus_topic: null, // topic currently focused (EV_FOCUS_TOPIC)
|
|
335
336
|
_focus_ids: [], // node ids carrying the focus 'active' state
|
|
336
337
|
_on_pointerdown_focus: null, // listener keeping the keyboard on the canvas
|
|
338
|
+
_on_focusout_restore: null, // ...and putting it back when it goes nowhere
|
|
337
339
|
_selected_paint_ids: [], // node ids whose card is PAINTED selected
|
|
338
340
|
// (G6's 'selected' state is the selection
|
|
339
341
|
// itself; this is what is on screen, and
|
|
@@ -462,11 +464,18 @@ function mt_destroy(gobj)
|
|
|
462
464
|
|
|
463
465
|
if(priv._on_pointerdown_focus) {
|
|
464
466
|
priv.$container.removeEventListener(
|
|
465
|
-
"pointerdown", priv._on_pointerdown_focus
|
|
467
|
+
"pointerdown", priv._on_pointerdown_focus, true
|
|
466
468
|
);
|
|
467
469
|
priv._on_pointerdown_focus = null;
|
|
468
470
|
}
|
|
469
471
|
|
|
472
|
+
if(priv._on_focusout_restore) {
|
|
473
|
+
priv.$container.removeEventListener(
|
|
474
|
+
"focusout", priv._on_focusout_restore
|
|
475
|
+
);
|
|
476
|
+
priv._on_focusout_restore = null;
|
|
477
|
+
}
|
|
478
|
+
|
|
470
479
|
if(priv.theme_observer) {
|
|
471
480
|
priv.theme_observer.disconnect();
|
|
472
481
|
priv.theme_observer = null;
|
|
@@ -818,12 +827,43 @@ function configure_events(gobj)
|
|
|
818
827
|
return;
|
|
819
828
|
}
|
|
820
829
|
}
|
|
821
|
-
let $canvas = priv.$container
|
|
830
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
822
831
|
if($canvas && typeof $canvas.focus === "function") {
|
|
823
832
|
$canvas.focus({preventScroll: true});
|
|
824
833
|
}
|
|
825
834
|
};
|
|
826
|
-
|
|
835
|
+
/* Capture: the cards are DOM and may stop the press from
|
|
836
|
+
* bubbling. */
|
|
837
|
+
priv.$container.addEventListener(
|
|
838
|
+
"pointerdown", priv._on_pointerdown_focus, true
|
|
839
|
+
);
|
|
840
|
+
|
|
841
|
+
/* And put it back when it is taken away to NOWHERE.
|
|
842
|
+
*
|
|
843
|
+
* Focusing on pointerdown is not enough on its own, which is
|
|
844
|
+
* measurable: the press does focus the canvas, and then the
|
|
845
|
+
* browser runs its own focus handling for the mousedown -- after
|
|
846
|
+
* ours -- and a card is not focusable, so it moves the focus to
|
|
847
|
+
* <body>. The graph goes deaf right after the click that
|
|
848
|
+
* selected something, which is the worst possible moment.
|
|
849
|
+
*
|
|
850
|
+
* Only when it goes nowhere (`relatedTarget` null). A focus
|
|
851
|
+
* moving to a REAL element -- the find box, a dialog, the next
|
|
852
|
+
* tab stop -- is the user leaving, and is left alone.
|
|
853
|
+
*/
|
|
854
|
+
priv._on_focusout_restore = (ev) => {
|
|
855
|
+
if(ev.relatedTarget) {
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if(gobj_is_destroying(gobj)) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
let $canvas = main_canvas_of(priv.$container);
|
|
862
|
+
if($canvas && $canvas.isConnected && document.activeElement !== $canvas) {
|
|
863
|
+
$canvas.focus({preventScroll: true});
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
priv.$container.addEventListener("focusout", priv._on_focusout_restore);
|
|
827
867
|
|
|
828
868
|
/* The canvas carries a `tabIndex` of its own, so a keydown reaches
|
|
829
869
|
* us only while the GRAPH has focus. That is what keeps Ctrl+A in
|
|
@@ -3125,6 +3165,30 @@ function perform_history_op(gobj, is_redo)
|
|
|
3125
3165
|
}
|
|
3126
3166
|
}
|
|
3127
3167
|
|
|
3168
|
+
/************************************************************
|
|
3169
|
+
* The canvas G6 listens on.
|
|
3170
|
+
*
|
|
3171
|
+
* A G6 graph stacks four canvases and gives every one of them a
|
|
3172
|
+
* `tabIndex`, so `querySelector("canvas")` finds a focusable
|
|
3173
|
+
* element that receives nothing: only the MAIN layer carries the
|
|
3174
|
+
* listeners, and it is the only one G6 leaves with pointer events
|
|
3175
|
+
* (`configCanvasDom` sets `pointerEvents: none` on the rest).
|
|
3176
|
+
* Focusing the wrong one looks exactly like focusing the right one
|
|
3177
|
+
* and delivers no key.
|
|
3178
|
+
************************************************************/
|
|
3179
|
+
function main_canvas_of($container)
|
|
3180
|
+
{
|
|
3181
|
+
let canvases = $container.querySelectorAll("canvas");
|
|
3182
|
+
|
|
3183
|
+
for(let i = 0; i < canvases.length; i++) {
|
|
3184
|
+
if(window.getComputedStyle(canvases[i]).pointerEvents !== "none") {
|
|
3185
|
+
return canvases[i];
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
return canvases[0] || null;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3128
3192
|
/************************************************************
|
|
3129
3193
|
* The selection.
|
|
3130
3194
|
*
|